Skip to content
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

test/e2e: fix default signal exit code test #24274

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

Luap99
Copy link
Member

@Luap99 Luap99 commented Oct 15, 2024

By default golang programs exit 2 on special exit signals that can be cought and produce a stack trace. However this is behavior that can be modfied via GOTRACEBACK=crash[1], in that case it does not exit(2) but rather sends itself SIGABRT to the parent sees the signal exit and out test sees that es exit code 134, 128 + 6 (SIGABRT), like most shells do.

As it turns out GOTRACEBACK=crash is the default mode on all fedora and RHEL rpm builds as they patch the build with a special "rpm_crashtraceback" go build tag.

While that change is old and existing for a very long time it was never caught until commit 5e240ab, which switched the old ExitWithError() check that accepted anything > 0, to just accept 2. And as CI only test upstream builds that are build without rpm_crashtraceback we did not catch in CI either. Only once a user actually used distro build against the source e2e test it failed.

I like to highlight that running distro builds against upstream e2e tests is not something we really support or plan to support but given this is a easy fix I decided to just fix it here as any user with GOTRACEBACK=crash set would face the same issue.

While I touch this test remove the unnecessary RestoreArtifact() call which is not needed at all as we do nothing with the image and just slows the test down for now reason.

[1] https://pkg.go.dev/runtime#section-sourcefiles

Fixes #24213

Does this PR introduce a user-facing change?

None

@openshift-ci openshift-ci bot added release-note-none approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 15, 2024
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@@ -112,7 +108,8 @@ var _ = Describe("Podman run with --sig-proxy", func() {
Expect(killSession).Should(ExitCleanly())

session.WaitWithDefaultTimeout()
Expect(session).To(ExitWithError(2, "SIGFPE: floating-point exception"))
errorMsg := "SIGFPE: floating-point exception"
Expect(session).To(Or(ExitWithError(2, errorMsg), ExitWithError(134, errorMsg)))
Copy link
Member Author

Choose a reason for hiding this comment

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

@edsantiago Not sure if you like this like that? It is certainly more duplication that I wanted but the alternative is to switch ExitWithError() to accept a list of exit codes which seems much more complicated.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I see a better alternative, or even any alternative.

Since this is very confusing to a reader, would you mind adding a one-line comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, the alternative is to patch ExitWithError() to accept any as first arg and then use it to pass an int like we do now or an array of int's to allow several exit codes. But this is much more complicated and for a single test overkill.

By default golang programs exit 2 on special exit signals that can be
cought and produce a stack trace. However this is behavior that can be
modfied via GOTRACEBACK=crash[1], in that case it does not exit(2) but
rather sends itself SIGABRT to the parent sees the signal exit and out
test sees that es exit code 134, 128 + 6 (SIGABRT), like most shells do.

As it turns out GOTRACEBACK=crash is the default mode on all fedora and
RHEL rpm builds as they patch the build with a special
"rpm_crashtraceback" go build tag.

While that change is old and existing for a very long time it was never
caught until commit 5e240ab, which switched the old ExitWithError()
check that accepted anything > 0, to just accept 2. And as CI only test
upstream builds that are build without rpm_crashtraceback we did not
catch in CI either. Only once a user actually used distro build against
the source e2e test it failed.

I like to highlight that running distro builds against upstream e2e
tests is not something we really support or plan to support but given
this is a easy fix I decided to just fix it here as any user with
GOTRACEBACK=crash set would face the same issue.

While I touch this test remove the unnecessary RestoreArtifact() call
which is not needed at all as we do nothing with the image and just
slows the test down for now reason.

[1] https://pkg.go.dev/runtime#section-sourcefiles

Fixes containers#24213

Signed-off-by: Paul Holzinger <[email protected]>
Copy link
Member

@edsantiago edsantiago left a comment

Choose a reason for hiding this comment

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

Nice comment, thank you.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 15, 2024
Copy link
Contributor

openshift-ci bot commented Oct 15, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: edsantiago, 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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 1dcb4c5 into containers:main Oct 15, 2024
52 of 54 checks passed
@Luap99 Luap99 deleted the fix-signal-exit branch October 15, 2024 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

e2e: ExitWithError() will determine an incorrect exit code and result in an error.
2 participants