Skip to content

Commit f404788

Browse files
author
Wei
authored
Merge pull request #248 from cloudpilot-ai/cherry-pick-246-release-0.2
Cherry pick PR(246)/fix: re-enqueue not too offen if error happened
2 parents 3eafbe8 + c439dc1 commit f404788

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

pkg/controllers/nodeclass/status/controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ func (c *Controller) Reconcile(ctx context.Context, nodeClass *v1alpha1.ECSNodeC
101101
errs = multierr.Append(errs, client.IgnoreNotFound(err))
102102
}
103103
}
104-
105-
if errs != nil {
106-
return reconcile.Result{}, errs
104+
if result.Min(results...).RequeueAfter > 0 {
105+
return result.Min(results...), nil
107106
}
108-
return result.Min(results...), nil
107+
108+
return reconcile.Result{}, errs
109109
}
110110

111111
func (c *Controller) Register(_ context.Context, m manager.Manager) error {

pkg/controllers/nodeclass/status/image.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (i *Image) Reconcile(ctx context.Context, nodeClass *v1alpha1.ECSNodeClass)
3737
images, err := i.imageProvider.List(ctx, nodeClass)
3838
if err != nil {
3939
log.FromContext(ctx).Error(err, "failed to list images")
40-
return reconcile.Result{}, err
40+
return reconcile.Result{RequeueAfter: time.Second * 30}, err
4141
}
4242

4343
if len(images) == 0 {

pkg/controllers/nodeclass/status/securitygroup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type SecurityGroup struct {
3434
func (sg *SecurityGroup) Reconcile(ctx context.Context, nodeClass *v1alpha1.ECSNodeClass) (reconcile.Result, error) {
3535
securityGroups, err := sg.securityGroupProvider.List(ctx, nodeClass)
3636
if err != nil {
37-
return reconcile.Result{}, fmt.Errorf("getting security groups, %w", err)
37+
return reconcile.Result{RequeueAfter: time.Second * 30}, fmt.Errorf("getting security groups, %w", err)
3838
}
3939
if len(securityGroups) == 0 && len(nodeClass.Spec.SecurityGroupSelectorTerms) > 0 {
4040
nodeClass.Status.SecurityGroups = nil

pkg/controllers/nodeclass/status/vswitch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type VSwitch struct {
3737
func (v *VSwitch) Reconcile(ctx context.Context, nodeClass *v1alpha1.ECSNodeClass) (reconcile.Result, error) {
3838
vSwitches, err := v.vSwitchProvider.List(ctx, nodeClass)
3939
if err != nil {
40-
return reconcile.Result{}, fmt.Errorf("getting vSwitches, %w", err)
40+
return reconcile.Result{RequeueAfter: time.Second * 30}, fmt.Errorf("getting vSwitches, %w", err)
4141
}
4242
if len(vSwitches) == 0 {
4343
nodeClass.Status.VSwitches = nil

0 commit comments

Comments
 (0)