Skip to content

Commit

Permalink
fix: re-reconcile the nodeclass status (#7305)
Browse files Browse the repository at this point in the history
Signed-off-by: Vacant2333 <[email protected]>
  • Loading branch information
Vacant2333 authored Dec 10, 2024
1 parent a74e441 commit f28522f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion pkg/controllers/nodeclass/status/ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ func (a *AMI) Reconcile(ctx context.Context, nodeClass *v1.EC2NodeClass) (reconc
if len(amis) == 0 {
nodeClass.Status.AMIs = nil
nodeClass.StatusConditions().SetFalse(v1.ConditionTypeAMIsReady, "AMINotFound", "AMISelector did not match any AMIs")
return reconcile.Result{}, nil
// If users have omitted the necessary tags from their AMIs and later add them, we need to reprocess the information.
// Returning 'ok' in this case means that the nodeclass will remain in an unready state until the component is restarted.
return reconcile.Result{RequeueAfter: time.Minute}, nil
}
nodeClass.Status.AMIs = lo.Map(amis, func(ami amifamily.AMI, _ int) v1.AMI {
reqs := lo.Map(ami.Requirements.NodeSelectorRequirements(), func(item karpv1.NodeSelectorRequirementWithMinValues, _ int) corev1.NodeSelectorRequirement {
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/nodeclass/status/securitygroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ func (sg *SecurityGroup) Reconcile(ctx context.Context, nodeClass *v1.EC2NodeCla
if len(securityGroups) == 0 && len(nodeClass.Spec.SecurityGroupSelectorTerms) > 0 {
nodeClass.Status.SecurityGroups = nil
nodeClass.StatusConditions().SetFalse(v1.ConditionTypeSecurityGroupsReady, "SecurityGroupsNotFound", "SecurityGroupSelector did not match any SecurityGroups")
return reconcile.Result{}, nil
// If users have omitted the necessary tags from their SecurityGroups and later add them, we need to reprocess the information.
// Returning 'ok' in this case means that the nodeclass will remain in an unready state until the component is restarted.
return reconcile.Result{RequeueAfter: time.Minute}, nil
}
sort.Slice(securityGroups, func(i, j int) bool {
return *securityGroups[i].GroupId < *securityGroups[j].GroupId
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/nodeclass/status/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ func (s *Subnet) Reconcile(ctx context.Context, nodeClass *v1.EC2NodeClass) (rec
if len(subnets) == 0 {
nodeClass.Status.Subnets = nil
nodeClass.StatusConditions().SetFalse(v1.ConditionTypeSubnetsReady, "SubnetsNotFound", "SubnetSelector did not match any Subnets")
return reconcile.Result{}, nil
// If users have omitted the necessary tags from their Subnets and later add them, we need to reprocess the information.
// Returning 'ok' in this case means that the nodeclass will remain in an unready state until the component is restarted.
return reconcile.Result{RequeueAfter: time.Minute}, nil
}
sort.Slice(subnets, func(i, j int) bool {
if int(*subnets[i].AvailableIpAddressCount) != int(*subnets[j].AvailableIpAddressCount) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/amifamily/ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func NewDefaultProvider(clk clock.Clock, versionProvider version.Provider, ssmPr
}
}

// Get Returning a list of AMIs with its associated requirements
// List Returning a list of AMIs with its associated requirements
func (p *DefaultProvider) List(ctx context.Context, nodeClass *v1.EC2NodeClass) (AMIs, error) {
p.Lock()
defer p.Unlock()
Expand Down

0 comments on commit f28522f

Please sign in to comment.