Skip to content

Commit 8d3db26

Browse files
author
Cristina Sánchez Sánchez
committed
Merge branch 'CLOUDP-320243-dev-2.0.0' into CLOUDP-333176
2 parents bc7fe7b + 0ef10fc commit 8d3db26

File tree

7 files changed

+13
-7
lines changed

7 files changed

+13
-7
lines changed

.changelog/3526.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/mongodbatlas_online_archive: Adds `timeouts` attribute for create operation
3+
```

docs/resources/online_archive.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ resource "mongodbatlas_online_archive" "test" {
116116
* `partition_fields` - (Recommended) Fields to use to partition data. You can specify up to two frequently queried fields (or up to three fields when one of them is `date_field`) to use for partitioning data. Queries that don’t contain the specified fields require a full collection scan of all archived documents, which takes longer and increases your costs. To learn more about how partition improves query performance, see [Data Structure in S3](https://docs.mongodb.com/datalake/admin/optimize-query-performance/#data-structure-in-s3). The value of a partition field can be up to a maximum of 700 characters. Documents with values exceeding 700 characters are not archived. See [partition fields](#partition).
117117
* `paused` - (Optional) State of the online archive. This is required for pausing an active online archive or resuming a paused online archive. If the collection has another active online archive, the resume request fails.
118118
* `sync_creation` - (Optional) Flag that indicates whether the provider will wait for the state of the online archive to reach `IDLE` or `ACTIVE` when creating an online archive. Defaults to `false`.
119+
* `timeouts`- (Optional) The duration of time to wait for Online Archive to be created. The timeout value is defined by a signed sequence of decimal numbers with a time unit suffix such as: `1h45m`, `300s`, `10m`, etc. The valid time units are: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. The default timeout for Online Archive create is `3h`. Learn more about timeouts [here](https://www.terraform.io/plugin/sdkv2/resources/retries-and-customizable-timeouts).
119120

120121
### Criteria
121122

internal/service/clusteroutagesimulation/resource_cluster_outage_simulation.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,11 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.
9393
return diag.FromErr(fmt.Errorf(errorClusterOutageSimulationCreate, projectID, clusterName, err))
9494
}
9595

96-
timeout := d.Timeout(schema.TimeoutCreate)
9796
stateConf := &retry.StateChangeConf{
9897
Pending: []string{"START_REQUESTED", "STARTING"},
9998
Target: []string{"SIMULATING"},
10099
Refresh: resourceRefreshFunc(ctx, clusterName, projectID, connV2),
101-
Timeout: timeout,
100+
Timeout: d.Timeout(schema.TimeoutCreate) - time.Minute, // When using a CRUD function with a timeout, any StateChangeConf timeouts must be configured below that duration to avoid returning the SDK context: deadline exceeded error instead of the retry logic error.
102101
MinTimeout: 1 * time.Minute,
103102
Delay: 3 * time.Minute,
104103
}

internal/service/networkpeering/resource_network_peering.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.
261261
Pending: []string{"INITIATING", "FINALIZING", "ADDING_PEER", "WAITING_FOR_USER"},
262262
Target: []string{"FAILED", "AVAILABLE", "PENDING_ACCEPTANCE"},
263263
Refresh: resourceRefreshFunc(ctx, peerID, projectID, peerRequest.GetContainerId(), conn.NetworkPeeringApi),
264-
Timeout: d.Timeout(schema.TimeoutCreate),
264+
Timeout: d.Timeout(schema.TimeoutCreate) - time.Minute, // When using a CRUD function with a timeout, any StateChangeConf timeouts must be configured below that duration to avoid returning the SDK context: deadline exceeded error instead of the retry logic error.
265265
MinTimeout: minTimeout,
266266
Delay: minTimeout,
267267
}

internal/service/onlinearchive/resource_online_archive.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ func Resource() *schema.Resource {
3434
Importer: &schema.ResourceImporter{
3535
StateContext: resourceImport,
3636
},
37+
Timeouts: &schema.ResourceTimeout{
38+
Create: schema.DefaultTimeout(3 * time.Hour),
39+
},
3740
}
3841
}
3942

@@ -240,7 +243,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.
240243
Pending: []string{"PENDING", "ARCHIVING", "PAUSING", "PAUSED", "ORPHANED", "REPEATING"},
241244
Target: []string{"IDLE", "ACTIVE"},
242245
Refresh: resourceOnlineRefreshFunc(ctx, projectID, clusterName, archiveID, connV2),
243-
Timeout: 3 * time.Hour,
246+
Timeout: d.Timeout(schema.TimeoutCreate) - time.Minute, // When using a CRUD function with a timeout, any StateChangeConf timeouts must be configured below that duration to avoid returning the SDK context: deadline exceeded error instead of the retry logic error.
244247
MinTimeout: 1 * time.Minute,
245248
Delay: 3 * time.Minute,
246249
}

internal/service/privatelinkendpoint/resource_privatelink_endpoint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.
134134
Pending: []string{"INITIATING", "DELETING"},
135135
Target: []string{"WAITING_FOR_USER", "FAILED", "DELETED", "AVAILABLE"},
136136
Refresh: refreshFunc(ctx, connV2, projectID, providerName, privateEndpoint.GetId()),
137-
Timeout: d.Timeout(schema.TimeoutCreate),
137+
Timeout: d.Timeout(schema.TimeoutCreate) - time.Minute, // If using a CRUD function with a timeout, any StateChangeConf timeouts should be configured below that duration to avoid returning the SDK context: deadline exceeded error instead of the retry logic error.
138138
MinTimeout: 5 * time.Second,
139139
Delay: 3 * time.Second,
140140
}

internal/service/privatelinkendpointservice/resource_privatelink_endpoint_service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.
173173
Pending: []string{"NONE", "INITIATING", "PENDING_ACCEPTANCE", "PENDING", "DELETING", "VERIFIED"},
174174
Target: []string{"AVAILABLE", "REJECTED", "DELETED", "FAILED"},
175175
Refresh: resourceRefreshFunc(ctx, connV2, projectID, providerName, privateLinkID, endpointServiceID),
176-
Timeout: d.Timeout(schema.TimeoutCreate),
176+
Timeout: d.Timeout(schema.TimeoutCreate) - time.Minute, // When using a CRUD function with a timeout, any StateChangeConf timeouts must be configured below that duration to avoid returning the SDK context: deadline exceeded error instead of the retry logic error.
177177
MinTimeout: 5 * time.Second,
178178
Delay: 1 * time.Minute,
179179
}
@@ -187,7 +187,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.
187187
Pending: []string{"REPEATING", "PENDING"},
188188
Target: []string{"IDLE", "DELETED"},
189189
Refresh: advancedcluster.ResourceClusterListAdvancedRefreshFunc(ctx, projectID, connV2.ClustersApi),
190-
Timeout: d.Timeout(schema.TimeoutCreate),
190+
Timeout: d.Timeout(schema.TimeoutCreate) - time.Minute, // When using a CRUD function with a timeout, any StateChangeConf timeouts must be configured below that duration to avoid returning the SDK context: deadline exceeded error instead of the retry logic error.
191191
MinTimeout: 5 * time.Second,
192192
Delay: 1 * time.Minute,
193193
}

0 commit comments

Comments
 (0)