(ctx context.Context, instanceName, clusterName string)
| 116 | } |
| 117 | |
| 118 | func ensurePodIsDeleted(ctx context.Context, instanceName, clusterName string) error { |
| 119 | // Check if the Pod exist |
| 120 | var pod corev1.Pod |
| 121 | err := plugin.Client.Get(ctx, client.ObjectKey{ |
| 122 | Namespace: plugin.Namespace, |
| 123 | Name: instanceName, |
| 124 | }, &pod) |
| 125 | if apierrs.IsNotFound(err) { |
| 126 | // The Pod doesn't exist, so we already did our job |
| 127 | return nil |
| 128 | } |
| 129 | if err != nil { |
| 130 | return err |
| 131 | } |
| 132 | |
| 133 | if _, isOwned := controller.IsOwnedByCluster(&pod); !isOwned { |
| 134 | return fmt.Errorf("instance %s is not owned by cluster %s", pod.Name, clusterName) |
| 135 | } |
| 136 | |
| 137 | return plugin.Client.Delete(ctx, &pod) |
| 138 | } |
| 139 | |
| 140 | // removeOwnerReference removes the owner reference to the cluster |
| 141 | func removeOwnerReference(references []metav1.OwnerReference, clusterName string) []metav1.OwnerReference { |
no test coverage detected