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

Function GetPodsNotOnPrimaryNode

internal/controller/replicas.go:395–412  ·  view source on GitHub ↗

GetPodsNotOnPrimaryNode filters out only pods that are not on the same node as the primary one

(
	status postgres.PostgresqlStatusList,
	primaryPod *postgres.PostgresqlStatus,
)

Source from the content-addressed store, hash-verified

393
394// GetPodsNotOnPrimaryNode filters out only pods that are not on the same node as the primary one
395func GetPodsNotOnPrimaryNode(
396 status postgres.PostgresqlStatusList,
397 primaryPod *postgres.PostgresqlStatus,
398) postgres.PostgresqlStatusList {
399 podsOnOtherNodes := postgres.PostgresqlStatusList{
400 IsReplicaCluster: status.IsReplicaCluster,
401 CurrentPrimary: status.CurrentPrimary,
402 }
403 if primaryPod == nil {
404 return podsOnOtherNodes
405 }
406 for _, candidate := range status.Items {
407 if candidate.Pod.Name != primaryPod.Pod.Name && candidate.Node != primaryPod.Node {
408 podsOnOtherNodes.Items = append(podsOnOtherNodes.Items, candidate)
409 }
410 }
411 return podsOnOtherNodes
412}
413
414// If the cluster is not in the online upgrading phase, enforceFailoverDelay will evaluate the failover delay specified
415// in the cluster's specification.

Callers 2

replicas_test.goFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected