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

Function fencingOff

internal/cmd/plugin/fence/fence.go:65–92  ·  view source on GitHub ↗

fencingOff marks an instance in a cluster as not fenced

(ctx context.Context, clusterName string, serverName string)

Source from the content-addressed store, hash-verified

63
64// fencingOff marks an instance in a cluster as not fenced
65func fencingOff(ctx context.Context, clusterName string, serverName string) error {
66 var cluster apiv1.Cluster
67 if err := plugin.Client.Get(ctx,
68 types.NamespacedName{Name: clusterName, Namespace: plugin.Namespace},
69 &cluster,
70 ); err != nil {
71 return err
72 }
73
74 if serverName != utils.FenceAllInstances &&
75 !slices.Contains(cluster.Status.InstanceNames, serverName) &&
76 !cluster.IsInstanceFenced(serverName) {
77 return fmt.Errorf("instance %s is not a known instance of cluster %s", serverName, clusterName)
78 }
79
80 err := utils.NewFencingMetadataExecutor(plugin.Client).
81 RemoveFencing().
82 ForInstance(serverName).
83 Execute(ctx,
84 types.NamespacedName{Name: clusterName, Namespace: plugin.Namespace},
85 &apiv1.Cluster{},
86 )
87 if err != nil {
88 return err
89 }
90 fmt.Printf("%s unfenced\n", serverName)
91 return nil
92}

Callers 2

cmd.goFile · 0.85
fence_test.goFile · 0.85

Calls 6

IsInstanceFencedMethod · 0.95
ExecuteMethod · 0.80
ForInstanceMethod · 0.80
RemoveFencingMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected