Skip to content

fix: respect OCIRuntime field in SpecGenerator#28473

Closed
GiulioSavini wants to merge 1 commit intocontainers:mainfrom
GiulioSavini:fix/specgen-oci-runtime
Closed

fix: respect OCIRuntime field in SpecGenerator#28473
GiulioSavini wants to merge 1 commit intocontainers:mainfrom
GiulioSavini:fix/specgen-oci-runtime

Conversation

@GiulioSavini
Copy link
Copy Markdown

@GiulioSavini GiulioSavini commented Apr 9, 2026

Description

When creating containers via the API with OCIRuntime set in the SpecGenerator, the field was silently ignored. The container always used the default runtime from containers.conf instead of the one specified in the API request.

The issue is in pkg/specgen/generate/container_create.go at line 168: the code only considered the image-platform-based runtime selection (ImagePlatformToRuntime) but never checked s.OCIRuntime.

Changes

The fix gives the user's explicit OCIRuntime choice priority over the automatic image-platform-based selection, and falls back to the existing behavior when not set:

if s.OCIRuntime != "" {
    options = append(options, libpod.WithCtrOCIRuntime(s.OCIRuntime))
} else if imageData != nil {
    // existing image-platform-based logic
}

This is consistent with how the CLI --runtime flag works, which correctly passes the runtime through.

Test plan

  • Create container via API with OCIRuntime set to a non-default runtime
  • Verify the container uses the specified runtime instead of the default
  • Create container via API without OCIRuntime set — verify existing behavior unchanged
  • Verify --runtime CLI flag still works as before

Fixes #28429

@GiulioSavini GiulioSavini force-pushed the fix/specgen-oci-runtime branch from 205eb76 to 455e393 Compare April 9, 2026 09:07
@packit-as-a-service
Copy link
Copy Markdown

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

2 similar comments
@packit-as-a-service
Copy link
Copy Markdown

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

@packit-as-a-service
Copy link
Copy Markdown

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

@GiulioSavini GiulioSavini force-pushed the fix/specgen-oci-runtime branch from 33bd529 to c7ced45 Compare April 9, 2026 09:21
When creating containers via the API with OCIRuntime set in the
SpecGenerator, the field was silently ignored and the default runtime
from containers.conf was used instead. The code only considered the
image-platform-based runtime selection but never checked s.OCIRuntime.

Now the user's explicit OCIRuntime choice takes priority over the
automatic image-platform-based selection, falling back to the existing
behavior when not set.

Includes a regression test that verifies the oci_runtime field is
respected when creating containers via the API.

Fixes containers#28429

Signed-off-by: giulio.savini <giulio.savini@bvtech.com>
@GiulioSavini GiulioSavini force-pushed the fix/specgen-oci-runtime branch from c7ced45 to 1dc18e3 Compare April 9, 2026 09:42
@Luap99
Copy link
Copy Markdown
Member

Luap99 commented Apr 9, 2026

There is already someone working on this in #28454, please do not work on issues that already have open PRs and rather review them if you are interest in that

@Luap99 Luap99 closed this Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OCIRuntime field in SpecGenerator is ignored

2 participants