fix(helm): Data race in kube/client Delete func. (#7820)

helm uninstall has a data race in its Delete function.
This resolves it using a mutex.

Signed-off-by: Liam Nattrass <liam.d.nattrass+git@gmail.com>
pull/7867/head
lnattrass 4 years ago committed by GitHub
parent 6414791e08
commit c12a9aee02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -246,12 +246,17 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err
func (c *Client) Delete(resources ResourceList) (*Result, []error) {
var errs []error
res := &Result{}
mtx := sync.Mutex{}
err := perform(resources, func(info *resource.Info) error {
c.Log("Starting delete for %q %s", info.Name, info.Mapping.GroupVersionKind.Kind)
if err := c.skipIfNotFound(deleteResource(info)); err != nil {
mtx.Lock()
defer mtx.Unlock()
// Collect the error and continue on
errs = append(errs, err)
} else {
mtx.Lock()
defer mtx.Unlock()
res.Deleted = append(res.Deleted, info)
}
return nil

Loading…
Cancel
Save