Skip to content

Commit

Permalink
Add mutex locks for KubeAPIWraper (#1013)
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronH88 authored Apr 22, 2024
1 parent 964bd0e commit 6730442
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/workceptor/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ func (ku KubeAPIWrapper) NewFakeAlwaysRateLimiter() flowcontrol.RateLimiter {
// It is instantiated in the NewkubeWorker function and available throughout the package.
var KubeAPIWrapperInstance KubeAPIer

var KubeAPIWrapperLock *sync.RWMutex

// ErrPodCompleted is returned when pod has already completed before we could attach.
var ErrPodCompleted = fmt.Errorf("pod ran to completion")

Expand Down Expand Up @@ -1501,10 +1503,13 @@ func (cfg KubeWorkerCfg) NewkubeWorker(bwu BaseWorkUnitForWorkUnit, w *Workcepto
}
}

KubeAPIWrapperLock = &sync.RWMutex{}
KubeAPIWrapperLock.Lock()
KubeAPIWrapperInstance = KubeAPIWrapper{}
if kawi != nil {
KubeAPIWrapperInstance = kawi
}
KubeAPIWrapperLock.Unlock()

ku := &KubeUnit{
BaseWorkUnitForWorkUnit: bwu,
Expand Down

0 comments on commit 6730442

Please sign in to comment.