MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / IsReady

Function IsReady

tests/utils/deployments/deployment.go:34–59  ·  view source on GitHub ↗

IsReady checks if a Deployment is ready

(deployment appsv1.Deployment)

Source from the content-addressed store, hash-verified

32
33// IsReady checks if a Deployment is ready
34func IsReady(deployment appsv1.Deployment) bool {
35 // If the deployment has been scaled down to 0 replicas, we consider it ready
36 if deployment.Status.Replicas == 0 && *deployment.Spec.Replicas == 0 {
37 return true
38 }
39
40 if deployment.Status.ObservedGeneration < deployment.Generation ||
41 deployment.Status.UpdatedReplicas < deployment.Status.Replicas ||
42 deployment.Status.AvailableReplicas < deployment.Status.Replicas ||
43 deployment.Status.ReadyReplicas < deployment.Status.Replicas {
44 return false
45 }
46
47 if deployment.Status.Conditions == nil {
48 return false
49 }
50 for _, condition := range deployment.Status.Conditions {
51 if condition.Type == appsv1.DeploymentAvailable && condition.Status != "True" {
52 return false
53 }
54 if condition.Type == appsv1.DeploymentProgressing && condition.Status != "True" {
55 return false
56 }
57 }
58 return true
59}
60
61// WaitForReady waits for a Deployment to be ready
62func WaitForReady(

Callers 3

isDeploymentReadyFunction · 0.92
WaitForReadyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected