Skip to content

fix(pods): resolve default container for multi-container pods (KEP-2227)#1060

Merged
manusa merged 1 commit into
containers:mainfrom
matzew:fix/1000-default-container-annotation
Apr 16, 2026
Merged

fix(pods): resolve default container for multi-container pods (KEP-2227)#1060
manusa merged 1 commit into
containers:mainfrom
matzew:fix/1000-default-container-annotation

Conversation

@matzew

@matzew matzew commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

pods_log fails on multi-container pods when no container parameter is provided because it passes an empty string to the Kubernetes API. pods_exec had a partial fix (falling back to the first container) but did not honor the kubectl.kubernetes.io/default-container annotation.

Add a resolveContainer helper implementing the KEP-2227 resolution order:

  • explicit param → single container → annotation → first container.

Both PodsLog and PodsExec now use this shared logic.

Fixes #1000

pods_log fails on multi-container pods when no container parameter is
provided because it passes an empty string to the Kubernetes API.
pods_exec had a partial fix (falling back to the first container) but
did not honor the kubectl.kubernetes.io/default-container annotation.

Add a resolveContainer helper implementing the KEP-2227 resolution
order: explicit param → single container → annotation → first container.
Both PodsLog and PodsExec now use this shared logic.

Fixes containers#1000

Signed-off-by: Matthias Wessendorf <mwessend@redhat.com>
@matzew
matzew requested a review from manusa April 16, 2026 08:25
@manusa manusa added this to the 0.1.0 milestone Apr 16, 2026

@manusa manusa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thx!

@manusa
manusa merged commit d2068da into containers:main Apr 16, 2026
19 of 20 checks passed
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.

pods_log: support kubectl.kubernetes.io/default-container annotation for multi-container pods

2 participants