mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
suffix InSeconds to cacheTTL for clearification
This commit is contained in:
parent
8953544b15
commit
287e3298fb
@ -175,21 +175,21 @@ type Config struct {
|
||||
// with LoadBalancerName
|
||||
LoadBalancerResourceGroup string `json:"loadBalancerResourceGroup,omitempty" yaml:"loadBalancerResourceGroup,omitempty"`
|
||||
|
||||
// AvailabilitySetNodesCacheTTL sets the Cache TTL for availabilitySetNodesCache
|
||||
// AvailabilitySetNodesCacheTTLInSeconds sets the Cache TTL for availabilitySetNodesCache
|
||||
// if not set, will use default value
|
||||
AvailabilitySetNodesCacheTTL int `json:"availabilitySetNodesCacheTTL,omitempty" yaml:"availabilitySetNodesCacheTTL,omitempty"`
|
||||
// VmssCacheTTL sets the cache TTL for VMSS
|
||||
VmssCacheTTL int `json:"vmssCacheTTL,omitempty" yaml:"vmssCacheTTL,omitempty"`
|
||||
// VmssVirtualMachinesCacheTTL sets the cache TTL for vmssVirtualMachines
|
||||
VmssVirtualMachinesCacheTTL int `json:"vmssVirtualMachinesCacheTTL,omitempty" yaml:"vmssVirtualMachinesCacheTTL,omitempty"`
|
||||
// VmCacheTTL sets the cache TTL for vm
|
||||
VMCacheTTL int `json:"vmCacheTTL,omitempty" yaml:"vmCacheTTL,omitempty"`
|
||||
// LbCacheTTL sets the cache TTL for load balancer
|
||||
LbCacheTTL int `json:"lbCacheTTL,omitempty" yaml:"lbcacheTTL,omitempty"`
|
||||
// NsgCacheTTL sets the cache TTL for network security group
|
||||
NsgCacheTTL int `json:"nsgCacheTTL,omityempty" yaml:"nsgCacheTTL,omitempty"`
|
||||
// RtCacheTTL sets the cache TTL for route table
|
||||
RtCacheTTL int `json:"rtCacheTTL,omitempty" yaml:"rtCacheTTL,omitempty"`
|
||||
AvailabilitySetNodesCacheTTLInSeconds int `json:"availabilitySetNodesCacheTTLInSeconds,omitempty" yaml:"availabilitySetNodesCacheTTLInSeconds,omitempty"`
|
||||
// VmssCacheTTLInSeconds sets the cache TTL for VMSS
|
||||
VmssCacheTTLInSeconds int `json:"vmssCacheTTLInSeconds,omitempty" yaml:"vmssCacheTTLInSeconds,omitempty"`
|
||||
// VmssVirtualMachinesCacheTTLInSeconds sets the cache TTL for vmssVirtualMachines
|
||||
VmssVirtualMachinesCacheTTLInSeconds int `json:"vmssVirtualMachinesCacheTTLInSeconds,omitempty" yaml:"vmssVirtualMachinesCacheTTLInSeconds,omitempty"`
|
||||
// VmCacheTTLInSeconds sets the cache TTL for vm
|
||||
VMCacheTTLInSeconds int `json:"vmCacheTTLInSeconds,omitempty" yaml:"vmCacheTTLInSeconds,omitempty"`
|
||||
// LoadBalancerCacheTTLInSeconds sets the cache TTL for load balancer
|
||||
LoadBalancerCacheTTLInSeconds int `json:"loadBalancerCacheTTLInSeconds,omitempty" yaml:"loadBalancerCacheTTLInSeconds,omitempty"`
|
||||
// NsgCacheTTLInSeconds sets the cache TTL for network security group
|
||||
NsgCacheTTLInSeconds int `json:"nsgCacheTTLInSeconds,omitempty" yaml:"nsgCacheTTLInSeconds,omitempty"`
|
||||
// RouteTableCacheTTLInSeconds sets the cache TTL for route table
|
||||
RouteTableCacheTTLInSeconds int `json:"routeTableCacheTTLInSeconds,omitempty" yaml:"routeTableCacheTTLInSeconds,omitempty"`
|
||||
}
|
||||
|
||||
var _ cloudprovider.Interface = (*Cloud)(nil)
|
||||
|
@ -59,13 +59,13 @@ func TestParseConfig(t *testing.T) {
|
||||
"CloudProviderRateLimitBucketWrite": 1,
|
||||
"cloudProviderRateLimitQPS": 1,
|
||||
"CloudProviderRateLimitQPSWrite": 1,
|
||||
"availabilitySetNodesCacheTTL": 100,
|
||||
"vmssCacheTTL": 100,
|
||||
"vmssVirtualMachinesCacheTTL": 100,
|
||||
"vmCacheTTL": 100,
|
||||
"lbCacheTTL": 100,
|
||||
"nsgCacheTTL": 100,
|
||||
"rtCacheTTL": 100,
|
||||
"availabilitySetNodesCacheTTLInSeconds": 100,
|
||||
"vmssCacheTTLInSeconds": 100,
|
||||
"vmssVirtualMachinesCacheTTLInSeconds": 100,
|
||||
"vmCacheTTLInSeconds": 100,
|
||||
"loadBalancerCacheTTLInSeconds": 100,
|
||||
"nsgCacheTTLInSeconds": 100,
|
||||
"routeTableCacheTTLInSeconds": 100,
|
||||
"location": "location",
|
||||
"maximumLoadBalancerRuleCount": 1,
|
||||
"primaryAvailabilitySetName": "primaryAvailabilitySetName",
|
||||
@ -94,36 +94,36 @@ func TestParseConfig(t *testing.T) {
|
||||
TenantID: "tenantId",
|
||||
UseManagedIdentityExtension: true,
|
||||
},
|
||||
CloudProviderBackoff: true,
|
||||
CloudProviderBackoffDuration: 1,
|
||||
CloudProviderBackoffExponent: 1,
|
||||
CloudProviderBackoffJitter: 1,
|
||||
CloudProviderBackoffRetries: 1,
|
||||
CloudProviderRateLimit: true,
|
||||
CloudProviderRateLimitBucket: 1,
|
||||
CloudProviderRateLimitBucketWrite: 1,
|
||||
CloudProviderRateLimitQPS: 1,
|
||||
CloudProviderRateLimitQPSWrite: 1,
|
||||
AvailabilitySetNodesCacheTTL: 100,
|
||||
VmssCacheTTL: 100,
|
||||
VmssVirtualMachinesCacheTTL: 100,
|
||||
VMCacheTTL: 100,
|
||||
LbCacheTTL: 100,
|
||||
NsgCacheTTL: 100,
|
||||
RtCacheTTL: 100,
|
||||
Location: "location",
|
||||
MaximumLoadBalancerRuleCount: 1,
|
||||
PrimaryAvailabilitySetName: "primaryAvailabilitySetName",
|
||||
PrimaryScaleSetName: "primaryScaleSetName",
|
||||
ResourceGroup: "resourcegroup",
|
||||
RouteTableName: "routeTableName",
|
||||
RouteTableResourceGroup: "routeTableResourceGroup",
|
||||
SecurityGroupName: "securityGroupName",
|
||||
SubnetName: "subnetName",
|
||||
UseInstanceMetadata: true,
|
||||
VMType: "standard",
|
||||
VnetName: "vnetName",
|
||||
VnetResourceGroup: "vnetResourceGroup",
|
||||
CloudProviderBackoff: true,
|
||||
CloudProviderBackoffDuration: 1,
|
||||
CloudProviderBackoffExponent: 1,
|
||||
CloudProviderBackoffJitter: 1,
|
||||
CloudProviderBackoffRetries: 1,
|
||||
CloudProviderRateLimit: true,
|
||||
CloudProviderRateLimitBucket: 1,
|
||||
CloudProviderRateLimitBucketWrite: 1,
|
||||
CloudProviderRateLimitQPS: 1,
|
||||
CloudProviderRateLimitQPSWrite: 1,
|
||||
AvailabilitySetNodesCacheTTLInSeconds: 100,
|
||||
VmssCacheTTLInSeconds: 100,
|
||||
VmssVirtualMachinesCacheTTLInSeconds: 100,
|
||||
VMCacheTTLInSeconds: 100,
|
||||
LoadBalancerCacheTTLInSeconds: 100,
|
||||
NsgCacheTTLInSeconds: 100,
|
||||
RouteTableCacheTTLInSeconds: 100,
|
||||
Location: "location",
|
||||
MaximumLoadBalancerRuleCount: 1,
|
||||
PrimaryAvailabilitySetName: "primaryAvailabilitySetName",
|
||||
PrimaryScaleSetName: "primaryScaleSetName",
|
||||
ResourceGroup: "resourcegroup",
|
||||
RouteTableName: "routeTableName",
|
||||
RouteTableResourceGroup: "routeTableResourceGroup",
|
||||
SecurityGroupName: "securityGroupName",
|
||||
SubnetName: "subnetName",
|
||||
UseInstanceMetadata: true,
|
||||
VMType: "standard",
|
||||
VnetName: "vnetName",
|
||||
VnetResourceGroup: "vnetResourceGroup",
|
||||
}
|
||||
|
||||
buffer := bytes.NewBufferString(azureConfig)
|
||||
@ -1587,13 +1587,13 @@ func TestNewCloudFromJSON(t *testing.T) {
|
||||
"cloudProviderRatelimit": true,
|
||||
"cloudProviderRateLimitQPS": 0.5,
|
||||
"cloudProviderRateLimitBucket": 5,
|
||||
"availabilitySetNodesCacheTTL": 100,
|
||||
"vmssCacheTTL": 100,
|
||||
"vmssVirtualMachinesCacheTTL": 100,
|
||||
"vmCacheTTL": 100,
|
||||
"lbCacheTTL": 100,
|
||||
"nsgCacheTTL": 100,
|
||||
"rtCacheTTL": 100,
|
||||
"availabilitySetNodesCacheTTLInSeconds": 100,
|
||||
"vmssCacheTTLInSeconds": 100,
|
||||
"vmssVirtualMachinesCacheTTLInSeconds": 100,
|
||||
"vmCacheTTLInSeconds": 100,
|
||||
"loadBalancerCacheTTLInSeconds": 100,
|
||||
"nsgCacheTTLInSeconds": 100,
|
||||
"routeTableCacheTTLInSeconds": 100,
|
||||
}`
|
||||
validateConfig(t, config)
|
||||
}
|
||||
@ -1643,13 +1643,13 @@ cloudProviderBackoffJitter: 1.0
|
||||
cloudProviderRatelimit: true
|
||||
cloudProviderRateLimitQPS: 0.5
|
||||
cloudProviderRateLimitBucket: 5
|
||||
availabilitySetNodesCacheTTL: 100
|
||||
vmssCacheTTL: 100
|
||||
vmssVirtualMachinesCacheTTL: 100
|
||||
vmCacheTTL: 100
|
||||
lbCacheTTL: 100
|
||||
nsgCacheTTL: 100
|
||||
rtCacheTTL: 100
|
||||
availabilitySetNodesCacheTTLInSeconds: 100
|
||||
vmssCacheTTLInSeconds: 100
|
||||
vmssVirtualMachinesCacheTTLInSeconds: 100
|
||||
vmCacheTTLInSeconds: 100
|
||||
loadBalancerCacheTTLInSeconds: 100
|
||||
nsgCacheTTLInSeconds: 100
|
||||
routeTableCacheTTLInSeconds: 100
|
||||
`
|
||||
validateConfig(t, config)
|
||||
}
|
||||
@ -1723,26 +1723,26 @@ func validateConfig(t *testing.T, config string) {
|
||||
if azureCloud.CloudProviderRateLimitBucket != 5 {
|
||||
t.Errorf("got incorrect value for CloudProviderRateLimitBucket")
|
||||
}
|
||||
if azureCloud.AvailabilitySetNodesCacheTTL != 100 {
|
||||
t.Errorf("got incorrect value for availabilitySetNodesCacheTTL")
|
||||
if azureCloud.AvailabilitySetNodesCacheTTLInSeconds != 100 {
|
||||
t.Errorf("got incorrect value for availabilitySetNodesCacheTTLInSeconds")
|
||||
}
|
||||
if azureCloud.VmssCacheTTL != 100 {
|
||||
t.Errorf("got incorrect value for vmssCacheTTL")
|
||||
if azureCloud.VmssCacheTTLInSeconds != 100 {
|
||||
t.Errorf("got incorrect value for vmssCacheTTLInSeconds")
|
||||
}
|
||||
if azureCloud.VmssVirtualMachinesCacheTTL != 100 {
|
||||
t.Errorf("got incorrect value for vmssVirtualMachinesCacheTTL")
|
||||
if azureCloud.VmssVirtualMachinesCacheTTLInSeconds != 100 {
|
||||
t.Errorf("got incorrect value for vmssVirtualMachinesCacheTTLInSeconds")
|
||||
}
|
||||
if azureCloud.VMCacheTTL != 100 {
|
||||
t.Errorf("got incorrect value for vmCacheTTL")
|
||||
if azureCloud.VMCacheTTLInSeconds != 100 {
|
||||
t.Errorf("got incorrect value for vmCacheTTLInSeconds")
|
||||
}
|
||||
if azureCloud.LbCacheTTL != 100 {
|
||||
t.Errorf("got incorrect value for lbCacheTTL")
|
||||
if azureCloud.LoadBalancerCacheTTLInSeconds != 100 {
|
||||
t.Errorf("got incorrect value for loadBalancerCacheTTLInSeconds")
|
||||
}
|
||||
if azureCloud.NsgCacheTTL != 100 {
|
||||
t.Errorf("got incorrect value for nsgCacheTTL")
|
||||
if azureCloud.NsgCacheTTLInSeconds != 100 {
|
||||
t.Errorf("got incorrect value for nsgCacheTTLInSeconds")
|
||||
}
|
||||
if azureCloud.RtCacheTTL != 100 {
|
||||
t.Errorf("got incorrect value for rtCacheTTL")
|
||||
if azureCloud.RouteTableCacheTTLInSeconds != 100 {
|
||||
t.Errorf("got incorrect value for routeTableCacheTTLInSeconds")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,9 +38,9 @@ var (
|
||||
vmssVirtualMachinesKey = "k8svmssVirtualMachinesKey"
|
||||
availabilitySetNodesKey = "k8sAvailabilitySetNodesKey"
|
||||
|
||||
availabilitySetNodesCacheTTLDefault = 900 // in seconds
|
||||
vmssCacheTTLDefault = 600 // in seconds
|
||||
vmssVirtualMachinesCacheTTLDefault = 600 // in seconds
|
||||
availabilitySetNodesCacheTTLDefaultInSeconds = 900
|
||||
vmssCacheTTLDefaultInSeconds = 600
|
||||
vmssVirtualMachinesCacheTTLDefaultInSeconds = 600
|
||||
)
|
||||
|
||||
type vmssVirtualMachinesEntry struct {
|
||||
@ -87,10 +87,10 @@ func (ss *scaleSet) newVMSSCache() (*timedCache, error) {
|
||||
return localCache, nil
|
||||
}
|
||||
|
||||
if ss.Config.VmssCacheTTL == 0 {
|
||||
return newTimedcache(time.Duration(vmssCacheTTLDefault)*time.Second, getter)
|
||||
if ss.Config.VmssCacheTTLInSeconds == 0 {
|
||||
ss.Config.VmssCacheTTLInSeconds = vmssCacheTTLDefaultInSeconds
|
||||
}
|
||||
return newTimedcache(time.Duration(ss.Config.VmssCacheTTL)*time.Second, getter)
|
||||
return newTimedcache(time.Duration(ss.Config.VmssCacheTTLInSeconds)*time.Second, getter)
|
||||
}
|
||||
|
||||
func extractVmssVMName(name string) (string, string, error) {
|
||||
@ -150,10 +150,10 @@ func (ss *scaleSet) newVMSSVirtualMachinesCache() (*timedCache, error) {
|
||||
return localCache, nil
|
||||
}
|
||||
|
||||
if ss.Config.VmssVirtualMachinesCacheTTL == 0 {
|
||||
return newTimedcache(time.Duration(vmssVirtualMachinesCacheTTLDefault)*time.Second, getter)
|
||||
if ss.Config.VmssVirtualMachinesCacheTTLInSeconds == 0 {
|
||||
ss.Config.VmssVirtualMachinesCacheTTLInSeconds = vmssVirtualMachinesCacheTTLDefaultInSeconds
|
||||
}
|
||||
return newTimedcache(time.Duration(ss.Config.VmssVirtualMachinesCacheTTL)*time.Second, getter)
|
||||
return newTimedcache(time.Duration(ss.Config.VmssVirtualMachinesCacheTTLInSeconds)*time.Second, getter)
|
||||
}
|
||||
|
||||
func (ss *scaleSet) deleteCacheForNode(nodeName string) error {
|
||||
@ -192,10 +192,10 @@ func (ss *scaleSet) newAvailabilitySetNodesCache() (*timedCache, error) {
|
||||
return localCache, nil
|
||||
}
|
||||
|
||||
if ss.Config.AvailabilitySetNodesCacheTTL == 0 {
|
||||
return newTimedcache(time.Duration(availabilitySetNodesCacheTTLDefault)*time.Second, getter)
|
||||
if ss.Config.AvailabilitySetNodesCacheTTLInSeconds == 0 {
|
||||
ss.Config.AvailabilitySetNodesCacheTTLInSeconds = availabilitySetNodesCacheTTLDefaultInSeconds
|
||||
}
|
||||
return newTimedcache(time.Duration(ss.Config.AvailabilitySetNodesCacheTTL)*time.Second, getter)
|
||||
return newTimedcache(time.Duration(ss.Config.AvailabilitySetNodesCacheTTLInSeconds)*time.Second, getter)
|
||||
}
|
||||
|
||||
func (ss *scaleSet) isNodeManagedByAvailabilitySet(nodeName string, crt cacheReadType) (bool, error) {
|
||||
|
@ -35,10 +35,10 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
vmCacheTTLDefault = 60 // in seconds
|
||||
lbCacheTTLDefault = 120 // in seconds
|
||||
nsgCacheTTLDefault = 120 // in seconds
|
||||
rtCacheTTLDefault = 120 // in seconds
|
||||
vmCacheTTLDefaultInSeconds = 60
|
||||
loadBalancerCacheTTLDefaultInSeconds = 120
|
||||
nsgCacheTTLDefaultInSeconds = 120
|
||||
routeTableCacheTTLDefaultInSeconds = 120
|
||||
|
||||
azureNodeProviderIDRE = regexp.MustCompile(`^azure:///subscriptions/(?:.*)/resourceGroups/(?:.*)/providers/Microsoft.Compute/(?:.*)`)
|
||||
azureResourceGroupNameRE = regexp.MustCompile(`.*/subscriptions/(?:.*)/resourceGroups/(.+)/providers/(?:.*)`)
|
||||
@ -228,10 +228,10 @@ func (az *Cloud) newVMCache() (*timedCache, error) {
|
||||
return &vm, nil
|
||||
}
|
||||
|
||||
if az.VMCacheTTL == 0 {
|
||||
return newTimedcache(time.Duration(vmCacheTTLDefault)*time.Second, getter)
|
||||
if az.VMCacheTTLInSeconds == 0 {
|
||||
az.VMCacheTTLInSeconds = vmCacheTTLDefaultInSeconds
|
||||
}
|
||||
return newTimedcache(time.Duration(az.VMCacheTTL)*time.Second, getter)
|
||||
return newTimedcache(time.Duration(az.VMCacheTTLInSeconds)*time.Second, getter)
|
||||
}
|
||||
|
||||
func (az *Cloud) newLBCache() (*timedCache, error) {
|
||||
@ -253,10 +253,10 @@ func (az *Cloud) newLBCache() (*timedCache, error) {
|
||||
return &lb, nil
|
||||
}
|
||||
|
||||
if az.LbCacheTTL == 0 {
|
||||
return newTimedcache(time.Duration(lbCacheTTLDefault)*time.Second, getter)
|
||||
if az.LoadBalancerCacheTTLInSeconds == 0 {
|
||||
az.LoadBalancerCacheTTLInSeconds = loadBalancerCacheTTLDefaultInSeconds
|
||||
}
|
||||
return newTimedcache(time.Duration(az.LbCacheTTL)*time.Second, getter)
|
||||
return newTimedcache(time.Duration(az.LoadBalancerCacheTTLInSeconds)*time.Second, getter)
|
||||
}
|
||||
|
||||
func (az *Cloud) newNSGCache() (*timedCache, error) {
|
||||
@ -277,10 +277,10 @@ func (az *Cloud) newNSGCache() (*timedCache, error) {
|
||||
return &nsg, nil
|
||||
}
|
||||
|
||||
if az.NsgCacheTTL == 0 {
|
||||
return newTimedcache(time.Duration(nsgCacheTTLDefault)*time.Second, getter)
|
||||
if az.NsgCacheTTLInSeconds == 0 {
|
||||
az.NsgCacheTTLInSeconds = nsgCacheTTLDefaultInSeconds
|
||||
}
|
||||
return newTimedcache(time.Duration(az.NsgCacheTTL)*time.Second, getter)
|
||||
return newTimedcache(time.Duration(az.NsgCacheTTLInSeconds)*time.Second, getter)
|
||||
}
|
||||
|
||||
func (az *Cloud) newRouteTableCache() (*timedCache, error) {
|
||||
@ -301,10 +301,10 @@ func (az *Cloud) newRouteTableCache() (*timedCache, error) {
|
||||
return &rt, nil
|
||||
}
|
||||
|
||||
if az.RtCacheTTL == 0 {
|
||||
return newTimedcache(time.Duration(rtCacheTTLDefault)*time.Second, getter)
|
||||
if az.RouteTableCacheTTLInSeconds == 0 {
|
||||
az.RouteTableCacheTTLInSeconds = routeTableCacheTTLDefaultInSeconds
|
||||
}
|
||||
return newTimedcache(time.Duration(az.RtCacheTTL)*time.Second, getter)
|
||||
return newTimedcache(time.Duration(az.RouteTableCacheTTLInSeconds)*time.Second, getter)
|
||||
}
|
||||
|
||||
func (az *Cloud) useStandardLoadBalancer() bool {
|
||||
|
Loading…
Reference in New Issue
Block a user