Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add debugs for swarm diagnostic #12233

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/compose/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -1339,17 +1339,18 @@ func (s *composeService) resolveExternalNetwork(ctx context.Context, n *types.Ne
networks, err := s.apiClient().NetworkList(ctx, network.ListOptions{
Filters: filters.NewArgs(filters.Arg("name", n.Name)),
})

if err != nil {
return err
}
logrus.Debugf("search network %q by name returned: %d", n.Name, len(networks))

if len(networks) == 0 {
// in this instance, n.Name is really an ID
sn, err := s.apiClient().NetworkInspect(ctx, n.Name, network.InspectOptions{})
if err != nil && !errdefs.IsNotFound(err) {
return err
}
logrus.Debugf("search network %q by ID succeeded", n.Name)
networks = append(networks, sn)
}

Expand All @@ -1360,16 +1361,19 @@ func (s *composeService) resolveExternalNetwork(ctx context.Context, n *types.Ne
// we still require just one network back, but we need to run the search on the ID
return net.Name == n.Name || net.ID == n.Name
})
logrus.Debugf("networks matching name %q after strict filtering: %d", n.Name, len(networks))

switch len(networks) {
case 1:
logrus.Debugf("match, network is: %s", networks[0].ID)
n.Name = networks[0].ID
return nil
case 0:
enabled, err := s.isSWarmEnabled(ctx)
if err != nil {
return err
}
logrus.Debugf("no match, swarm is enabled: %t", enabled)
if enabled {
// Swarm nodes do not register overlay networks that were
// created on a different node unless they're in use.
Expand Down
Loading