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

Function removeFencedInstance

pkg/utils/fencing.go:116–138  ·  view source on GitHub ↗

removeFencedInstance removes the given server name from the FencedInstanceAnnotation annotation returns an error if the instance was already unfenced

(instanceName string, object metav1.Object)

Source from the content-addressed store, hash-verified

114// removeFencedInstance removes the given server name from the FencedInstanceAnnotation annotation
115// returns an error if the instance was already unfenced
116func removeFencedInstance(instanceName string, object metav1.Object) (bool, error) {
117 fencedInstances, err := GetFencedInstances(object.GetAnnotations())
118 if err != nil {
119 return false, err
120 }
121 if fencedInstances.Len() == 0 {
122 return false, nil
123 }
124 if instanceName == FenceAllInstances {
125 return true, setFencedInstances(object, stringset.New())
126 }
127
128 if fencedInstances.Has(FenceAllInstances) {
129 return false, ErrorSingleInstanceUnfencing
130 }
131
132 if !fencedInstances.Has(instanceName) {
133 return false, nil
134 }
135
136 fencedInstances.Delete(instanceName)
137 return true, setFencedInstances(object, fencedInstances)
138}
139
140// FencingMetadataExecutor executes the logic regarding adding and removing the fencing annotation for a kubernetes
141// object

Callers 1

fencing_test.goFile · 0.85

Calls 5

GetFencedInstancesFunction · 0.85
setFencedInstancesFunction · 0.85
HasMethod · 0.80
LenMethod · 0.45
DeleteMethod · 0.45

Tested by

no test coverage detected