Skip to content

Commit

Permalink
don't check external network existence when swarm is enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Jan 25, 2024
1 parent bef8785 commit 84796d4
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions pkg/compose/create.go
Expand Up @@ -1245,19 +1245,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 {

Check warning on line 1252 in pkg/compose/create.go

View check run for this annotation

Codecov / codecov/patch

pkg/compose/create.go#L1248-L1252

Added lines #L1248 - L1252 were not covered by tests
// 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

Check warning on line 1255 in pkg/compose/create.go

View check run for this annotation

Codecov / codecov/patch

pkg/compose/create.go#L1255

Added line #L1255 was not covered by tests
// 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

Check warning on line 1257 in pkg/compose/create.go

View check run for this annotation

Codecov / codecov/patch

pkg/compose/create.go#L1257

Added line #L1257 was not covered by tests
}
return fmt.Errorf("network %s declared as external, but could not be found", n.Name)
default:
Expand Down

0 comments on commit 84796d4

Please sign in to comment.