Skip to content

Use logging library with json support in cmctl (part 1) - #6108

Merged
jetstack-bot merged 2 commits into
cert-manager:masterfrom
inteon:ctl_logging
Jul 27, 2023
Merged

jetstack-bot merged 2 commits into
cert-manager:masterfrom
inteon:ctl_logging

Conversation

@inteon

@inteon inteon commented May 26, 2023 •

Copy link
Copy Markdown
Member

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.

NONE

@jetstack-bot jetstack-bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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 May 26, 2023
@jetstack-bot

Copy link
Copy Markdown
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

Details 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 May 26, 2023
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")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This removes unnecessary traceback info from these errors.

@inteon
inteon force-pushed the ctl_logging branch 2 times, most recently from bbceff9 to 825cac0 Compare May 26, 2023 09:11
@jetstack-bot jetstack-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 30, 2023
@jetstack-bot jetstack-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 30, 2023
@inteon inteon changed the title Use logging library with json support in cmctl Use logging library with json support in cmctl (part 1) May 30, 2023
@jetstack-bot jetstack-bot added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels May 30, 2023
)

var (
ErrCertManagerCRDsNotFound = errors.New("the cert-manager CRDs are not yet installed on the Kubernetes API server")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This removes unnecessary traceback info from these errors because this traceback info renders quite poorly in json logs.

Comment thread pkg/util/cmapichecker/cmapichecker.go Resolved
Co-authored-by: Siggi Skulason <[email protected]>
Signed-off-by: Tim Ramlot <[email protected]>
@inteon
inteon requested a review from maelvls June 15, 2023 15:34
@inteon inteon added this to the 1.13 milestone Jul 4, 2023
Comment thread internal/cmd/util/exit.go
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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

I wish this type of information was documented in the man pages, but we don't have a man page for cmctl...

Comment thread pkg/logs/logs.go
{
var allFlags pflag.FlagSet
logsapi.AddFlags(opts, &allFlags)
func AddFlags(opts *logs.Options, fs *pflag.FlagSet) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We keep AddFlags for backwards compatibility.

const certificatesCertManagerCrdName = "certificates.cert-manager.io"
const certificatesCertManagerOldCrdName = "certificates.certmanager.k8s.io"

var certManagerLabelSelector = map[string]string{

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is not used.

return nil
}

type ApiCheckError struct {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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".

@maelvls

maelvls commented Jul 27, 2023

Copy link
Copy Markdown
Member

Except for the 124 exit code that slightly changes cmctl's behavior (no impact I can forsee), this PR is just cosmetic so no trouble!

/lgtm

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Jul 27, 2023
@jetstack-bot
jetstack-bot merged commit 9de9809 into cert-manager:master Jul 27, 2023
@jetstack-bot

Copy link
Copy Markdown
Contributor

@inteon: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cert-manager-master-e2e-v1-27-upgrade c4c5899 link unknown /test pull-cert-manager-master-e2e-v1-27-upgrade

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.

Details

Instructions 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.

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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. 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.

4 participants