Repository: dragonflyoss/Dragonfly2
Pull request #904 (2021-12-09 06:18:32)

docs: dir path
Signed-off-by: Gaius <gaius.qi@gmail.com>

<!--- Provide a general summary of your changes in the Title above -->

## Description
- Dir path config document.
<!--- Describe your changes in detail -->

## Related Issue

<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->

## Screenshots (if appropriate):

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [x] Documentation Update (if none of the other choices apply)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [x] Code compiles correctly.
- [x] My code follows the code style of this project.
- [x] My change requires a change to the documentation.
- [x] I have updated the documentation accordingly.
- [x] I have read the **CONTRIBUTING** document.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.



Patch:
diff --git a/docs/en/deployment/configuration/cdn.yaml b/docs/en/deployment/configuration/cdn.yaml
index 4cd2f8aa..b5f53c93 100644
--- a/docs/en/deployment/configuration/cdn.yaml
+++ b/docs/en/deployment/configuration/cdn.yaml
@@ -43,6 +43,11 @@ base:
   # storageMode is the Mode of storage policy, [disk/hybrid]
   storageMode: disk
 
+  # logDir is the log storage directory
+  # in linux, default value is /var/log/dragonfly
+  # in macos(just for testing), default value is /Users/$USER/.dragonfly/logs
+  logDir: ""
+
   # manager configuration
   manager:
     addr: ""
diff --git a/docs/en/deployment/configuration/dfget.yaml b/docs/en/deployment/configuration/dfget.yaml
index 5045ee7d..fe76b354 100644
--- a/docs/en/deployment/configuration/dfget.yaml
+++ b/docs/en/deployment/configuration/dfget.yaml
@@ -5,15 +5,20 @@ aliveTime: 0s
 # daemon gc task running interval
 gcInterval: 1m0s
 
-# daemon data directory
-# in linux, default value is $HOME/.dragonfly/dfget-daemon/
-# in macos(just for testing), default value is /Users/$USER/.dragonfly/dfdaemon/
-dataDir: /var/lib/dragonfly
-
 # daemon work directory, daemon will change current working directory to this
-# in linux, default value is $HOME/.dragonfly/dfget-daemon/
-# in macos(just for testing), default value is /Users/$USER/.dragonfly/dfdaemon/
-workHome: /var/lib/dragonfly
+# in linux, default value is /usr/local/dragonfly
+# in macos(just for testing), default value is /Users/$USER/.dragonfly
+workHome: ""
+
+# cacheDir is dynconfig cache storage directory
+# in linux, default value is /var/cache/dragonfly
+# in macos(just for testing), default value is /Users/$USER/.dragonfly/cache
+cacheDir: ""
+
+# logDir is the log storage directory
+# in linux, default value is /var/log/dragonfly
+# in macos(just for testing), default value is /Users/$USER/.dragonfly/logs
+logDir: ""
 
 # when daemon exit, keep peer task data or not
 # it is usefully when upgrade daemon service, all local cache will be saved
diff --git a/docs/en/deployment/configuration/scheduler.yaml b/docs/en/deployment/configuration/scheduler.yaml
index 6657c208..ec07a036 100644
--- a/docs/en/deployment/configuration/scheduler.yaml
+++ b/docs/en/deployment/configuration/scheduler.yaml
@@ -53,6 +53,16 @@ server:
   # default: 8002
   port: 8002
 
+  # cacheDir is dynconfig cache storage directory
+  # in linux, default value is /var/cache/dragonfly
+  # in macos(just for testing), default value is /Users/$USER/.dragonfly/cache
+  cacheDir: ""
+
+  # logDir is the log storage directory
+  # in linux, default value is /var/log/dragonfly
+  # in macos(just for testing), default value is /Users/$USER/.dragonfly/logs
+  logDir: ""
+
 # dynamic data configuration
 dynConfig:
   # dynamic data source type
diff --git a/pkg/source/source_client.go b/pkg/source/source_client.go
index 53dc0e34..c4e58633 100644
--- a/pkg/source/source_client.go
+++ b/pkg/source/source_client.go
@@ -147,28 +147,36 @@ func WithPluginDir(dir string) Option {
 }
 
 func (m *clientManager) Register(scheme string, resourceClient ResourceClient, adaptor requestAdapter, hooks ...Hook) error {
+	scheme = strings.ToLower(scheme)
 	m.mu.Lock()
 	defer m.mu.Unlock()
-	if client, ok := m.clients[strings.ToLower(scheme)]; ok {
+	if client, ok := m.clients[scheme]; ok {
 		if client.(*clientWrapper).rc != resourceClient {
 			return errors.Errorf("client with scheme %s already exist, current client: %#v", scheme, client)
 		}
+		logger.Warnf("client with scheme %s already exist, no need register again", scheme)
+		return nil
 	}
-	m.clients[strings.ToLower(scheme)] = &clientWrapper{
+	m.doRegister(scheme, &clientWrapper{
 		adapter: adaptor,
 		hooks:   hooks,
 		rc:      resourceClient,
-	}
+	})
 	return nil
 }
 
+func (m *clientManager) doRegister(scheme string, resourceClient ResourceClient) {
+	m.clients[strings.ToLower(scheme)] = resourceClient
+}
+
 func (m *clientManager) UnRegister(scheme string) {
 	m.mu.Lock()
 	defer m.mu.Unlock()
-	if client, ok := m.clients[strings.ToLower(scheme)]; ok {
+	scheme = strings.ToLower(scheme)
+	if client, ok := m.clients[scheme]; ok {
 		logger.Infof("remove client %#v for scheme %s", client, scheme)
 	}
-	delete(m.clients, strings.ToLower(scheme))
+	delete(m.clients, scheme)
 }
 
 func (m *clientManager) GetClient(scheme string, options ...Option) (ResourceClient, bool) {
@@ -198,7 +206,7 @@ func (m *clientManager) GetClient(scheme string, options ...Option) (ResourceCli
 		m.mu.Unlock()
 		return nil, false
 	}
-	m.clients[scheme] = client
+	m.doRegister(scheme, client)
 	m.mu.Unlock()
 	return client, true
 }


Test patch:
diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go
index 467d0526..83acdb91 100644
--- a/test/e2e/e2e_test.go
+++ b/test/e2e/e2e_test.go
@@ -68,6 +68,7 @@ var _ = BeforeSuite(func() {
 	rawDfgetVersion, err := pod.Command("dfget", "version").CombinedOutput()
 	Expect(err).NotTo(HaveOccurred())
 	dfgetGitCommit := strings.Fields(string(rawDfgetVersion))[7]
+	fmt.Printf("raw dfget version: %s\n", rawDfgetVersion)
 	fmt.Printf("dfget merge commit: %s\n", dfgetGitCommit)
 
 	if mode == dfdaemonCompatibilityTestMode {
diff --git a/test/testdata/k8s/proxy.yaml b/test/testdata/k8s/proxy.yaml
index 2b268f95..c380be34 100644
--- a/test/testdata/k8s/proxy.yaml
+++ b/test/testdata/k8s/proxy.yaml
@@ -8,7 +8,6 @@ data:
     aliveTime: 0s
     gcInterval: 1m0s
     keepStorage: false
-    dataDir: /root/.dragonfly/dfget-daemon/
     workDir: /root/.dragonfly/dfget-daemon/
     verbose: true
     pprof-port: 0