Skip to content

Fix Missing HostConfig field from API response#28714

Open
christopherbii wants to merge 2 commits into
containers:mainfrom
christopherbii:main
Open

Fix Missing HostConfig field from API response#28714
christopherbii wants to merge 2 commits into
containers:mainfrom
christopherbii:main

Conversation

@christopherbii
Copy link
Copy Markdown

No description provided.

@github-actions github-actions Bot added the kind/api-change Change to remote API; merits scrutiny label May 16, 2026
Copy link
Copy Markdown
Member

@Honny1 Honny1 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Can you please add APIv2 tests?

Comment thread pkg/api/handlers/compat/containers.go Outdated
}{
NetworkMode: "host",
// TODO: add annotations here for >= v1.46
NetworkMode: inspect.HostConfig.NetworkMode,
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.

The HostConfig can be nil.

@christopherbii
Copy link
Copy Markdown
Author

@Honny1 I have added the nil check and the test under the already existing compat containers/json test invocation.

I had to run the patches against 5.8.2 for tests to pass, main is currently in a broken state.

Copy link
Copy Markdown
Member

@danishprakash danishprakash left a comment

Choose a reason for hiding this comment

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

CI is failing. Can you run make validatepr?

(This is a nice catch, btw, I wasn't aware of promotion rules for a struct with two embedded fields with the same name)

@christopherbii
Copy link
Copy Markdown
Author

@danishprakash

It was written in the CI logs:

  • ./bin/golangci-lint run --build-tags=apparmor,seccomp,selinux
    pkg/api/handlers/compat/containers.go:468:1: File is not properly formatted (gofumpt)
    ID: l.ID(),

Just pushed the fixed version

Copy link
Copy Markdown
Member

@Honny1 Honny1 left a comment

Choose a reason for hiding this comment

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

LGTM, can you please stash your commits?

- Populate the Docker-compatible container summary HostConfig from the
  container inspect data
- Remove the unused ContainerCreateConfig wrapper from the compat
  handler
- Add APIv2 test

Signed-off-by: Christopher Bii <christopherbii@hyub.org>
- Top process killed with sigkill would not exit with the expected 0
  code

Signed-off-by: Christopher Bii <christopherbii@hyub.org>
@christopherbii
Copy link
Copy Markdown
Author

I am not sure if or how this test has been passing, but the container runs a top process and simply waits for timeout before sending a SIGABRT. This should never exit cleanly.

c1 := "ctr1"
c1s := podmanTest.Podman([]string{"run", "-d", "--expose", "22/tcp", "-p", "8080:80/tcp", "--name", c1, ALPINE, "top"})
c1s.WaitWithDefaultTimeout()
Expect(c1s).Should(ExitCleanly())
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.

Why was this changed? This is not right, the exit status we're checking here is podman run ...'s, not top's inside the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/api-change Change to remote API; merits scrutiny

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants