Repository navigation
Use logging library with json support in cmctl (part 1) - #6108
Conversation
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
| ErrCertManagerCRDsNotFound = errors.New("the cert-manager CRDs are not yet installed on the Kubernetes API server") | ||
| ErrVersionNotDetected = errors.New("could not detect the cert-manager version") | ||
| ErrMultipleVersionsDetected = errors.New("detect multiple different cert-manager versions") | ||
| ErrCertManagerCRDsNotFound = fmt.Errorf("the cert-manager CRDs are not yet installed on the Kubernetes API server") |
There was a problem hiding this comment.
This removes unnecessary traceback info from these errors.
bbceff9 to
825cac0
Compare
Signed-off-by: Tim Ramlot <[email protected]>
| ) | ||
|
|
||
| var ( | ||
| ErrCertManagerCRDsNotFound = errors.New("the cert-manager CRDs are not yet installed on the Kubernetes API server") |
There was a problem hiding this comment.
This removes unnecessary traceback info from these errors because this traceback info renders quite poorly in json logs.
Co-authored-by: Siggi Skulason <[email protected]> Signed-off-by: Tim Ramlot <[email protected]>
| func SetExitCode(err error) { | ||
| if (err != nil) && !errors.Is(err, context.Canceled) { | ||
| if (err != nil) && errors.Is(err, context.DeadlineExceeded) { | ||
| errorExitCodeChannel <- 124 // Indicate that there was a timeout error |
There was a problem hiding this comment.
If err is a DeadlineExceeded, we want to set the exit code to 124 instead of 1.
This will be used here: https://github.com/cert-manager/cert-manager/pull/6119/files#diff-cfd76d5765e1105fc331f3c440d29ad4a9939557e16706b887785d24c13626e6R138
There was a problem hiding this comment.
I wish this type of information was documented in the man pages, but we don't have a man page for cmctl...
| { | ||
| var allFlags pflag.FlagSet | ||
| logsapi.AddFlags(opts, &allFlags) | ||
| func AddFlags(opts *logs.Options, fs *pflag.FlagSet) { |
There was a problem hiding this comment.
We keep AddFlags for backwards compatibility.
| const certificatesCertManagerCrdName = "certificates.cert-manager.io" | ||
| const certificatesCertManagerOldCrdName = "certificates.certmanager.k8s.io" | ||
|
|
||
| var certManagerLabelSelector = map[string]string{ |
| return nil | ||
| } | ||
|
|
||
| type ApiCheckError struct { |
There was a problem hiding this comment.
Instead of returning an error with a "SimpleError" and an "UnderlyingError", we now only return the "UnderlyingError" and provide TranslateToSimpleError to obtain the "SimpleError" from this "UnderlyingError".
|
Except for the 124 exit code that slightly changes /lgtm |
|
@inteon: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Pull Request Motivation
Continuation of what we started in #5828.
Changes cmctl to use the logging library used in all our other components.
NOTE: I had to split this PR into 3 parts: part 1, part 2 and part 3 because cmctl uses a pinned cert-manager version. This PR contains all the changes to cert-manager/cert-manager.
Kind
/kind cleanup
Release Note
I added the release note in #6119.