Merge pull request #11409 from ndeloof/swarm_overlay_network

don't check external network existence when swarm is enabled
This commit is contained in:
Guillaume Lours 2024-01-29 20:11:13 +01:00 committed by GitHub
commit ac8ea082a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 10 deletions

View File

@ -1246,19 +1246,16 @@ func (s *composeService) resolveExternalNetwork(ctx context.Context, n *types.Ne
n.Name = networks[0].ID
return nil
case 0:
if n.Driver == "overlay" {
enabled, err := s.isSWarmEnabled(ctx)
if err != nil {
return err
}
if enabled {
// Swarm nodes do not register overlay networks that were
// created on a different node unless they're in use.
// Here we assume `driver` is relevant for a network we don't manage
// which is a non-sense, but this is our legacy ¯\(ツ)/¯
// So we can't preemptively check network exists, but
// networkAttach will later fail anyway if network actually doesn't exists
enabled, err := s.isSWarmEnabled(ctx)
if err != nil {
return err
}
if enabled {
return nil
}
return nil
}
return fmt.Errorf("network %s declared as external, but could not be found", n.Name)
default: