pull/10893/merge
Marcos Lorenzo 6 months ago committed by GitHub
commit ca2637fbe7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -504,10 +504,28 @@ func rdelete(c *Client, resources ResourceList, propagation metav1.DeletionPropa
mtx := sync.Mutex{} mtx := sync.Mutex{}
err := perform(resources, func(info *resource.Info) error { err := perform(resources, func(info *resource.Info) error {
c.Log("Starting delete for %q %s", info.Name, info.Mapping.GroupVersionKind.Kind) c.Log("Starting delete for %q %s", info.Name, info.Mapping.GroupVersionKind.Kind)
err := deleteResource(info, propagation) if err2 := info.Get(); err2 != nil {
if err == nil || apierrors.IsNotFound(err) { c.Log("Unable to get obj %q, err2: %s", info.Name, err2)
if err != nil { mtx.Lock()
c.Log("Ignoring delete failure for %q %s: %v", info.Name, info.Mapping.GroupVersionKind, err) defer mtx.Unlock()
// Collect the error and continue on
errs = append(errs, err2)
return nil
}
annotations, err2 := metadataAccessor.Annotations(info.Object)
if err2 != nil {
c.Log("Unable to get annotations on %q, err2: %s", info.Name, err2)
}
if annotations != nil && annotations[ResourcePolicyAnno] == KeepPolicy {
c.Log("Skipping delete of %q due to annotation [%s=%s]", info.Name, ResourcePolicyAnno, KeepPolicy)
mtx.Lock()
defer mtx.Unlock()
return nil
}
err2 = deleteResource(info, propagation)
if err2 == nil || apierrors.IsNotFound(err2) {
if err2 != nil {
c.Log("Ignoring delete failure for %q %s: %v", info.Name, info.Mapping.GroupVersionKind, err2)
} }
mtx.Lock() mtx.Lock()
defer mtx.Unlock() defer mtx.Unlock()
@ -517,7 +535,7 @@ func rdelete(c *Client, resources ResourceList, propagation metav1.DeletionPropa
mtx.Lock() mtx.Lock()
defer mtx.Unlock() defer mtx.Unlock()
// Collect the error and continue on // Collect the error and continue on
errs = append(errs, err) errs = append(errs, err2)
return nil return nil
}) })
if err != nil { if err != nil {

Loading…
Cancel
Save