mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
fix(azure): set default value of VmssVirtualMachinesCacheTTLInSeconds during init to prevent data race
Signed-off-by: knight42 <anonymousknight96@gmail.com>
This commit is contained in:
parent
7740b8124c
commit
1e9f3306f1
@ -83,13 +83,16 @@ type scaleSet struct {
|
||||
|
||||
// newScaleSet creates a new scaleSet.
|
||||
func newScaleSet(az *Cloud) (VMSet, error) {
|
||||
var err error
|
||||
if az.Config.VmssVirtualMachinesCacheTTLInSeconds == 0 {
|
||||
az.Config.VmssVirtualMachinesCacheTTLInSeconds = vmssVirtualMachinesCacheTTLDefaultInSeconds
|
||||
}
|
||||
ss := &scaleSet{
|
||||
Cloud: az,
|
||||
availabilitySet: newAvailabilitySet(az),
|
||||
vmssVMCache: &sync.Map{},
|
||||
}
|
||||
|
||||
var err error
|
||||
if !ss.DisableAvailabilitySetNodes {
|
||||
ss.availabilitySetNodesCache, err = ss.newAvailabilitySetNodesCache()
|
||||
if err != nil {
|
||||
|
@ -154,9 +154,6 @@ func (ss *scaleSet) gcVMSSVMCache() error {
|
||||
|
||||
// newVMSSVirtualMachinesCache instanciates a new VMs cache for VMs belonging to the provided VMSS.
|
||||
func (ss *scaleSet) newVMSSVirtualMachinesCache(resourceGroupName, vmssName, cacheKey string) (*azcache.TimedCache, error) {
|
||||
if ss.Config.VmssVirtualMachinesCacheTTLInSeconds == 0 {
|
||||
ss.Config.VmssVirtualMachinesCacheTTLInSeconds = vmssVirtualMachinesCacheTTLDefaultInSeconds
|
||||
}
|
||||
vmssVirtualMachinesCacheTTL := time.Duration(ss.Config.VmssVirtualMachinesCacheTTLInSeconds) * time.Second
|
||||
|
||||
getter := func(key string) (interface{}, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user