cloud: when saving state, create a pending state version then upload

Create a pending state version followed by a separate state upload

When this version of the endpoint fails (It is not yet generally available, or when using with Terraform Enterprise) Fall back to the original call with state content included in the request.

This strategy will reduce the amount of save failures due to network latency and gateway timeouts.
This commit is contained in:
Brandon Croft
2023-06-08 17:29:32 -06:00
parent 5ed38eb3fa
commit 9fe3f7a7b4
7 changed files with 91 additions and 21 deletions

View File

@@ -298,7 +298,6 @@ func TestState_PersistState(t *testing.T) {
// since HTTP-level concerns like headers are out of scope for the
// mock client we typically use in other tests in this package, which
// aim to abstract away HTTP altogether.
var serverURL string
// Didn't want to repeat myself here
for _, testCase := range []struct {
@@ -314,10 +313,9 @@ func TestState_PersistState(t *testing.T) {
snapshotsEnabled: false,
},
} {
server := testServerWithSnapshotsEnabled(t, serverURL, testCase.snapshotsEnabled)
server := testServerWithSnapshotsEnabled(t, testCase.snapshotsEnabled)
defer server.Close()
serverURL = server.URL
cfg := &tfe.Config{
Address: server.URL,
BasePath: "api",