Skip to content

Add retry to acl endpoint for config update #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading