Support delete ophranworks can continue the remove operation when an exception occurs, and finally return all deleted exceptions
Signed-off-by: wawa0210 <xiaozhang0210@hotmail.com>
This commit is contained in:
parent
d3a5660abe
commit
2d332b7556
|
@ -141,13 +141,18 @@ func FindOrphanWorks(c client.Client, bindingNamespace, bindingName string, clus
|
|||
|
||||
// RemoveOrphanWorks will remove orphan works.
|
||||
func RemoveOrphanWorks(c client.Client, works []workv1alpha1.Work) error {
|
||||
var errs []error
|
||||
for workIndex, work := range works {
|
||||
err := c.Delete(context.TODO(), &works[workIndex])
|
||||
if err != nil {
|
||||
return err
|
||||
klog.Errorf("Failed to delete orphan work %s/%s, err is %v", work.GetNamespace(), work.GetName(), err)
|
||||
errs = append(errs, err)
|
||||
}
|
||||
klog.Infof("Delete orphan work %s/%s successfully.", work.GetNamespace(), work.GetName())
|
||||
}
|
||||
if len(errs) > 0 {
|
||||
return errors.NewAggregate(errs)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue