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

Include event type in `kubectl get -w` output #72416

Merged
merged 2 commits into from Jul 9, 2019

Conversation

@liggitt
Copy link
Member

commented Dec 28, 2018

What type of PR is this?
/kind feature

What this PR does / why we need it:
Allows the type of event (ADDED, MODIFIED, DELETED) to be seen when watching objects with kubectl get -w --output-watch-events

Before:

kubectl get ns -w
NAME              STATUS   AGE
default           Active   9h
kube-node-lease   Active   9h
kube-public       Active   9h
kube-system       Active   9h
ns1   Active   0s
ns1   Terminating   8s
ns1   Terminating   13s
ns1   Terminating   13s

After:

kubectl get ns -w --output-watch-events
EVENT      NAME              STATUS   AGE
ADDED      default           Active   84m
ADDED      kube-node-lease   Active   84m
ADDED      kube-public       Active   84m
ADDED      kube-system       Active   84m
ADDED      ns1               Active   0s
MODIFIED   ns1               Terminating   5s
MODIFIED   ns1               Terminating   10s
DELETED    ns1               Terminating   10s

Which issue(s) this PR fixes:
Fixes kubernetes/kubectl#185

Based on #79530

Does this PR introduce a user-facing change?:

`kubectl get -w` now takes an `--output-watch-events` flag to indicate the event type (ADDED, MODIFIED, DELETED)

/cc @smarterclayton @seans3
/sig cli

@liggitt

This comment has been minimized.

Copy link
Member Author

commented Dec 28, 2018

/retest

Show resolved Hide resolved pkg/printers/humanreadable.go Outdated
Show resolved Hide resolved pkg/printers/humanreadable.go Outdated

@liggitt liggitt force-pushed the liggitt:watch-event-type branch 2 times, most recently from 57b7fcd to 8b0da1e Jan 2, 2019

@liggitt liggitt changed the title Include event type in human readable `kubectl get -w` output WIP - Include event type in human readable `kubectl get -w` output Jan 3, 2019

@liggitt liggitt force-pushed the liggitt:watch-event-type branch from 8b0da1e to f866f3c Jan 3, 2019

@liggitt

This comment has been minimized.

Copy link
Member Author

commented Jan 5, 2019

/retest

@@ -42,6 +43,11 @@ type NamePrinter struct {
// PrintObj is an implementation of ResourcePrinter.PrintObj which decodes the object
// and print "resource/name" pair. If the object is a List, print all items in it.
func (p *NamePrinter) PrintObj(obj runtime.Object, w io.Writer) error {
switch castObj := obj.(type) {
case *metav1.WatchEvent:

This comment has been minimized.

Copy link
@smarterclayton

smarterclayton Feb 19, 2019

Contributor

I wish we'd done a watch event interface. I can take that as a future cleanup.

@liggitt liggitt added this to the v1.15 milestone Mar 7, 2019

@liggitt liggitt removed this from the v1.15 milestone May 29, 2019

@liggitt liggitt changed the title WIP - Include event type in `kubectl get -w` output Include event type in `kubectl get -w` output Jun 24, 2019

@liggitt

This comment has been minimized.

Copy link
Member Author

commented Jun 24, 2019

/priority important-longterm

@liggitt liggitt force-pushed the liggitt:watch-event-type branch from 313ffbd to e3139c4 Jun 28, 2019

@k8s-ci-robot k8s-ci-robot added size/XL and removed size/L labels Jun 28, 2019

@liggitt

This comment has been minimized.

Copy link
Member Author

commented Jun 28, 2019

addressed comments, rebased on #79530

@liggitt liggitt force-pushed the liggitt:watch-event-type branch from e3139c4 to fc6730a Jun 28, 2019

@liggitt liggitt force-pushed the liggitt:watch-event-type branch from fc6730a to 1327346 Jun 28, 2019

@k8s-ci-robot k8s-ci-robot added size/L and removed size/XL labels Jun 28, 2019

@@ -171,6 +173,7 @@ func NewCmdGet(parent string, f cmdutil.Factory, streams genericclioptions.IOStr
cmd.Flags().StringVar(&o.Raw, "raw", o.Raw, "Raw URI to request from the server. Uses the transport specified by the kubeconfig file.")
cmd.Flags().BoolVarP(&o.Watch, "watch", "w", o.Watch, "After listing/getting the requested object, watch for changes. Uninitialized objects are excluded if no object name is provided.")
cmd.Flags().BoolVar(&o.WatchOnly, "watch-only", o.WatchOnly, "Watch for changes to the requested object(s), without listing/getting first.")
cmd.Flags().BoolVar(&o.OutputWatchEvents, "output-watch-events", o.OutputWatchEvents, "Output watch event objects when --watch or --watch-only is used. Existing objects are output as initial ADDED events.")

This comment has been minimized.

Copy link
@smarterclayton

smarterclayton Jul 4, 2019

Contributor

Maybe this should be --watch-events or --include-events (although I could maybe see that being confused with Events). We're not super strict about prefixing flags though.

This comment has been minimized.

Copy link
@liggitt

liggitt Jul 4, 2019

Author Member

I like --output-... as a prefix, and since it's only allowed with --watch (or --watch-only), I thought qualifying it would be clearer

This comment has been minimized.

Copy link
@liggitt

liggitt Jul 4, 2019

Author Member

--include-events sounds like what describe does, separately fetching/printing related events

@smarterclayton

This comment has been minimized.

Copy link
Contributor

commented Jul 9, 2019

/lgtm
/approve

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

commented Jul 9, 2019

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt, smarterclayton

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 merged commit 5625ead into kubernetes:master Jul 9, 2019

23 checks passed

cla/linuxfoundation liggitt authorized
Details
pull-kubernetes-bazel-build Job succeeded.
Details
pull-kubernetes-bazel-test Job succeeded.
Details
pull-kubernetes-conformance-image-test Skipped.
pull-kubernetes-cross Skipped.
pull-kubernetes-dependencies Job succeeded.
Details
pull-kubernetes-e2e-gce Job succeeded.
Details
pull-kubernetes-e2e-gce-100-performance Job succeeded.
Details
pull-kubernetes-e2e-gce-csi-serial Skipped.
pull-kubernetes-e2e-gce-device-plugin-gpu Job succeeded.
Details
pull-kubernetes-e2e-gce-iscsi Skipped.
pull-kubernetes-e2e-gce-iscsi-serial Skipped.
pull-kubernetes-e2e-gce-storage-slow Skipped.
pull-kubernetes-godeps Skipped.
pull-kubernetes-integration Job succeeded.
Details
pull-kubernetes-kubemark-e2e-gce-big Job succeeded.
Details
pull-kubernetes-local-e2e Skipped.
pull-kubernetes-node-e2e Job succeeded.
Details
pull-kubernetes-node-e2e-containerd Job succeeded.
Details
pull-kubernetes-typecheck Job succeeded.
Details
pull-kubernetes-verify Job succeeded.
Details
pull-publishing-bot-validate Skipped.
tide In merge pool.
Details

@liggitt liggitt deleted the liggitt:watch-event-type branch Jul 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.