Add guards while modifying shared variable during upgrades

Signed-off-by: Krish <kriiyer@cisco.com>
pull/9370/head
Krish 5 years ago
parent 46d80f68c1
commit 52b8b4f958

@ -21,6 +21,7 @@ import (
"context"
"fmt"
"strings"
"sync"
"time"
"github.com/pkg/errors"
@ -98,12 +99,15 @@ type Upgrade struct {
PostRenderer postrender.PostRenderer
// DisableOpenAPIValidation controls whether OpenAPI validation is enforced.
DisableOpenAPIValidation bool
// Synchronize multiple upgrade operations happening in parallel
Mutex *sync.Mutex
}
// NewUpgrade creates a new Upgrade object with the given configuration.
func NewUpgrade(cfg *Configuration) *Upgrade {
return &Upgrade{
cfg: cfg,
cfg: cfg,
Mutex: &sync.Mutex{},
}
}
@ -126,7 +130,9 @@ func (u *Upgrade) Run(name string, chart *chart.Chart, vals map[string]interface
return nil, err
}
u.Mutex.Lock()
u.cfg.Releases.MaxHistory = u.MaxHistory
u.Mutex.Unlock()
u.cfg.Log("performing update for %s", name)
res, err := u.performUpgrade(currentRelease, upgradedRelease)

@ -61,7 +61,7 @@ const (
// ValidateReleaseName performs checks for an entry for a Helm release name
//
// For Helm to allow a name, it must be below a certain character count (53) and also match
// a reguar expression.
// a regular expression.
//
// According to the Kubernetes help text, the regular expression it uses is:
//

Loading…
Cancel
Save