Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Ignore docker source cleanup err when resource not found #588

Merged
merged 1 commit into from
Apr 20, 2020
Merged
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
6 changes: 5 additions & 1 deletion pkg/dmlegacy/image_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strings"
"unicode"

containerderr "github.com/containerd/containerd/errdefs"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
api "github.com/weaveworks/ignite/pkg/apis/ignite"
Expand Down Expand Up @@ -99,7 +100,10 @@ func addFiles(img *api.Image, src source.Source) error {
}

if err := src.Cleanup(); err != nil {
return err
// Ignore the cleanup error if the resource no longer exists.
if !errors.Is(err, containerderr.ErrNotFound) {
return err
}
}

return setupResolvConf(tempDir)
Expand Down
7 changes: 6 additions & 1 deletion pkg/operations/import.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package operations

import (
"errors"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path"

containerderr "github.com/containerd/containerd/errdefs"
log "github.com/sirupsen/logrus"
"github.com/weaveworks/gitops-toolkit/pkg/filter"
"github.com/weaveworks/gitops-toolkit/pkg/storage/filterer"
Expand Down Expand Up @@ -156,7 +158,10 @@ func importKernel(c *client.Client, ociRef meta.OCIImageRef) (*api.Kernel, error

// Remove the temporary container
if err := dockerSource.Cleanup(); err != nil {
return nil, err
// Ignore the cleanup error if the resource no longer exists.
if !errors.Is(err, containerderr.ErrNotFound) {
return nil, err
}
}

// Locate the kernel file in the temporary directory
Expand Down