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

Function ensurePodIsDeleted

internal/cmd/plugin/destroy/destroy.go:118–138  ·  view source on GitHub ↗
(ctx context.Context, instanceName, clusterName string)

Source from the content-addressed store, hash-verified

116}
117
118func 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
141func removeOwnerReference(references []metav1.OwnerReference, clusterName string) []metav1.OwnerReference {

Callers 1

DestroyFunction · 0.85

Calls 3

IsOwnedByClusterFunction · 0.92
GetMethod · 0.45
DeleteMethod · 0.45

Tested by

no test coverage detected