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

Function ScaleOperatorDeployment

tests/utils/operator/operator.go:242–260  ·  view source on GitHub ↗

ScaleOperatorDeployment will scale the operator to n replicas and return an error in case of failure

(
	ctx context.Context, crudClient client.Client, replicas int32,
)

Source from the content-addressed store, hash-verified

240
241// ScaleOperatorDeployment will scale the operator to n replicas and return an error in case of failure
242func ScaleOperatorDeployment(
243 ctx context.Context, crudClient client.Client, replicas int32,
244) error {
245 operatorDeployment, err := GetDeployment(ctx, crudClient)
246 if err != nil {
247 return err
248 }
249
250 updatedOperatorDeployment := *operatorDeployment.DeepCopy()
251 updatedOperatorDeployment.Spec.Replicas = ptr.To(replicas)
252
253 err = crudClient.Patch(ctx, &updatedOperatorDeployment, client.MergeFrom(&operatorDeployment))
254 if err != nil {
255 return err
256 }
257
258 // Wait for the operator deployment to be ready
259 return WaitForReady(ctx, crudClient, 120, replicas > 0)
260}
261
262// PodRenamed checks if the operator pod was renamed
263func PodRenamed(operatorPod corev1.Pod, expectedOperatorPodName string) bool {

Callers 3

webhook_test.goFile · 0.92

Calls 4

GetDeploymentFunction · 0.85
WaitForReadyFunction · 0.70
DeepCopyMethod · 0.45
PatchMethod · 0.45

Tested by

no test coverage detected