Skip to content

Commit

Permalink
Relax error on annotations read failure
Browse files Browse the repository at this point in the history
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
  • Loading branch information
apostasie committed Dec 17, 2024
1 parent 7e97f06 commit 41757b2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
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

0 comments on commit 41757b2

Please sign in to comment.