Skip to content

Commit

Permalink
fix(nodegroup): add nil pointer check for nodegroup version
Browse files Browse the repository at this point in the history
Added a check to ensure that the nodegroup version is not nil before dereferencing it. This prevents potential runtime panics due to nil pointer dereference.

Signed-off-by: nueavv <nuguni@kakao.com>
  • Loading branch information
nueavv committed Jun 13, 2024
1 parent be020fd commit df089ef
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/cloud/services/eks/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ func (s *NodegroupService) reconcileNodegroupVersion(ng *eks.Nodegroup) error {
return fmt.Errorf("parsing EKS version from spec: %w", err)
}
}

// Check for nil pointers before dereferencing
if ng.Version == nil {
return fmt.Errorf("nodegroup version is nil")
}
ngVersion := version.MustParseGeneric(*ng.Version)
specAMI := s.scope.ManagedMachinePool.Spec.AMIVersion
ngAMI := *ng.ReleaseVersion
Expand Down

0 comments on commit df089ef

Please sign in to comment.