Skip to content

Commit

Permalink
Merge pull request #201 from mploski/fix/config-create-acl-retry
Browse files Browse the repository at this point in the history
Add retry to acl endpoint for config update
  • Loading branch information
mploski authored Dec 6, 2024
2 parents 2728d13 + e5707df commit e8397ea
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion splunk/resource_splunk_configs_conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import (
"errors"
"fmt"
"io"
"log"
"net/http"
"regexp"
"strconv"

"github.com/avast/retry-go/v4"
"github.com/splunk/terraform-provider-splunk/client/models"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
Expand Down Expand Up @@ -65,7 +67,18 @@ func configsConfCreate(d *schema.ResourceData, meta interface{}) error {
}
if _, ok := d.GetOk("acl"); ok {
conf, stanza := (*provider.Client).SplitConfStanza(name)
err := (*provider.Client).UpdateAcl(aclObject.Owner, aclObject.App, stanza, aclObject, "configs", "conf-"+conf)
// add retry as sometimes config object is not yet propagated and acl endpoint return 404
err = retry.Do(
func() error {
err := (*provider.Client).UpdateAcl(aclObject.Owner, aclObject.App, stanza, aclObject, "configs", "conf-"+conf)
if err != nil {
return err
}
return nil
}, retry.Attempts(10), retry.OnRetry(func(n uint, err error) {
log.Printf("#%d: %s. Retrying...\n", n, err)
}), retry.DelayType(retry.BackOffDelay),
)
if err != nil {
return err
}
Expand Down

0 comments on commit e8397ea

Please sign in to comment.