wait.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. Copyright 2019 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package deployment
  14. import (
  15. "time"
  16. appsv1 "k8s.io/api/apps/v1"
  17. clientset "k8s.io/client-go/kubernetes"
  18. "k8s.io/kubernetes/test/e2e/framework"
  19. testutils "k8s.io/kubernetes/test/utils"
  20. )
  21. const (
  22. // poll is how often to poll pods, nodes and claims.
  23. poll = 2 * time.Second
  24. pollShortTimeout = 1 * time.Minute
  25. pollLongTimeout = 5 * time.Minute
  26. )
  27. // WaitForDeploymentRevisionAndImage waits for the deployment's and its new RS's revision and container image to match the given revision and image.
  28. // Note that deployment revision and its new RS revision should be updated shortly most of the time, but an overwhelmed RS controller
  29. // may result in taking longer to relabel a RS.
  30. func WaitForDeploymentRevisionAndImage(c clientset.Interface, ns, deploymentName string, revision, image string) error {
  31. return testutils.WaitForDeploymentRevisionAndImage(c, ns, deploymentName, revision, image, framework.Logf, poll, pollLongTimeout)
  32. }
  33. // WaitForDeploymentComplete waits for the deployment to complete, and don't check if rolling update strategy is broken.
  34. // Rolling update strategy is used only during a rolling update, and can be violated in other situations,
  35. // such as shortly after a scaling event or the deployment is just created.
  36. func WaitForDeploymentComplete(c clientset.Interface, d *appsv1.Deployment) error {
  37. return testutils.WaitForDeploymentComplete(c, d, framework.Logf, poll, pollLongTimeout)
  38. }