Skip to content

Commit

Permalink
Log and return wrapped launchtemplate error
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Malcontenti-Wilson <[email protected]>
  • Loading branch information
adammw committed Dec 29, 2020
1 parent 757b669 commit 59a5204
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions controllers/rollingupgrade_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,14 +455,15 @@ func (r *RollingUpgradeReconciler) populateAsg(ruObj *upgrademgrv1alpha1.Rolling
return nil
}

func (r *RollingUpgradeReconciler) populateLaunchTemplates() error {
func (r *RollingUpgradeReconciler) populateLaunchTemplates(ruObj *upgrademgrv1alpha1.RollingUpgrade) error {
launchTemplates := []*ec2.LaunchTemplate{}
err := r.EC2Client.DescribeLaunchTemplatesPages(&ec2.DescribeLaunchTemplatesInput{}, func(page *ec2.DescribeLaunchTemplatesOutput, lastPage bool) bool {
launchTemplates = append(launchTemplates, page.LaunchTemplates...)
return page.NextToken != nil
})
if err != nil {
return err
r.error(ruObj, err, "Failed to populate launch template list")
return fmt.Errorf("failed to populate launch template list for %s: %w", ruObj.NamespacedName(), err)
}
r.LaunchTemplates = launchTemplates
return nil
Expand Down Expand Up @@ -648,7 +649,7 @@ func (r *RollingUpgradeReconciler) Process(ctx *context.Context,
return
}

if err := r.populateLaunchTemplates(); err != nil {
if err := r.populateLaunchTemplates(ruObj); err != nil {
r.finishExecution(upgrademgrv1alpha1.StatusError, 0, ctx, ruObj)
return
}
Expand Down

0 comments on commit 59a5204

Please sign in to comment.