Off marks an instance in a cluster as not fenced
( ctx context.Context, crudClient client.Client, serverName, namespace, clusterName string, fencingMethod Method, )
| 74 | |
| 75 | // Off marks an instance in a cluster as not fenced |
| 76 | func Off( |
| 77 | ctx context.Context, |
| 78 | crudClient client.Client, |
| 79 | serverName, |
| 80 | namespace, |
| 81 | clusterName string, |
| 82 | fencingMethod Method, |
| 83 | ) error { |
| 84 | switch fencingMethod { |
| 85 | case UsingPlugin: |
| 86 | _, _, err := run.Run(fmt.Sprintf("kubectl cnpg fencing off %v %v -n %v", |
| 87 | clusterName, serverName, namespace)) |
| 88 | if err != nil { |
| 89 | return err |
| 90 | } |
| 91 | case UsingAnnotation: |
| 92 | err := utils.NewFencingMetadataExecutor(crudClient). |
| 93 | RemoveFencing(). |
| 94 | ForInstance(serverName). |
| 95 | Execute(ctx, types.NamespacedName{Name: clusterName, Namespace: namespace}, &apiv1.Cluster{}) |
| 96 | if err != nil { |
| 97 | return err |
| 98 | } |
| 99 | default: |
| 100 | return fmt.Errorf("unrecognized fencing Method: %s", fencingMethod) |
| 101 | } |
| 102 | return nil |
| 103 | } |
no test coverage detected