ScaleOperatorDeployment will scale the operator to n replicas and return an error in case of failure
( ctx context.Context, crudClient client.Client, replicas int32, )
| 240 | |
| 241 | // ScaleOperatorDeployment will scale the operator to n replicas and return an error in case of failure |
| 242 | func 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 |
| 263 | func PodRenamed(operatorPod corev1.Pod, expectedOperatorPodName string) bool { |
no test coverage detected