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 64caf12
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion 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 Expand Up @@ -555,7 +560,7 @@ func (s *NodegroupService) reconcileNodegroup(ctx context.Context) error {
return errors.Wrap(err, "failed to wait for nodegroup to be active")
}

if err := s.reconcileNodegroupVersion(ng); err != nil {
if err := s.(ng); err != nil {
return errors.Wrap(err, "failed to reconcile nodegroup version")
}

Expand Down

0 comments on commit 64caf12

Please sign in to comment.