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

OCI container fixes #1001

Merged
merged 3 commits into from
Jul 15, 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
16 changes: 16 additions & 0 deletions client/oci_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
Expand Down Expand Up @@ -55,6 +56,11 @@ func (r *ProtocolOCI) GetImagesWithFilter(filters []string) ([]api.Image, error)
func (r *ProtocolOCI) GetImage(fingerprint string) (*api.Image, string, error) {
info, ok := r.cache[fingerprint]
if !ok {
_, err := exec.LookPath("skopeo")
if err != nil {
return nil, "", fmt.Errorf("OCI container handling requires \"skopeo\" be present on the system")
}

return nil, "", fmt.Errorf("Image not found")
}

Expand Down Expand Up @@ -93,6 +99,11 @@ func (r *ProtocolOCI) GetImageFile(fingerprint string, req ImageFileRequest) (*I

info, ok := r.cache[fingerprint]
if !ok {
_, err := exec.LookPath("skopeo")
if err != nil {
return nil, fmt.Errorf("OCI container handling requires \"skopeo\" be present on the system")
}

return nil, fmt.Errorf("Image not found")
}

Expand All @@ -105,6 +116,11 @@ func (r *ProtocolOCI) GetImageFile(fingerprint string, req ImageFileRequest) (*I
return nil, fmt.Errorf("OCI image export currently requires root access")
}

_, err := exec.LookPath("umoci")
if err != nil {
return nil, fmt.Errorf("OCI container handling requires \"umoci\" be present on the system")
}

// Get some temporary storage.
ociPath, err := os.MkdirTemp("", "incus-oci-")
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions cmd/incusd/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ func instanceCreateFromImage(ctx context.Context, s *state.State, r *http.Reques

// If dealing with an OCI image, parse the configuration.
if args.Type == instancetype.Container && inst.LocalConfig()["image.type"] == "oci" {
// Reset the config to the post-generation one.
args.Config = inst.LocalConfig()

// Mount the instance.
_, err = pool.MountInstance(inst, nil)
if err != nil {
Expand Down
Loading