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

Relax error on network annotation read failure #3771

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion pkg/cmd/container/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ func cleanupNetwork(ctx context.Context, container containerd.Container, globalO
networksJSON := spec.Annotations[labels.Networks]
var networks []string
if err := json.Unmarshal([]byte(networksJSON), &networks); err != nil {
return err
log.G(ctx).WithError(err).Infof("unable to retrieve networking information for that container, which is likely managed by another tool")
return nil
}
netType, err := nettype.Detect(networks)
if err != nil {
Expand Down
23 changes: 11 additions & 12 deletions pkg/cmd/container/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,18 @@ func RemoveContainer(ctx context.Context, c containerd.Container, globalOptions
}

netOpts, err := containerutil.NetworkOptionsFromSpec(spec)
if err != nil {
retErr = fmt.Errorf("failed to load container networking options from specs: %s", err)
return
}

networkManager, err := containerutil.NewNetworkingOptionsManager(globalOptions, netOpts, client)
if err != nil {
retErr = fmt.Errorf("failed to instantiate network options manager: %s", err)
return
}
if err == nil {
networkManager, err := containerutil.NewNetworkingOptionsManager(globalOptions, netOpts, client)
if err != nil {
retErr = fmt.Errorf("failed to instantiate network options manager: %s", err)
return
}

if err := networkManager.CleanupNetworking(ctx, c); err != nil {
log.G(ctx).WithError(err).Warnf("failed to clean up container networking: %q", id)
if err := networkManager.CleanupNetworking(ctx, c); err != nil {
log.G(ctx).WithError(err).Warnf("failed to clean up container networking: %q", id)
}
} else {
log.G(ctx).WithError(err).Infof("unable to retrieve networking information for that container, which is likely managed by another tool: %q", id)
}

// Delete the container now. If it fails, try again without snapshot cleanup
Expand Down
Loading