Merge pull request #11300 from porridge/better-logging

During deletion, explicitly log already deleted resource.
pull/11497/head
Andrew Block 2 years ago committed by GitHub
commit 269dd247d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -308,16 +308,20 @@ func (c *Client) Delete(resources ResourceList) (*Result, []error) {
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)
if err := c.skipIfNotFound(deleteResource(info)); err != nil { err := deleteResource(info)
mtx.Lock() if err == nil || apierrors.IsNotFound(err) {
defer mtx.Unlock() if err != nil {
// Collect the error and continue on c.Log("Ignoring delete failure for %q %s: %v", info.Name, info.Mapping.GroupVersionKind, err)
errs = append(errs, err) }
} else {
mtx.Lock() mtx.Lock()
defer mtx.Unlock() defer mtx.Unlock()
res.Deleted = append(res.Deleted, info) res.Deleted = append(res.Deleted, info)
return nil
} }
mtx.Lock()
defer mtx.Unlock()
// Collect the error and continue on
errs = append(errs, err)
return nil return nil
}) })
if err != nil { if err != nil {
@ -334,14 +338,6 @@ func (c *Client) Delete(resources ResourceList) (*Result, []error) {
return res, nil return res, nil
} }
func (c *Client) skipIfNotFound(err error) error {
if apierrors.IsNotFound(err) {
c.Log("%v", err)
return nil
}
return err
}
func (c *Client) watchTimeout(t time.Duration) func(*resource.Info) error { func (c *Client) watchTimeout(t time.Duration) func(*resource.Info) error {
return func(info *resource.Info) error { return func(info *resource.Info) error {
return c.watchUntilReady(t, info) return c.watchUntilReady(t, info)

Loading…
Cancel
Save