From d7f9b597b4bc1eee537347ae8d4a4c25c919bc06 Mon Sep 17 00:00:00 2001 From: Hans Rakers Date: Wed, 15 May 2024 15:50:17 +0200 Subject: [PATCH] fix: Set showunique on the call to GetTemplateID so we get a unique response 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. --- pkg/cloud/instance.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/cloud/instance.go b/pkg/cloud/instance.go index 4bd01bae..a18c39cf 100644 --- a/pkg/cloud/instance.go +++ b/pkg/cloud/instance.go @@ -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(