-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Set correct exitcode in remove events #20609
Set correct exitcode in remove events #20609
Conversation
libpod/events.go
Outdated
@@ -77,6 +77,11 @@ func (c *Container) newContainerEventWithInspectData(status events.Status, inspe | |||
e.HealthStatus = containerHealthStatus | |||
} | |||
|
|||
if status == events.Remove { | |||
exitCode, _ := c.runtime.state.GetContainerExitCode(c.ID()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Luap99 what kind of check should be added here to check for error from GetContainerExitCode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is fine to ignore the error here but IMO we should not display the ContainerExitCode
in the events when there is no exit code. However because 0
is a valid exit code we cannot use it with the current omitempty json logic.
While this is a pre-existing problem I think we should fix it. Having -1
for no exit code might be fine but I don't particular like this either. IMO it would make much more sense to change ContainerExitCode
to *int
then we have a proper nil
value for no exit code which also means the omitempty json will correctly write it for 0
and only exclude it for nil
.
This ensures it will not show up the the events output and thus not change the behaviour because "ContainerExitCode":-1
looks odd.
Cockpit tests failed for commit 8ce566d25d59ab31899febaa3a661c4b8c2056d2. @martinpitt, @jelly, @mvollmer please check. |
8ce566d
to
8fd4e40
Compare
Ephemeral COPR build failed. @containers/packit-build please check. |
Cockpit tests failed for commit 70e7804fc140834ff543f1717604bf83ff0c32b4. @martinpitt, @jelly, @mvollmer please check. |
pkg/domain/infra/abi/containers.go
Outdated
@@ -1188,13 +1188,15 @@ func (ic *ContainerEngine) ContainerRun(ctx context.Context, opts entities.Conta | |||
return &report, nil | |||
} | |||
|
|||
func (ic *ContainerEngine) GetContainerExitCode(ctx context.Context, ctr *libpod.Container) int { | |||
func (ic *ContainerEngine) GetContainerExitCode(ctx context.Context, ctr *libpod.Container) *int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this function changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing that as I mistook it for the same function as libpod>stage
libpod/events.go
Outdated
intExitCode := int(exitCode) | ||
e.ContainerExitCode = &intExitCode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because we now have a proper nil as default you should only set the if there was no error returned by the call.
70e7804
to
83d27dd
Compare
libpod/service.go
Outdated
@@ -126,7 +126,7 @@ func (c *Container) canStopServiceContainer() (*serviceContainerReport, error) { | |||
if err != nil { | |||
return nil, err | |||
} | |||
if exitCode != 0 { | |||
if exitCode != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would the check suffice @Luap99
Ephemeral COPR build failed. @containers/packit-build please check. |
83d27dd
to
4beb20b
Compare
Cockpit tests failed for commit 83d27dd206d4d374d1ab90d2aafa958f66bf1700. @martinpitt, @jelly, @mvollmer please check. |
Ephemeral COPR build failed. @containers/packit-build please check. |
Cockpit tests failed for commit 83d27dd206d4d374d1ab90d2aafa958f66bf1700. @martinpitt, @jelly, @mvollmer please check. |
Ephemeral COPR build failed. @containers/packit-build please check. |
Cockpit tests failed for commit 4beb20b0ca8b4f36acc0f7c3d1f483b316a805b8. @martinpitt, @jelly, @mvollmer please check. |
@cgiradkar why is this a draft state? |
Some extra code refactoring was done which was not part of original plan, hence, till @Luap99 and I decide on a final strat, will keep in draft PR mode. |
4beb20b
to
ededad0
Compare
Cockpit tests failed for commit ededad013f333ad19300bbfa528cef362d34b35c. @martinpitt, @jelly, @mvollmer please check. |
ededad0
to
2999dfb
Compare
Cockpit tests failed for commit 2999dfb86bebade0d3228af5c4ebcd6137f0095f. @martinpitt, @jelly, @mvollmer please check. |
This still breaks a lot of tests, even most of them. As this is still draft, can you please let me know when it's ready from your side, so that we can start going through the regressions? Thanks! |
sure @martinpitt |
5157d21
to
ced4a4b
Compare
e816526
to
e9d56b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please squash both commits into one here. Code itself LGTM.
32801a9
to
4186e17
Compare
…om int to int ptr Added additional check for event type to be remove and set the correct exitcode. While it was getting difficult to maintain the omitempty notation for Event->ContainerExitCode, changing the type from int to int ptr gives us the ability to check for ContainerExitCode to be not nil and continue operations from there. closes containers#19124 Signed-off-by: Chetan Giradkar <[email protected]>
4186e17
to
572f38c
Compare
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, @containers/podman-maintainers PTAL
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cgiradkar, Luap99 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
Added additional check for event type to be remove and set the correct exitcode by fetching it from runtime state
closes #19124
Does this PR introduce a user-facing change?