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

'kubectl events' command #99557

Merged
merged 28 commits into from Oct 29, 2021
Merged

Conversation

bboreham
Copy link
Contributor

@bboreham bboreham commented Feb 28, 2021

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds a new verb 'events' to kubectl which addresses various deficiencies with kubectl get events.

Which issue(s) this PR fixes:

kubernetes/enhancements#1440
Fixes: kubernetes/kubectl#704
Fixes: #29838

Special notes for your reviewer:

This is a very minimal version, posted to see if I'm on the right track.
In particular, it does not implement any flexibility on output formats.

Does this PR introduce a user-facing change?

adds new [alpha] command 'kubectl events'

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

[KEP]: https://github.com/kubernetes/enhancements/issues/1440

Video of KubeCon talk "The Soul of a New Command: Adding ‘Events’ to kubectl"

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 28, 2021
@k8s-ci-robot k8s-ci-robot added area/kubectl sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Feb 28, 2021
@bboreham
Copy link
Contributor Author

@soltysh could I ask for some feedback please on the overall approach

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 9, 2021
@eddiezane
Copy link
Member

/cc

Borrowing code from 'kubectl describe'
Print namespace if fetching from all
To make it easier to add watch function next.
Run the list function same as before, so those events come out in order,
then watch from the ResourceVersion after the last event.
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
@bboreham bboreham changed the title WIP: 'kubectl events' command 'kubectl events' command Oct 27, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 27, 2021
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Flags represents the inputs from the CLI; options are what the running
command needs. This structure parallels the 'wait' command, and should
be easier to write tests for.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

One final nit and this is good to go.

@soltysh
Copy link
Contributor

soltysh commented Oct 28, 2021

/triage accepted
/priority backlog

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/backlog Higher priority than priority/awaiting-more-evidence. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Oct 28, 2021
We tried to print the list first then start a watch after the last
event, but sometimes the server will return "watch is too old" on that
ResourceVersion.
Instead, if we need to watch just start it from the beginning.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Also, if watching, don't print the headings until the first event
arrives.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve
/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Oct 29, 2021
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 29, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bboreham, soltysh

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 29, 2021
@k8s-ci-robot k8s-ci-robot merged commit a988182 into kubernetes:master Oct 29, 2021
SIG CLI automation moved this from Needs review to Done Oct 29, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Oct 29, 2021
@bboreham bboreham deleted the kubectl-events branch December 10, 2021 15:32
@bboreham
Copy link
Contributor Author

Some ideas for further enhancements:

  • a way to get the event object name (-o wide, perhaps)
  • a way to get the absolute time for each line rather than relative time

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/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/backlog Higher priority than priority/awaiting-more-evidence. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
4 participants