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

BUGFIX: return correct error codes and add tests #40

Merged
merged 1 commit into from
Mar 25, 2024

Conversation

inteon
Copy link
Member

@inteon inteon commented Mar 20, 2024

In #33, a bug was introduced in the exit code calculation.
This PR fixes that bug and adds tests that check the error code.

@jetstack-bot jetstack-bot added dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 20, 2024
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
@inteon
Copy link
Member Author

inteon commented Mar 23, 2024

/approve

@jetstack-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: inteon

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

@jetstack-bot jetstack-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 23, 2024
@maelvls maelvls self-requested a review March 25, 2024 10:43
@maelvls
Copy link
Member

maelvls commented Mar 25, 2024

For anyone wondering, here is the context:

This bug was revealed while publishing cmctl to Homebrew: a test assertion was changed from 1 to 129, which led to led to a discussion in person (see the assertion change here).

If you install 2.0.0, you will see that cmctl unexpectedly returns the exit code 129 instead of 1 for most errors. For example:

$ cmctl status certificate --kubeconfig=nonexistant; echo $?
error: stat nonexistant: no such file or directory
129
$ cmctl check api; echo $?
error: error finding the scope of the object: failed to get restmapping: failed to get server groups: Get "https://127.0.0.1:58484/api": dial tcp 127.0.0.1:58484: connect: connection refused
129

Before 2.0.0, cmctl used to return 1 on normal errors, and would exit 128 + signal number when cmctl was terminated mid-flight due to a signal.

I don't think this bug will have affected anyone. The only case where checking whether the exit code is 1 or 130 (due to a SIGINT caused by ctrl+C) or 143 (SIGTERM) would make sense would be when cmctl is run for a long time, which is only true for cmctl check api.

/lgtm

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 25, 2024
@jetstack-bot jetstack-bot merged commit b99f57b into cert-manager:main Mar 25, 2024
5 checks passed
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. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants