-
Notifications
You must be signed in to change notification settings - Fork 129
Integrate OCI image metadata into index #1485
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
Changes from 2 commits
d374dde
ecdd2c9
427c050
c8ee98e
7643849
670b82e
b7aa3fb
35be922
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ import ( | |
| "github.com/beam-cloud/beta9/pkg/storage" | ||
| types "github.com/beam-cloud/beta9/pkg/types" | ||
| pb "github.com/beam-cloud/beta9/proto" | ||
| clipCommon "github.com/beam-cloud/clip/pkg/common" | ||
| goproc "github.com/beam-cloud/goproc/pkg" | ||
| "tags.cncf.io/container-device-interface/pkg/cdi" | ||
|
|
||
|
|
@@ -384,14 +385,22 @@ func (s *Worker) readBundleConfig(request *types.ContainerRequest) (*specs.Spec, | |
| // deriveSpecFromSourceImage creates an OCI spec from the source image metadata. | ||
| // This is used for v2 images where we don't have an unpacked bundle with config.json. | ||
| func (s *Worker) deriveSpecFromSourceImage(request *types.ContainerRequest) (*specs.Spec, error) { | ||
| // Determine source image reference and credentials | ||
| // First try to get cached metadata from CLIP archive (v2 images) | ||
| if clipMeta, ok := s.imageClient.GetCLIPImageMetadata(request.ImageId); ok { | ||
| log.Info(). | ||
| Str("image_id", request.ImageId). | ||
| Msg("using cached image metadata from clip archive") | ||
| return s.buildSpecFromCLIPMetadata(clipMeta), nil | ||
| } | ||
|
|
||
| // Fallback: determine source image reference and credentials for runtime lookup | ||
| sourceImageRef, sourceImageCreds := s.getSourceImageInfo(request) | ||
| if sourceImageRef == "" { | ||
| log.Warn().Str("image_id", request.ImageId).Msg("no source image reference, using base spec") | ||
| log.Warn().Str("image_id", request.ImageId).Msg("no source image reference or cached metadata, using base spec") | ||
| return nil, nil | ||
| } | ||
|
|
||
| // Inspect source image with timeout | ||
| // Inspect source image with timeout (fallback for v1 images or when metadata is not cached) | ||
| ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) | ||
| defer cancel() | ||
|
|
||
|
|
@@ -408,9 +417,9 @@ func (s *Worker) deriveSpecFromSourceImage(request *types.ContainerRequest) (*sp | |
| log.Info(). | ||
| Str("image_id", request.ImageId). | ||
| Str("source_image", sourceImageRef). | ||
| Msg("derived spec from source image") | ||
| Msg("derived spec from source image via runtime lookup") | ||
|
|
||
| // Build spec from image metadata | ||
| // Build spec from skopeo metadata (legacy path for v1 images) | ||
| return s.buildSpecFromImageMetadata(&imgMeta), nil | ||
| } | ||
|
|
||
|
|
@@ -433,7 +442,37 @@ func (s *Worker) getSourceImageInfo(request *types.ContainerRequest) (string, st | |
| return "", "" | ||
| } | ||
|
|
||
| // buildSpecFromImageMetadata constructs an OCI spec from image metadata | ||
| // buildSpecFromCLIPMetadata constructs an OCI spec from CLIP image metadata | ||
| // This is the primary path for v2 images with embedded metadata | ||
| func (s *Worker) buildSpecFromCLIPMetadata(clipMeta *clipCommon.ImageMetadata) *specs.Spec { | ||
| spec := specs.Spec{ | ||
| Process: &specs.Process{ | ||
| Env: []string{}, | ||
| }, | ||
| } | ||
|
|
||
| // CLIP metadata has a flat structure with all fields at the top level | ||
| if len(clipMeta.Env) > 0 { | ||
| spec.Process.Env = clipMeta.Env | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GetCLIPImageMetadata hands out the cached metadata pointer, so this assigns the shared Env slice. Prompt for AI agents |
||
| } | ||
| if clipMeta.WorkingDir != "" { | ||
| spec.Process.Cwd = clipMeta.WorkingDir | ||
| } | ||
| if clipMeta.User != "" { | ||
| spec.Process.User.Username = clipMeta.User | ||
| } | ||
| // Combine Entrypoint and Cmd, or use Cmd alone | ||
| if len(clipMeta.Entrypoint) > 0 { | ||
| spec.Process.Args = append(clipMeta.Entrypoint, clipMeta.Cmd...) | ||
luke-lombardi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } else if len(clipMeta.Cmd) > 0 { | ||
| spec.Process.Args = clipMeta.Cmd | ||
| } | ||
|
|
||
| return &spec | ||
| } | ||
|
|
||
| // buildSpecFromImageMetadata constructs an OCI spec from skopeo image metadata | ||
| // This is the legacy path for v1 images or when CLIP metadata is not available | ||
| func (s *Worker) buildSpecFromImageMetadata(imgMeta *common.ImageMetadata) *specs.Spec { | ||
| spec := specs.Spec{ | ||
| Process: &specs.Process{ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.