Skip to content

OCI image debugging improvements #1478

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

Merged
merged 2 commits into from
Dec 10, 2024
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
8 changes: 6 additions & 2 deletions client/oci_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/lxc/incus/v6/shared/api"
"github.com/lxc/incus/v6/shared/ioprogress"
"github.com/lxc/incus/v6/shared/logger"
"github.com/lxc/incus/v6/shared/osarch"
"github.com/lxc/incus/v6/shared/subprocess"
"github.com/lxc/incus/v6/shared/units"
Expand Down Expand Up @@ -145,13 +146,14 @@ func (r *ProtocolOCI) GetImageFile(fingerprint string, req ImageFileRequest) (*I
req.ProgressHandler(ioprogress.ProgressData{Text: "Retrieving OCI image from registry"})
}

_, err = subprocess.RunCommand(
stdout, err := subprocess.RunCommand(
"skopeo",
"--insecure-policy",
"copy",
fmt.Sprintf("%s/%s", strings.Replace(r.httpHost, "https://", "docker://", -1), info.Alias),
fmt.Sprintf("oci:%s:latest", filepath.Join(ociPath, "oci")))
if err != nil {
logger.Debug("Error copying remote image to local", logger.Ctx{"image": info.Alias, "stdout": stdout, "stderr": err})
return nil, err
}

Expand All @@ -160,13 +162,14 @@ func (r *ProtocolOCI) GetImageFile(fingerprint string, req ImageFileRequest) (*I
req.ProgressHandler(ioprogress.ProgressData{Text: "Unpacking the OCI image"})
}

_, err = subprocess.RunCommand(
stdout, err = subprocess.RunCommand(
"umoci",
"unpack",
"--keep-dirlinks",
"--image", filepath.Join(ociPath, "oci"),
filepath.Join(ociPath, "image"))
if err != nil {
logger.Debug("Error unpacking OCI image", logger.Ctx{"image": filepath.Join(ociPath, "oci"), "stdout": stdout, "stderr": err})
return nil, err
}

Expand Down Expand Up @@ -305,6 +308,7 @@ func (r *ProtocolOCI) GetImageAlias(name string) (*api.ImageAliasesEntry, string
// Get the image information from skopeo.
stdout, err := subprocess.RunCommand("skopeo", "inspect", fmt.Sprintf("%s/%s", strings.Replace(r.httpHost, "https://", "docker://", -1), name))
if err != nil {
logger.Debug("Error getting image alias", logger.Ctx{"name": name, "stdout": stdout, "stderr": err})
return nil, "", err
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/incusd/daemon_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func ImageDownload(ctx context.Context, r *http.Request, s *state.State, op *ope
// Setup OCI client
remote, err = incus.ConnectOCI(args.Server, clientArgs)
if err != nil {
return nil, false, fmt.Errorf("Failed to connect to simple streams server %q: %w", args.Server, err)
return nil, false, fmt.Errorf("Failed to connect to oci server %q: %w", args.Server, err)
}
} else if protocol == "simplestreams" {
// Setup simplestreams client
Expand All @@ -114,7 +114,7 @@ func ImageDownload(ctx context.Context, r *http.Request, s *state.State, op *ope

// For public images, handle aliases and initial metadata
if args.Secret == "" {
// Look for a matching alias
// Look for a matching alias. Note, this err message is lost!
entry, _, err := remote.GetImageAliasType(args.Type, fp)
if err == nil {
fp = entry.Target
Expand Down
Loading