Skip to content

Commit e17dec9

Browse files
committed
chore(objectstorage): add retry on 429 for objectstorage control plane
Signed-off-by: Mauritz Uphoff <mauritz.uphoff@stackit.cloud>
1 parent b2c1037 commit e17dec9

13 files changed

Lines changed: 102 additions & 17 deletions

File tree

docs/data-sources/objectstorage_bucket.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ page_title: "stackit_objectstorage_bucket Data Source - stackit"
44
subcategory: ""
55
description: |-
66
ObjectStorage bucket data source schema. Must have a region specified in the provider configuration.
7+
-> Note: States with many Object Storage resources may take several minutes to plan or apply due to Control Plane rate limiting. Requests are automatically retried.
78
---
89

910
# stackit_objectstorage_bucket (Data Source)
1011

1112
ObjectStorage bucket data source schema. Must have a `region` specified in the provider configuration.
1213

14+
-> **Note:** States with many Object Storage resources may take several minutes to plan or apply due to Control Plane rate limiting. Requests are automatically retried.
15+
1316
## Example Usage
1417

1518
```terraform

docs/data-sources/objectstorage_credential.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ page_title: "stackit_objectstorage_credential Data Source - stackit"
44
subcategory: ""
55
description: |-
66
ObjectStorage credential data source schema. Must have a region specified in the provider configuration.
7+
-> Note: States with many Object Storage resources may take several minutes to plan or apply due to Control Plane rate limiting. Requests are automatically retried.
78
---
89

910
# stackit_objectstorage_credential (Data Source)
1011

1112
ObjectStorage credential data source schema. Must have a `region` specified in the provider configuration.
1213

14+
-> **Note:** States with many Object Storage resources may take several minutes to plan or apply due to Control Plane rate limiting. Requests are automatically retried.
15+
1316
## Example Usage
1417

1518
```terraform

docs/data-sources/objectstorage_credentials_group.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ page_title: "stackit_objectstorage_credentials_group Data Source - stackit"
44
subcategory: ""
55
description: |-
66
ObjectStorage credentials group data source schema. Must have a region specified in the provider configuration.
7+
-> Note: States with many Object Storage resources may take several minutes to plan or apply due to Control Plane rate limiting. Requests are automatically retried.
78
---
89

910
# stackit_objectstorage_credentials_group (Data Source)
1011

1112
ObjectStorage credentials group data source schema. Must have a `region` specified in the provider configuration.
1213

14+
-> **Note:** States with many Object Storage resources may take several minutes to plan or apply due to Control Plane rate limiting. Requests are automatically retried.
15+
1316
## Example Usage
1417

1518
```terraform

docs/resources/objectstorage_bucket.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ subcategory: ""
55
description: |-
66
ObjectStorage bucket resource schema. Must have a region specified in the provider configuration.
77
~> This resource cannot be destroyed if the bucket contains objects. Please ensure the bucket is empty before attempting to destroy it.
8+
-> Note: States with many Object Storage resources may take several minutes to plan or apply due to Control Plane rate limiting. Requests are automatically retried.
89
---
910

1011
# stackit_objectstorage_bucket (Resource)
@@ -13,6 +14,8 @@ ObjectStorage bucket resource schema. Must have a `region` specified in the prov
1314

1415
~> This resource cannot be destroyed if the bucket contains objects. Please ensure the bucket is empty before attempting to destroy it.
1516

17+
-> **Note:** States with many Object Storage resources may take several minutes to plan or apply due to Control Plane rate limiting. Requests are automatically retried.
18+
1619
## Example Usage
1720

1821
```terraform

docs/resources/objectstorage_credential.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ page_title: "stackit_objectstorage_credential Resource - stackit"
44
subcategory: ""
55
description: |-
66
ObjectStorage credential resource schema. Must have a region specified in the provider configuration.
7+
-> Note: States with many Object Storage resources may take several minutes to plan or apply due to Control Plane rate limiting. Requests are automatically retried.
78
---
89

910
# stackit_objectstorage_credential (Resource)
1011

1112
ObjectStorage credential resource schema. Must have a `region` specified in the provider configuration.
1213

14+
-> **Note:** States with many Object Storage resources may take several minutes to plan or apply due to Control Plane rate limiting. Requests are automatically retried.
15+
1316
## Example Usage
1417

1518
```terraform

docs/resources/objectstorage_credentials_group.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ page_title: "stackit_objectstorage_credentials_group Resource - stackit"
44
subcategory: ""
55
description: |-
66
ObjectStorage credentials group resource schema. Must have a region specified in the provider configuration.
7+
-> Note: States with many Object Storage resources may take several minutes to plan or apply due to Control Plane rate limiting. Requests are automatically retried.
78
---
89

910
# stackit_objectstorage_credentials_group (Resource)
1011

1112
ObjectStorage credentials group resource schema. Must have a `region` specified in the provider configuration.
1213

14+
-> **Note:** States with many Object Storage resources may take several minutes to plan or apply due to Control Plane rate limiting. Requests are automatically retried.
15+
1316
## Example Usage
1417

1518
```terraform

stackit/internal/services/objectstorage/bucket/datasource.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ func (r *bucketDataSource) Configure(ctx context.Context, req datasource.Configu
6060
// Schema defines the schema for the data source.
6161
func (r *bucketDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
6262
descriptions := map[string]string{
63-
"main": "ObjectStorage bucket data source schema. Must have a `region` specified in the provider configuration.",
63+
"main": "ObjectStorage bucket data source schema. Must have a `region` specified in the provider configuration.\n\n" +
64+
"-> **Note:** States with many Object Storage resources may take several minutes to plan or apply due to Control Plane rate limiting. Requests are automatically retried.",
6465
"id": "Terraform's internal data source identifier. It is structured as \"`project_id`,`region`,`name`\".",
6566
"name": "The bucket name. It must be DNS conform.",
6667
"project_id": "STACKIT Project ID to which the bucket is associated.",
@@ -130,7 +131,11 @@ func (r *bucketDataSource) Read(ctx context.Context, req datasource.ReadRequest,
130131
ctx = tflog.SetField(ctx, "name", bucketName)
131132
ctx = tflog.SetField(ctx, "region", region)
132133

133-
bucketResp, err := r.client.DefaultAPI.GetBucket(ctx, projectId, region, bucketName).Execute()
134+
bucketResp, err := utils.RetryRequest(
135+
ctx,
136+
r.client.DefaultAPI.GetBucket(ctx, projectId, region, bucketName).Execute,
137+
objectstorageUtils.RateLimitRetryConfig,
138+
)
134139
if err != nil {
135140
utils.LogError(
136141
ctx,

stackit/internal/services/objectstorage/bucket/resource.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ func (r *bucketResource) Configure(ctx context.Context, req resource.ConfigureRe
120120
func (r *bucketResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
121121
descriptions := map[string]string{
122122
"main": "ObjectStorage bucket resource schema. Must have a `region` specified in the provider configuration.\n\n" +
123-
"~> This resource cannot be destroyed if the bucket contains objects. Please ensure the bucket is empty before attempting to destroy it.",
123+
"~> This resource cannot be destroyed if the bucket contains objects. Please ensure the bucket is empty before attempting to destroy it.\n\n" +
124+
"-> **Note:** States with many Object Storage resources may take several minutes to plan or apply due to Control Plane rate limiting. Requests are automatically retried.",
124125
"id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`region`,`name`\".",
125126
"name": "The bucket name. It must be DNS conform.",
126127
"project_id": "STACKIT Project ID to which the bucket is associated.",
@@ -218,7 +219,11 @@ func (r *bucketResource) Create(ctx context.Context, req resource.CreateRequest,
218219
}
219220

220221
// Create new bucket
221-
_, err = r.client.DefaultAPI.CreateBucket(ctx, projectId, region, bucketName).ObjectLockEnabled(model.ObjectLock.ValueBool()).Execute()
222+
_, err = utils.RetryRequest(
223+
ctx,
224+
r.client.DefaultAPI.CreateBucket(ctx, projectId, region, bucketName).ObjectLockEnabled(model.ObjectLock.ValueBool()).Execute,
225+
objectstorageUtils.RateLimitRetryConfig,
226+
)
222227
if err != nil {
223228
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating bucket", fmt.Sprintf("Calling API: %v", err))
224229
return
@@ -275,7 +280,11 @@ func (r *bucketResource) Read(ctx context.Context, req resource.ReadRequest, res
275280
ctx = tflog.SetField(ctx, "name", bucketName)
276281
ctx = tflog.SetField(ctx, "region", region)
277282

278-
bucketResp, err := r.client.DefaultAPI.GetBucket(ctx, projectId, region, bucketName).Execute()
283+
bucketResp, err := utils.RetryRequest(
284+
ctx,
285+
r.client.DefaultAPI.GetBucket(ctx, projectId, region, bucketName).Execute,
286+
objectstorageUtils.RateLimitRetryConfig,
287+
)
279288
if err != nil {
280289
var oapiErr *oapierror.GenericOpenAPIError
281290
if errors.As(err, &oapiErr) && oapiErr.StatusCode == http.StatusNotFound {
@@ -330,7 +339,11 @@ func (r *bucketResource) Delete(ctx context.Context, req resource.DeleteRequest,
330339
ctx = tflog.SetField(ctx, "region", region)
331340

332341
// Delete existing bucket
333-
_, err := r.client.DefaultAPI.DeleteBucket(ctx, projectId, region, bucketName).Execute()
342+
_, err := utils.RetryRequest(
343+
ctx,
344+
r.client.DefaultAPI.DeleteBucket(ctx, projectId, region, bucketName).Execute,
345+
objectstorageUtils.RateLimitRetryConfig,
346+
)
334347
if err != nil {
335348
var oapiErr *oapierror.GenericOpenAPIError
336349
if errors.As(err, &oapiErr) {

stackit/internal/services/objectstorage/credential/datasource.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ func (r *credentialDataSource) Configure(ctx context.Context, req datasource.Con
7070
// Schema defines the schema for the datasource.
7171
func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
7272
descriptions := map[string]string{ //nolint:gosec // description for credential id
73-
"main": "ObjectStorage credential data source schema. Must have a `region` specified in the provider configuration.",
73+
"main": "ObjectStorage credential data source schema. Must have a `region` specified in the provider configuration.\n\n" +
74+
"-> **Note:** States with many Object Storage resources may take several minutes to plan or apply due to Control Plane rate limiting. Requests are automatically retried.",
7475
"id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`region`,`credentials_group_id`,`credential_id`\".",
7576
"credential_id": "The credential ID.",
7677
"credentials_group_id": "The credential group ID.",
@@ -133,7 +134,11 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ
133134
ctx = tflog.SetField(ctx, "credential_id", credentialId)
134135
ctx = tflog.SetField(ctx, "region", region)
135136

136-
credentialsGroupResp, err := r.client.DefaultAPI.ListAccessKeys(ctx, projectId, region).CredentialsGroup(credentialsGroupId).Execute()
137+
credentialsGroupResp, err := utils.RetryRequest(
138+
ctx,
139+
r.client.DefaultAPI.ListAccessKeys(ctx, projectId, region).CredentialsGroup(credentialsGroupId).Execute,
140+
objectstorageUtils.RateLimitRetryConfig,
141+
)
137142
if err != nil {
138143
utils.LogError(
139144
ctx,

stackit/internal/services/objectstorage/credential/resource.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ func (r *credentialResource) Configure(ctx context.Context, req resource.Configu
160160
// Schema defines the schema for the resource.
161161
func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
162162
descriptions := map[string]string{ //nolint:gosec // description for credential id
163-
"main": "ObjectStorage credential resource schema. Must have a `region` specified in the provider configuration.",
163+
"main": "ObjectStorage credential resource schema. Must have a `region` specified in the provider configuration.\n\n" +
164+
"-> **Note:** States with many Object Storage resources may take several minutes to plan or apply due to Control Plane rate limiting. Requests are automatically retried.",
164165
"id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`region`,`credentials_group_id`,`credential_id`\".",
165166
"credential_id": "The credential ID.",
166167
"credentials_group_id": "The credential group ID.",
@@ -294,7 +295,11 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
294295
return
295296
}
296297
// Create new credential
297-
credentialResp, err := r.client.DefaultAPI.CreateAccessKey(ctx, projectId, region).CredentialsGroup(credentialsGroupId).CreateAccessKeyPayload(*payload).Execute()
298+
credentialResp, err := utils.RetryRequest(
299+
ctx,
300+
r.client.DefaultAPI.CreateAccessKey(ctx, projectId, region).CredentialsGroup(credentialsGroupId).CreateAccessKeyPayload(*payload).Execute,
301+
objectstorageUtils.RateLimitRetryConfig,
302+
)
298303
if err != nil {
299304
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err))
300305
return
@@ -454,7 +459,11 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ
454459
ctx = tflog.SetField(ctx, "region", region)
455460

456461
// Delete existing credential
457-
_, err := r.client.DefaultAPI.DeleteAccessKey(ctx, projectId, region, credentialId).CredentialsGroup(credentialsGroupId).Execute()
462+
_, err := utils.RetryRequest(
463+
ctx,
464+
r.client.DefaultAPI.DeleteAccessKey(ctx, projectId, region, credentialId).CredentialsGroup(credentialsGroupId).Execute,
465+
objectstorageUtils.RateLimitRetryConfig,
466+
)
458467
if err != nil {
459468
var oapiErr *oapierror.GenericOpenAPIError
460469
if errors.As(err, &oapiErr) && oapiErr.StatusCode == http.StatusNotFound {
@@ -560,7 +569,11 @@ func readCredentials(ctx context.Context, model *Model, region string, client *o
560569
credentialsGroupId := model.CredentialsGroupId.ValueString()
561570
credentialId := model.CredentialId.ValueString()
562571

563-
credentialsGroupResp, err := client.DefaultAPI.ListAccessKeys(ctx, projectId, region).CredentialsGroup(credentialsGroupId).Execute()
572+
credentialsGroupResp, err := utils.RetryRequest(
573+
ctx,
574+
client.DefaultAPI.ListAccessKeys(ctx, projectId, region).CredentialsGroup(credentialsGroupId).Execute,
575+
objectstorageUtils.RateLimitRetryConfig,
576+
)
564577
if err != nil {
565578
var oapiErr *oapierror.GenericOpenAPIError
566579
if errors.As(err, &oapiErr) && oapiErr.StatusCode == http.StatusNotFound {

0 commit comments

Comments
 (0)