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

Function On

tests/utils/fencing/fencing.go:46–73  ·  view source on GitHub ↗

On marks an instance in a cluster as fenced

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

Source from the content-addressed store, hash-verified

44
45// On marks an instance in a cluster as fenced
46func On(
47 ctx context.Context,
48 crudClient client.Client,
49 serverName,
50 namespace,
51 clusterName string,
52 fencingMethod Method,
53) error {
54 switch fencingMethod {
55 case UsingPlugin:
56 _, _, err := run.Run(fmt.Sprintf("kubectl cnpg fencing on %v %v -n %v",
57 clusterName, serverName, namespace))
58 if err != nil {
59 return err
60 }
61 case UsingAnnotation:
62 err := utils.NewFencingMetadataExecutor(crudClient).
63 AddFencing().
64 ForInstance(serverName).
65 Execute(ctx, types.NamespacedName{Name: clusterName, Namespace: namespace}, &apiv1.Cluster{})
66 if err != nil {
67 return err
68 }
69 default:
70 return fmt.Errorf("unrecognized fencing Method: %s", fencingMethod)
71 }
72 return nil
73}
74
75// Off marks an instance in a cluster as not fenced
76func Off(

Callers 3

fencing_test.goFile · 0.92

Calls 5

RunFunction · 0.92
ExecuteMethod · 0.80
ForInstanceMethod · 0.80
AddFencingMethod · 0.80

Tested by

no test coverage detected