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

Add support for waiting by label selector or on all resources #71746

Merged
merged 1 commit into from Feb 4, 2019

Conversation

@rctl
Copy link
Contributor

rctl commented Dec 5, 2018

What type of PR is this?
/kind feature

What this PR does / why we need it:

Will add support for kubectl wait to await resources by label selector, field selector or await all resources of a specific type.

Which issue(s) this PR fixes:

Fixes #68298

Special notes for your reviewer:

Testplan

test.yaml:

apiVersion: v1
kind: Namespace
metadata:
  name: test
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: test
  namespace: test
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: test
    spec:
      containers:
      - name: echo
        image: busybox:latest
        command:
        - sleep
        - "3600"
$ kubectl apply -f test.yaml
namespace/test created
deployment.extensions/test created

$ kubectl get pods -n test
NAME                    READY     STATUS    RESTARTS   AGE
test-74588866c5-69ldt   1/1       Running   0          9s
test-74588866c5-s4sms   1/1       Running   0          9s

# wait for resource by type and name

# async
$ _output/bin/kubectl wait --for=delete pod test-74588866c5-69ldt --timeout=120s -n test
pod/test-74588866c5-69ldt condition met

$ kubectl delete pod test-74588866c5-69ldt -n test
pod "test-74588866c5-69ldt" deleted

# wait for all resources

# async
$ _output/bin/kubectl wait --for=delete pod --all --timeout=120s -n test
pod/test-74588866c5-qdx8n condition met
pod/test-74588866c5-s4sms condition met

$ kubectl delete pod --all -n test
pod "test-74588866c5-qdx8n" deleted
pod "test-74588866c5-s4sms" deleted

# wait by label selector

# async
$ _output/bin/kubectl wait --for delete pod -l app=test --timeout=120s -n test
pod/test-74588866c5-62z92 condition met
pod/test-74588866c5-j6m4c condition met

$ kubectl delete pod -l app=test -n test
pod "test-74588866c5-62z92" deleted
pod "test-74588866c5-j6m4c" deleted

# wait by file

# async
$ _output/bin/kubectl wait --for delete -f test.yaml --timeout=120s -n test
namespace/test condition met

$ kubectl delete -f test.yaml
namespace "test" deleted
deployment "test" deleted

Does this PR introduce a user-facing change?:

Expand kubectl wait to work with more types of selectors.
@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Dec 5, 2018

Hi @rctl. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@rctl

This comment has been minimized.

Copy link
Contributor Author

rctl commented Dec 5, 2018

@code-sleuth

This comment has been minimized.

Copy link
Member

code-sleuth commented Dec 5, 2018

/ok-to-test
/sig cli

@rctl

This comment has been minimized.

Copy link
Contributor Author

rctl commented Dec 5, 2018

/test pull-kubernetes-e2e-kops-aws

@juanvallejo

This comment has been minimized.

Copy link
Member

juanvallejo commented Dec 5, 2018

/retest

@juanvallejo

This comment has been minimized.

Copy link
Member

juanvallejo commented Dec 5, 2018

Mind adding a test as well?

@rctl

This comment has been minimized.

Copy link
Contributor Author

rctl commented Dec 5, 2018

@juanvallejo Absolutely, I will add some test-cases :)

@rctl rctl force-pushed the rctl:rctl-wait-all branch from 2bba32c to 93446f1 Dec 10, 2018

@k8s-ci-robot k8s-ci-robot added size/M and removed size/S labels Dec 10, 2018

@rctl

This comment has been minimized.

Copy link
Contributor Author

rctl commented Dec 10, 2018

@juanvallejo I've added test-case for awaiting multiple resources when selectors match multiple resources, this should cover the expansion to allow wait to accept multiple resources to wait for.

@rctl

This comment has been minimized.

Copy link
Contributor Author

rctl commented Dec 13, 2018

/retest

@rctl

This comment has been minimized.

Copy link
Contributor Author

rctl commented Dec 14, 2018

/cc @seans3

@k8s-ci-robot k8s-ci-robot requested a review from seans3 Dec 14, 2018

@juanvallejo

This comment has been minimized.

Copy link
Member

juanvallejo commented Dec 17, 2018

/lgtm

@rctl rctl force-pushed the rctl:rctl-wait-all branch from 730deb8 to 18d05e5 Feb 2, 2019

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Feb 2, 2019

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rctl, 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 approved and removed cncf-cla: yes labels Feb 2, 2019

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Feb 2, 2019

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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.

@rctl

This comment has been minimized.

Copy link
Contributor Author

rctl commented Feb 2, 2019

/remove-area area/apiserver
/remove-area area/kubeadm
/remove-area sig/api-machinery
/remove-area sig/cloud-provider
/remove-area sig/cluster-lifecycle
/remove-area sig/contributor-experience
/remove-area sig/gcp
/remove-area sig/instrumentation
/remove-area sig/release
/remove-area sig/scheduling

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Feb 2, 2019

@rctl: Those labels are not set on the issue: area/area/apiserver, area/, area/area/kubeadm, area/, area/, area/sig/api-machinery, area/, area/, area/sig/cloud-provider, area/, area/sig/cluster-lifecycle, area/, area/, area/sig/contributor-experience, area/, area/, area/sig/gcp, area/, area/, area/sig/instrumentation, area/, area/, area/sig/release, area/, area/, area/sig/scheduling

In response to this:

/remove-area area/apiserver
/remove-area area/kubeadm
/remove-area sig/api-machinery
/remove-area sig/cloud-provider
/remove-area sig/cluster-lifecycle
/remove-area sig/contributor-experience
/remove-area sig/gcp
/remove-area sig/instrumentation
/remove-area sig/release
/remove-area sig/scheduling

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.

@rctl

This comment has been minimized.

Copy link
Contributor Author

rctl commented Feb 2, 2019

/remove-area apiserver
/remove-area kubeadm
/remove-sig api-machinery
/remove-sig cloud-provider
/remove-sig cluster-lifecycle
/remove-sig contributor-experience
/remove-sig gcp
/remove-sig instrumentation
/remove-sig release
/remove-sig scheduling

Add support for waiting by label selector or on all resources
Add test for multiple deletions in kubectl watch

@rctl rctl force-pushed the rctl:rctl-wait-all branch from 18d05e5 to 4c31e98 Feb 2, 2019

@rctl

This comment has been minimized.

Copy link
Contributor Author

rctl commented Feb 2, 2019

I might have f* up when amending, but we are good now, the test has been repaired. Some dependency of the test had changed, but we are good to land now once we have green light from test-infra :)

@soltysh

soltysh approved these changes Feb 4, 2019

Copy link
Contributor

soltysh left a comment

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm label Feb 4, 2019

@k8s-ci-robot k8s-ci-robot merged commit b4a02c3 into kubernetes:master Feb 4, 2019

16 checks passed

cla/linuxfoundation rctl authorized
Details
pull-kubernetes-bazel-build Job succeeded.
Details
pull-kubernetes-bazel-test Job succeeded.
Details
pull-kubernetes-cross Skipped
pull-kubernetes-e2e-gce Job succeeded.
Details
pull-kubernetes-e2e-gce-100-performance Job succeeded.
Details
pull-kubernetes-e2e-gce-device-plugin-gpu Job succeeded.
Details
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-local-e2e-containerized Skipped
pull-kubernetes-node-e2e Job succeeded.
Details
pull-kubernetes-typecheck Job succeeded.
Details
pull-kubernetes-verify Job succeeded.
Details
tide In merge pool.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment