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

Function IsNodeReachable

tests/utils/nodes/nodes.go:139–163  ·  view source on GitHub ↗

IsNodeReachable checks if a node is: 1. Ready 2. Not tainted with the unreachable taint

(
	ctx context.Context,
	crudClient client.Client,
	nodeName string,
)

Source from the content-addressed store, hash-verified

137// 1. Ready
138// 2. Not tainted with the unreachable taint
139func IsNodeReachable(
140 ctx context.Context,
141 crudClient client.Client,
142 nodeName string,
143) (bool, error) {
144 node := &corev1.Node{}
145 err := crudClient.Get(ctx, client.ObjectKey{Name: nodeName}, node)
146 if err != nil {
147 return false, err
148 }
149 for _, condition := range node.Status.Conditions {
150 if condition.Type == corev1.NodeReady && condition.Status == corev1.ConditionFalse {
151 return false, nil
152 }
153 }
154
155 // check that the node does not have the unreachable taint
156 for _, taint := range node.Spec.Taints {
157 if taint.Key == corev1.TaintNodeUnreachable {
158 return false, nil
159 }
160 }
161
162 return true, nil
163}

Callers 1

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected