Skip to content

Commit

Permalink
Fix node pool update when version is set
Browse files Browse the repository at this point in the history
  • Loading branch information
kahun committed Dec 19, 2023
1 parent cadb9b9 commit a315128
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions cloud/services/container/nodepools/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,12 @@ func (s *Service) checkDiffAndPrepareUpdateConfig(existingNodePool *containerpb.
desiredNodePool := scope.ConvertToSdkNodePool(*s.scope.GCPManagedMachinePool, *s.scope.MachinePool, isRegional, s.scope.GCPManagedControlPlane.Spec.ClusterName)

// Node version
if s.scope.NodePoolVersion() != nil && *s.scope.NodePoolVersion() != infrav1exp.ConvertFromSdkNodeVersion(existingNodePool.Version) {
needUpdate = true
updateNodePoolRequest.NodeVersion = *s.scope.NodePoolVersion()
if s.scope.NodePoolVersion() != nil {
desiredNodePoolVersion := infrav1exp.ConvertFromSdkNodeVersion(*s.scope.NodePoolVersion())
if desiredNodePoolVersion != infrav1exp.ConvertFromSdkNodeVersion(existingNodePool.Version) {
needUpdate = true
updateNodePoolRequest.NodeVersion = desiredNodePoolVersion
}
}
// Kubernetes labels
if !cmp.Equal(desiredNodePool.Config.GetLabels(), existingNodePool.Config.Labels) {
Expand Down
2 changes: 1 addition & 1 deletion exp/api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,5 @@ func ConvertToSdkAutoscaling(autoscaling *NodePoolAutoScaling) *containerpb.Node
// ConvertFromSdkNodeVersion converts GCP SDK node version to k8s version.
func ConvertFromSdkNodeVersion(sdkNodeVersion string) string {
// For example, the node version returned from GCP SDK can be 1.27.2-gke.2100, we want to convert it to 1.27.2
return strings.Split(sdkNodeVersion, "-")[0]
return strings.Replace(strings.Split(sdkNodeVersion, "-")[0], "v", "", 1)
}

0 comments on commit a315128

Please sign in to comment.