mirror of
https://github.com/helm/helm.git
synced 2026-04-15 21:59:50 -04:00
fix: protect FailingKubeClient.RecordedWaitOptions from concurrent access
Add a sync.Mutex to guard the append to RecordedWaitOptions in GetWaiterWithOptions, fixing a data race detected by -race when concurrent goroutines (e.g. upgrade + rollback) both call GetWaiterWithOptions on the same FailingKubeClient instance. Fixes race failures in TestUpgradeRelease_Interrupted_RollbackOnFailure and TestInstallRelease_RollbackOnFailure_Interrupted. Signed-off-by: Terry Howe <thowe@nvidia.com>
This commit is contained in:
parent
b4bd6b7688
commit
757ae5cd37
1 changed files with 4 additions and 0 deletions
|
|
@ -19,6 +19,7 @@ package fake
|
|||
|
||||
import (
|
||||
"io"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
|
@ -49,6 +50,7 @@ type FailingKubeClient struct {
|
|||
WaitDuration time.Duration
|
||||
// RecordedWaitOptions stores the WaitOptions passed to GetWaiter for testing
|
||||
RecordedWaitOptions []kube.WaitOption
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
var _ kube.Interface = &FailingKubeClient{}
|
||||
|
|
@ -160,7 +162,9 @@ func (f *FailingKubeClient) GetWaiter(ws kube.WaitStrategy) (kube.Waiter, error)
|
|||
|
||||
func (f *FailingKubeClient) GetWaiterWithOptions(ws kube.WaitStrategy, opts ...kube.WaitOption) (kube.Waiter, error) {
|
||||
// Record the WaitOptions for testing
|
||||
f.mu.Lock()
|
||||
f.RecordedWaitOptions = append(f.RecordedWaitOptions, opts...)
|
||||
f.mu.Unlock()
|
||||
waiter, _ := f.PrintingKubeClient.GetWaiterWithOptions(ws, opts...)
|
||||
printingKubeWaiter, _ := waiter.(*PrintingKubeWaiter)
|
||||
return &FailingKubeWaiter{
|
||||
|
|
|
|||
Loading…
Reference in a new issue