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

Function GetFirstReplica

tests/utils/clusterutils/cluster.go:214–227  ·  view source on GitHub ↗

GetFirstReplica gets the first replica pod from a cluster

(
	ctx context.Context,
	crudClient client.Client,
	namespace, clusterName string,
)

Source from the content-addressed store, hash-verified

212
213// GetFirstReplica gets the first replica pod from a cluster
214func 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

Callers 1

Calls 1

GetReplicasFunction · 0.85

Tested by

no test coverage detected