removeFencedInstance removes the given server name from the FencedInstanceAnnotation annotation returns an error if the instance was already unfenced
(instanceName string, object metav1.Object)
| 114 | // removeFencedInstance removes the given server name from the FencedInstanceAnnotation annotation |
| 115 | // returns an error if the instance was already unfenced |
| 116 | func 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 |
no test coverage detected