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

Merge pull request #37045 from abhi/inspect

Fixing network inspect for swarm
This commit is contained in:
Sebastiaan van Stijn 2018-05-14 12:51:12 +02:00 committed by GitHub
commit 8baea3a1bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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
}