Forráskód Böngészése

Fixing network inspect for swarm

Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
Abhinandan Prativadi 7 éve
szülő
commit
a059d6f4f5

+ 6 - 6
daemon/cluster/convert/network.go

@@ -140,13 +140,13 @@ func swarmPortConfigToAPIPortConfig(portConfig *swarmapi.PortConfig) types.PortC
 func BasicNetworkFromGRPC(n swarmapi.Network) basictypes.NetworkResource {
 func BasicNetworkFromGRPC(n swarmapi.Network) basictypes.NetworkResource {
 	spec := n.Spec
 	spec := n.Spec
 	var ipam networktypes.IPAM
 	var ipam networktypes.IPAM
-	if spec.IPAM != nil {
-		if spec.IPAM.Driver != nil {
-			ipam.Driver = spec.IPAM.Driver.Name
-			ipam.Options = spec.IPAM.Driver.Options
+	if n.IPAM != nil {
+		if n.IPAM.Driver != nil {
+			ipam.Driver = n.IPAM.Driver.Name
+			ipam.Options = n.IPAM.Driver.Options
 		}
 		}
-		ipam.Config = make([]networktypes.IPAMConfig, 0, len(spec.IPAM.Configs))
-		for _, ic := range spec.IPAM.Configs {
+		ipam.Config = make([]networktypes.IPAMConfig, 0, len(n.IPAM.Configs))
+		for _, ic := range n.IPAM.Configs {
 			ipamConfig := networktypes.IPAMConfig{
 			ipamConfig := networktypes.IPAMConfig{
 				Subnet:     ic.Subnet,
 				Subnet:     ic.Subnet,
 				IPRange:    ic.Range,
 				IPRange:    ic.Range,

+ 13 - 3
integration/network/inspect_test.go

@@ -162,9 +162,19 @@ func noTasks(client client.ServiceAPIClient) func(log poll.LogT) poll.Result {
 // Check to see if Service and Tasks info are part of the inspect verbose response
 // Check to see if Service and Tasks info are part of the inspect verbose response
 func validNetworkVerbose(network types.NetworkResource, service string, instances uint64) bool {
 func validNetworkVerbose(network types.NetworkResource, service string, instances uint64) bool {
 	if service, ok := network.Services[service]; ok {
 	if service, ok := network.Services[service]; ok {
-		if len(service.Tasks) == int(instances) {
-			return true
+		if len(service.Tasks) != int(instances) {
+			return false
 		}
 		}
 	}
 	}
-	return false
+
+	if network.IPAM.Config == nil {
+		return false
+	}
+
+	for _, cfg := range network.IPAM.Config {
+		if cfg.Gateway == "" || cfg.Subnet == "" {
+			return false
+		}
+	}
+	return true
 }
 }