Repository: dragonflyoss/Dragonfly2
Pull request #1379 (2022-06-13 13:01:42)

feat: dfdaemon add ns filter
Signed-off-by: Gaius <gaius.qi@gmail.com>

<!--- Provide a general summary of your changes in the Title above -->

## Description
- Dfdaemn add ns filter.
<!--- 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)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] 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! -->

- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have read the **CONTRIBUTING** document.
- [ ] I have added tests to cover my changes.



Patch:
diff --git a/build/package/nfpm/config/dfget.yaml b/build/package/nfpm/config/dfget.yaml
index 875d4b4a..951c0719 100644
--- a/build/package/nfpm/config/dfget.yaml
+++ b/build/package/nfpm/config/dfget.yaml
@@ -109,7 +109,7 @@ storage:
 # proxy service option
 proxy:
   maxConcurrency: 12
-  defaultFilter: Expires&Signature
+  defaultFilter: Expires&Signature&ns
   security:
     insecure: true
     cacert: ""
diff --git a/deploy/docker-compose/template/dfget.template.yaml b/deploy/docker-compose/template/dfget.template.yaml
index 846c1321..e8787b0b 100644
--- a/deploy/docker-compose/template/dfget.template.yaml
+++ b/deploy/docker-compose/template/dfget.template.yaml
@@ -193,10 +193,10 @@ storage:
 # proxy service detail option
 proxy:
   # filter for hash url
-  # when defaultFilter: "Expires&Signature", for example:
-  #  http://localhost/xyz?Expires=111&Signature=222 and http://localhost/xyz?Expires=333&Signature=999
+  # when defaultFilter: "Expires&Signature&ns", for example:
+  #  http://localhost/xyz?Expires=111&Signature=222&ns=docker.io and http://localhost/xyz?Expires=333&Signature=999&ns=docker.io
   # is same task
-  defaultFilter: "Expires&Signature"
+  defaultFilter: "Expires&Signature&ns"
   security:
     insecure: true
     cacert: ""
diff --git a/pkg/rpc/client_util.go b/pkg/rpc/client_util.go
index 38f33160..31ea99c0 100644
--- a/pkg/rpc/client_util.go
+++ b/pkg/rpc/client_util.go
@@ -94,19 +94,8 @@ func (conn *Connection) startGC() {
 // gcConn gc keys and clients associated with server node
 func (conn *Connection) gcConn(node string) {
 	logger.GrpcLogger.With("conn", conn.name).Infof("gc keys and clients associated with server node: %s starting", node)
-	value, ok := conn.node2ClientMap.Load(node)
-	if ok {
-		clientCon := value.(*grpc.ClientConn)
-		err := clientCon.Close()
-		if err == nil {
-			conn.node2ClientMap.Delete(node)
-			logger.GrpcLogger.With("conn", conn.name).Infof("success gc clientConn: %s", node)
-		} else {
-			logger.GrpcLogger.With("conn", conn.name).Warnf("failed to close clientConn: %s: %v", node, err)
-		}
-	} else {
-		logger.GrpcLogger.With("conn", conn.name).Warnf("server node: %s dose not found in node2ClientMap", node)
-	}
+	conn.node2ClientMap.Delete(node)
+	logger.GrpcLogger.With("conn", conn.name).Infof("success gc clientConn: %s", node)
 	// gc hash keys
 	conn.key2NodeMap.Range(func(key, value interface{}) bool {
 		if value == node {


Test patch:
diff --git a/test/testdata/charts/config.yaml b/test/testdata/charts/config.yaml
index 69b20fa7..90f6eeb5 100644
--- a/test/testdata/charts/config.yaml
+++ b/test/testdata/charts/config.yaml
@@ -79,7 +79,7 @@ dfdaemon:
     scheduler:
       disableAutoBackSource: true
     proxy:
-      defaultFilter: "Expires&Signature"
+      defaultFilter: "Expires&Signature&ns"
       security:
         insecure: true
       tcpListen:
diff --git a/test/testdata/k8s/proxy.yaml b/test/testdata/k8s/proxy.yaml
index 0b8eb6c0..8d1a9a66 100644
--- a/test/testdata/k8s/proxy.yaml
+++ b/test/testdata/k8s/proxy.yaml
@@ -55,7 +55,7 @@ data:
       strategy: io.d7y.storage.v2.simple
       taskExpireTime: 6h
     proxy:
-      defaultFilter: Expires&Signature
+      defaultFilter: Expires&Signature&ns
       tcpListen:
         listen: 0.0.0.0
         port: 65001