diff --git a/cloud/services/container/nodepools/reconcile.go b/cloud/services/container/nodepools/reconcile.go index 3df3a826a..68ade86e0 100644 --- a/cloud/services/container/nodepools/reconcile.go +++ b/cloud/services/container/nodepools/reconcile.go @@ -420,7 +420,8 @@ func (s *Service) checkDiffAndPrepareUpdateAutoscaling(existingNodePool *contain setNodePoolAutoscalingRequest := containerpb.SetNodePoolAutoscalingRequest{ Name: s.scope.NodePoolFullName(), } - if !cmp.Equal(desiredAutoscaling, existingNodePool.Autoscaling) { + + if !cmp.Equal(desiredAutoscaling, existingNodePool.Autoscaling, cmpopts.IgnoreUnexported(containerpb.NodePoolAutoscaling{})) { needUpdate = true setNodePoolAutoscalingRequest.Autoscaling = desiredAutoscaling } diff --git a/exp/api/v1beta1/types.go b/exp/api/v1beta1/types.go index 19e29c0f6..53eb3dc85 100644 --- a/exp/api/v1beta1/types.go +++ b/exp/api/v1beta1/types.go @@ -81,27 +81,30 @@ func convertToSdkLocationPolicy(locationPolicy ManagedNodePoolLocationPolicy) co // ConvertToSdkAutoscaling converts node pool autoscaling config to a value that is used by GCP SDK. func ConvertToSdkAutoscaling(autoscaling *NodePoolAutoScaling) *containerpb.NodePoolAutoscaling { - if autoscaling == nil { - return nil - } sdkAutoscaling := containerpb.NodePoolAutoscaling{ - Enabled: true, // enable autoscaling by default - } - // set fields - if autoscaling.MinCount != nil { - sdkAutoscaling.TotalMinNodeCount = *autoscaling.MinCount - } - if autoscaling.MaxCount != nil { - sdkAutoscaling.TotalMaxNodeCount = *autoscaling.MaxCount - } - if autoscaling.EnableAutoscaling != nil { - sdkAutoscaling.Enabled = *autoscaling.EnableAutoscaling + Enabled: true, // enable autoscaling by default + TotalMinNodeCount: 0, + TotalMaxNodeCount: 1, + LocationPolicy: convertToSdkLocationPolicy(ManagedNodePoolLocationPolicyBalanced), } - if autoscaling.LocationPolicy != nil { - sdkAutoscaling.LocationPolicy = convertToSdkLocationPolicy(*autoscaling.LocationPolicy) - } else if sdkAutoscaling.Enabled { - // if location policy is not specified and autoscaling is enabled, default location policy to "any" - sdkAutoscaling.LocationPolicy = convertToSdkLocationPolicy(ManagedNodePoolLocationPolicyAny) + if autoscaling != nil { + // set fields + if autoscaling.MinCount != nil { + sdkAutoscaling.TotalMinNodeCount = *autoscaling.MinCount + } + if autoscaling.MaxCount != nil { + sdkAutoscaling.TotalMaxNodeCount = *autoscaling.MaxCount + } + if autoscaling.LocationPolicy != nil { + sdkAutoscaling.LocationPolicy = convertToSdkLocationPolicy(*autoscaling.LocationPolicy) + } + if autoscaling.EnableAutoscaling != nil { + if !*autoscaling.EnableAutoscaling { + sdkAutoscaling = containerpb.NodePoolAutoscaling{ + Enabled: false, + } + } + } } return &sdkAutoscaling diff --git a/tilt-provider.json b/tilt-provider.json index 94ba98dd5..bcbbb3fd4 100644 --- a/tilt-provider.json +++ b/tilt-provider.json @@ -8,7 +8,8 @@ "go.sum", "api", "cloud", - "controllers" + "controllers", + "exp" ], "label": "CAPG" }