mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +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.
|
// newScaleSet creates a new scaleSet.
|
||||||
func newScaleSet(az *Cloud) (VMSet, error) {
|
func newScaleSet(az *Cloud) (VMSet, error) {
|
||||||
var err error
|
if az.Config.VmssVirtualMachinesCacheTTLInSeconds == 0 {
|
||||||
|
az.Config.VmssVirtualMachinesCacheTTLInSeconds = vmssVirtualMachinesCacheTTLDefaultInSeconds
|
||||||
|
}
|
||||||
ss := &scaleSet{
|
ss := &scaleSet{
|
||||||
Cloud: az,
|
Cloud: az,
|
||||||
availabilitySet: newAvailabilitySet(az),
|
availabilitySet: newAvailabilitySet(az),
|
||||||
vmssVMCache: &sync.Map{},
|
vmssVMCache: &sync.Map{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
if !ss.DisableAvailabilitySetNodes {
|
if !ss.DisableAvailabilitySetNodes {
|
||||||
ss.availabilitySetNodesCache, err = ss.newAvailabilitySetNodesCache()
|
ss.availabilitySetNodesCache, err = ss.newAvailabilitySetNodesCache()
|
||||||
if err != nil {
|
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.
|
// newVMSSVirtualMachinesCache instanciates a new VMs cache for VMs belonging to the provided VMSS.
|
||||||
func (ss *scaleSet) newVMSSVirtualMachinesCache(resourceGroupName, vmssName, cacheKey string) (*azcache.TimedCache, error) {
|
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
|
vmssVirtualMachinesCacheTTL := time.Duration(ss.Config.VmssVirtualMachinesCacheTTLInSeconds) * time.Second
|
||||||
|
|
||||||
getter := func(key string) (interface{}, error) {
|
getter := func(key string) (interface{}, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user