Skip to content

Commit ec6a6ab

Browse files
committed
Relax error on annotations read failure
Signed-off-by: apostasie <[email protected]>
1 parent 558dd93 commit ec6a6ab

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

pkg/cmd/container/kill.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ func cleanupNetwork(ctx context.Context, container containerd.Container, globalO
143143
networksJSON := spec.Annotations[labels.Networks]
144144
var networks []string
145145
if err := json.Unmarshal([]byte(networksJSON), &networks); err != nil {
146-
return err
146+
log.G(ctx).WithError(err).WithField("container", container.ID()).Infof("unable to retrieve networking information for that container")
147+
return nil
147148
}
148149
netType, err := nettype.Detect(networks)
149150
if err != nil {

pkg/cmd/container/remove.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,18 @@ func RemoveContainer(ctx context.Context, c containerd.Container, globalOptions
191191
}
192192

193193
netOpts, err := containerutil.NetworkOptionsFromSpec(spec)
194-
if err != nil {
195-
retErr = fmt.Errorf("failed to load container networking options from specs: %s", err)
196-
return
197-
}
198-
199-
networkManager, err := containerutil.NewNetworkingOptionsManager(globalOptions, netOpts, client)
200-
if err != nil {
201-
retErr = fmt.Errorf("failed to instantiate network options manager: %s", err)
202-
return
203-
}
194+
if err == nil {
195+
networkManager, err := containerutil.NewNetworkingOptionsManager(globalOptions, netOpts, client)
196+
if err != nil {
197+
retErr = fmt.Errorf("failed to instantiate network options manager: %s", err)
198+
return
199+
}
204200

205-
if err := networkManager.CleanupNetworking(ctx, c); err != nil {
206-
log.G(ctx).WithError(err).Warnf("failed to clean up container networking: %q", id)
201+
if err := networkManager.CleanupNetworking(ctx, c); err != nil {
202+
log.G(ctx).WithError(err).Warnf("failed to clean up container networking: %q", id)
203+
}
204+
} else {
205+
log.G(ctx).WithError(err).WithField("container", id).Infof("unable to retrieve networking information for that container")
207206
}
208207

209208
// Delete the container now. If it fails, try again without snapshot cleanup

0 commit comments

Comments
 (0)