GetFirstReplica gets the first replica pod from a cluster
( ctx context.Context, crudClient client.Client, namespace, clusterName string, )
| 212 | |
| 213 | // GetFirstReplica gets the first replica pod from a cluster |
| 214 | func GetFirstReplica( |
| 215 | ctx context.Context, |
| 216 | crudClient client.Client, |
| 217 | namespace, clusterName string, |
| 218 | ) (*corev1.Pod, error) { |
| 219 | podList, err := GetReplicas(ctx, crudClient, namespace, clusterName) |
| 220 | if err != nil { |
| 221 | return nil, err |
| 222 | } |
| 223 | if len(podList.Items) == 0 { |
| 224 | return nil, fmt.Errorf("no replicas found") |
| 225 | } |
| 226 | return &podList.Items[0], nil |
| 227 | } |
| 228 | |
| 229 | // AddTopologySpreadConstraint appends a soft topology spread constraint |
| 230 | // that distributes all CNPG-managed pods (instances and jobs) across |
no test coverage detected