Skip to content

Commit e8397ea

Browse files
authored
Merge pull request #201 from mploski/fix/config-create-acl-retry
Add retry to acl endpoint for config update
2 parents 2728d13 + e5707df commit e8397ea

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

splunk/resource_splunk_configs_conf.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import (
55
"errors"
66
"fmt"
77
"io"
8+
"log"
89
"net/http"
910
"regexp"
1011
"strconv"
1112

13+
"github.com/avast/retry-go/v4"
1214
"github.com/splunk/terraform-provider-splunk/client/models"
1315

1416
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
@@ -65,7 +67,18 @@ func configsConfCreate(d *schema.ResourceData, meta interface{}) error {
6567
}
6668
if _, ok := d.GetOk("acl"); ok {
6769
conf, stanza := (*provider.Client).SplitConfStanza(name)
68-
err := (*provider.Client).UpdateAcl(aclObject.Owner, aclObject.App, stanza, aclObject, "configs", "conf-"+conf)
70+
// add retry as sometimes config object is not yet propagated and acl endpoint return 404
71+
err = retry.Do(
72+
func() error {
73+
err := (*provider.Client).UpdateAcl(aclObject.Owner, aclObject.App, stanza, aclObject, "configs", "conf-"+conf)
74+
if err != nil {
75+
return err
76+
}
77+
return nil
78+
}, retry.Attempts(10), retry.OnRetry(func(n uint, err error) {
79+
log.Printf("#%d: %s. Retrying...\n", n, err)
80+
}), retry.DelayType(retry.BackOffDelay),
81+
)
6982
if err != nil {
7083
return err
7184
}

0 commit comments

Comments
 (0)