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:
parent
17b039cb49
commit
a059d6f4f5
2 changed files with 19 additions and 9 deletions
|
@ -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 n.IPAM != nil {
|
||||||
if spec.IPAM.Driver != nil {
|
if n.IPAM.Driver != nil {
|
||||||
ipam.Driver = spec.IPAM.Driver.Name
|
ipam.Driver = n.IPAM.Driver.Name
|
||||||
ipam.Options = spec.IPAM.Driver.Options
|
ipam.Options = n.IPAM.Driver.Options
|
||||||
}
|
}
|
||||||
ipam.Config = make([]networktypes.IPAMConfig, 0, len(spec.IPAM.Configs))
|
ipam.Config = make([]networktypes.IPAMConfig, 0, len(n.IPAM.Configs))
|
||||||
for _, ic := range spec.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,
|
||||||
|
|
|
@ -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) {
|
if len(service.Tasks) != int(instances) {
|
||||||
return true
|
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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue