Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#1099 from kahun/fix/node_pool_upda…
Browse files Browse the repository at this point in the history
…te_version

Fix node pool update when MachinePool version is set
  • Loading branch information
k8s-ci-robot committed Feb 4, 2024
2 parents 0d60ffb + a315128 commit 9831d45
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,7 +110,7 @@ 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)
}

// ConvertToSdkCgroupMode converts GCP SDK node version to k8s version.
Expand Down

0 comments on commit 9831d45

Please sign in to comment.