1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fixing network inspect for swarm

Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
This commit is contained in:
Abhinandan Prativadi 2018-05-11 14:37:01 -07:00
parent 17b039cb49
commit a059d6f4f5
2 changed files with 19 additions and 9 deletions

View file

@ -140,13 +140,13 @@ func swarmPortConfigToAPIPortConfig(portConfig *swarmapi.PortConfig) types.PortC
func BasicNetworkFromGRPC(n swarmapi.Network) basictypes.NetworkResource {
spec := n.Spec
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{
Subnet: ic.Subnet,
IPRange: ic.Range,

View file

@ -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
func validNetworkVerbose(network types.NetworkResource, service string, instances uint64) bool {
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
}