8000 Ctl commmand status certificate: Add events output by hzhou97 · Pull Request #3102 · cert-manager/cert-manager · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Ctl commmand status certificate: Add events output #3102

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

Merged
merged 6 commits into from
Jul 23, 2020

Conversation

hzhou97
Copy link
Contributor
@hzhou97 hzhou97 commented Jul 16, 2020

What this PR does / why we need it:
This PR adds the Events of the Certificate and of the CertificateRequest to the output of the ctl command status certificate

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

  1. I added a implementation of the PrefixWriter interface that is defined in the describe package of kubectl in order to reuse the existing function DescribeEvents(). Not sure if there is a better way? An alternative I considered was to copy DescribeEvents() (along with a few private functions) and modify the copy.
  2. I am not sure where the changes in LICENSES and go.sum come from, but it was automatically generated when I ran ./hack/update-deps.sh.
  3. There is a slight problem in the formatting when printing the Events of the CertificateRequest which is because of how DescribeEvents() is implemented, where they print Events:\nType\tReason and so on. It's not very big of a problem as the rest of the output is still correct. What do you think?
  Events:
  Type  Reason  Age     From    Message
    ----        ------  ----    ----    -------
    Normal      OrderCreated    27s     cert-manager    Created Order resource default/v1alpha3-certificate-pmlc7-1319513028
    Normal      OrderPending    27s     cert-manager    Waiting on certificate issuance from order default/v1alpha3-certificate-pmlc7-1319513028: ""

Release note:

Add Events of the Certificate and of the CertificateRequest to the output of the ctl command `status certificate`

/area ctl
/kind feature

@jetstack-bot jetstack-bot added area/ctl Indicates a PR or issue relates to the cert-manager-ctl CLI component 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. kind/feature Categorizes issue or PR as related to a new feature. labels Jul 16, 2020
@jetstack-bot jetstack-bot requested a review from JoshVanL July 16, 2020 17:24
@jetstack-bot jetstack-bot added area/testing Issues relating to testing size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 16, 2020
@hzhou97 hzhou97 force-pushed the add_events_output branch from e95666a to 8e46021 Compare July 17, 2020 08:17
Copy link
Member
@wallrj wallrj left a comment

Choose a reason for hiding this comment

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

Hey @hzhou97

I compiled and tested ctl. Here's the output:

bazel-out/k8-fastbuild-ST-3bfd66f45e612c1a5c797474a25664e227d81bf914f3b08a40e00b2e2692afa4/bin/cmd/ctl/kubectl-cert_manager  status certificate --namespace cert-manager-test selfsigned-cert
Name: selfsigned-cert
Namespace: cert-manager-test
Conditions:
  Ready: True, Reason: Ready, Message: Certificate is up to date and has not expired
DNS Names:
- example.com
Events:
  Type	Reason	Age	From	Message
  ----	------	----	----	-------
  Normal	Issuing	2m26s	cert-manager	Issuing certificate as Secret does not exist
  Normal	Generated	2m26s	cert-manager	Stored new private key in temporary Secret resource "selfsigned-cert-kbhzm"
  Normal	Requested	2m26s	cert-manager	Created new CertificateRequest resource "selfsigned-cert-h94ds"
  Normal	Issuing	2m26s	cert-manager	The certificate has been successfully issued
Issuer:
  Name: test-selfsigned
  Kind: 
Secret Name: selfsigned-cert-tls
Not Before: 2020-07-17T11:17:27+01:00
Not After: 2020-10-15T11:17:27+01:00
Renewal Time: 2020-09-15T11:17:27+01:00
No CertificateRequest found for this Certificate richard   add_events_output  ~  projects  cert-manager  cert-manager  

Some problems I noticed:

  • Missing newline at at the end of the output
  • The Event reasons don't line up with the column heading
  • Issuer > Kind: line has no value.
  • There is a certificaterequest for this certificate, but I guess it's been filtered out by the next revision check (discussed in an earlier PR)....I think we should show all existing CRs for a cert but order them, most recent first, and somehow mark the ones which are in-progress vs CRs which are complete.
  • I think it'd be nice to show more information about the secret content...i.e. some summary information about the key and about the certificate that has actually been issued.
  • I also think it'd be useful to show the time when the Certificate was created and when it was last updated.
  • I think I'd like to see none-normal events associated with the Issuer, if the certificate / cr is in a failed state.

Just some suggestions, mostly for future PRs. But please fix the formatting of the events and the missing newline before merging this.

hzhou97 added 4 commits July 22, 2020 09:45
Signed-off-by: Haoxiang Zhou <haoxiang.zhou@jetstack.io>
…f kubectl

Signed-off-by: Haoxiang Zhou <haoxiang.zhou@jetstack.io>
Signed-off-by: Haoxiang Zhou <haoxiang.zhou@jetstack.io>
Signed-off-by: Haoxiang Zhou <haoxiang.zhou@jetstack.io>
@hzhou97 hzhou97 force-pushed the add_events_output branch from 8e46021 to 38f50ca Compare July 22, 2020 11:17
@hzhou97 hzhou97 requested a review from wallrj July 22, 2020 11:17
Signed-off-by: Haoxiang Zhou <haoxiang.zhou@jetstack.io>
@hzhou97 hzhou97 force-pushed the add_events_output branch from 38f50ca to 8525a26 Compare July 22, 2020 11:31
Copy link
Member
@wallrj wallrj left a comment

Choose a reason for hiding this comment

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

Hey @hzhou97

I compiled and tested the updated code and it works nicely, but I wondered if describe.NewNestedPrefixWriter might avoid having to add the prefix writer and event describing code to our repo.

// This implementation is based on the one in the describe package, with a slight modification of having a baseLevel
// on top of which any other indentations are added.
// The purpose is be able to reuse functions in the describe package where the Level of the output is fixed,
// e.g. DescribeEvents() only prints out at Level 0.
Copy link
Member

Choose a reason for hiding this comment

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

Did you try nestedPrefixWriter ? It looks like it should allow you to write the events table, indented: https://github.com/kubernetes/kubernetes/blob/0b678bbb51a83e47df912f1205907418e354b281/staging/src/k8s.io/kubectl/pkg/describe/describe.go#L159

If not, then add a note to the top of this file explaining that parts of this code have been copied from a particular revision of Kubernetes and link to the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm. nestedPrefixWriter does not show up in the code I'm reading..
We still need the copied and slightly modified DescribeEvents because on this line they print the column headers by using \n and two spaces and not with Prefixing, that means that the column headers are slightly misformatted if we use the originial DescribeEvents to print Events for the CR.
I did remove the implementation of the PrefixWriter as it's not needed anymore.

Signed-off-by: Haoxiang Zhou <haoxiang.zhou@jetstack.io>
@hzhou97 hzhou97 requested a review from wallrj July 23, 2020 09:11
Copy link
Member
@wallrj wallrj left a comment

Choose a reason for hiding this comment

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

/lgtm

$ bazel-out/k8-fastbuild-ST-3bfd66f45e612c1a5c797474a25664e227d81bf914f3b08a40e00b2e2692afa4/bin/cmd/ctl/kubectl-cert_manager status certificate -n cert-manager-test selfsigned-cert
Name: selfsigned-cert
Namespace: cert-manager-test
Conditions:
  Ready: True, Reason: Ready, Message: Certificate is up to date and has not expired
DNS Names:
- example.com
Events:  <none>
Issuer:
  Name: test-selfsigned
  Kind: Issuer
Secret Name: selfsigned-cert-tls
Not Before: 2020-07-22T15:24:28+01:00
Not After: 2020-10-20T15:24:28+01:00
Renewal Time: 2020-09-20T15:24:28+01:00
No CertificateRequest found for this Certificate

$ bazel-out/k8-fastbuild-ST-3bfd66f45e612c1a5c797474a25664e227d81bf914f3b08a40e00b2e2692afa4/bin/cmd/ctl/kubectl-cert_manager renew -n cert-manager-test selfsigned-cert
Manually triggered issuance of Certificate cert-manager-test/selfsigned-cert

$ bazel-out/k8-fastbuild-ST-3bfd66f45e612c1a5c797474a25664e227d81bf914f3b08a40e00b2e2692afa4/bin/cmd/ctl/kubectl-cert_manager status certificate -n cert-manager-test selfsigned-cert
Name: selfsigned-cert
Namespace: cert-manager-test
Conditions:
  Ready: True, Reason: Ready, Message: Certificate is up to date and has not expired
DNS Names:
- example.com
Events:
  Type    Reason     Age               From          Message
  ----    ------     ----              ----          -------
  Normal  Issuing    3s (x2 over 21h)  cert-manager  The certificate has been successfully issued
  Normal  Reused     3s                cert-manager  Reusing private key stored in existing Secret resource "selfsigned-cert-tls"
  Normal  Requested  3s                cert-manager  Created new CertificateRequest resource "selfsigned-cert-z92xb"
Issuer:
  Name: test-selfsigned
  Kind: Issuer
Secret Name: selfsigned-cert-tls
Not Before: 2020-07-23T13:12:35+01:00
Not After: 2020-10-21T13:12:35+01:00
Renewal Time: 2020-09-21T13:12:35+01:00
No CertificateRequest found for this Certificate

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Jul 23, 2020
@hzhou97
Copy link
Contributor Author
hzhou97 commented Jul 23, 2020

Hmm why did it not find the CR?

@meyskens
Copy link
Contributor

/approve

@jetstack-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzhou97, meyskens, wallrj

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 Jul 23, 2020
@jetstack-bot jetstack-bot merged commit b14a7f2 into cert-manager:master Jul 23, 2020
@jetstack-bot jetstack-bot added this to the v0.16 milestone Jul 23, 2020
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. area/ctl Indicates a PR or issue relates to the cert-manager-ctl CLI component area/testing Issues relating to testing dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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
0