Skip to content

Commit

Permalink
fix: Set showunique on the call to GetTemplateID so we get a unique r…
Browse files Browse the repository at this point in the history
…esponse from the CS API

This is a workaround for the fact that the CloudStack API returns an invalid count when calling listTemplates with domain level API creds.
  • Loading branch information
hrak committed May 15, 2024
1 parent 301314e commit d7f9b59
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/cloud/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,15 @@ func (c *client) ResolveTemplate(
}
return csMachine.Spec.Template.ID, nil
}
templateID, count, err := c.cs.Template.GetTemplateID(csMachine.Spec.Template.Name, "executable", zoneID)
templateID, count, err := c.cs.Template.GetTemplateID(csMachine.Spec.Template.Name, "executable", zoneID, func(cs *cloudstack.CloudStackClient, i interface{}) error {
v, ok := i.(*cloudstack.ListTemplatesParams)
if !ok {
return fmt.Errorf("expected a cloudstack.ListTemplatesParams but got a %T", i)
}
v.SetShowunique(true)

return nil
})
if err != nil {
c.customMetrics.EvaluateErrorAndIncrementAcsReconciliationErrorCounter(err)
return "", multierror.Append(retErr, errors.Wrapf(
Expand Down

0 comments on commit d7f9b59

Please sign in to comment.