Merge pull request #33844 from hashicorp/TF-9205-state-intermediate-snapshot-interval-header-being-set-by-from-archivist-responses

cloud: don't update snapshot interval unless response is from tfe.v2
s3/f-check-for-bucket-in-init
Brandon Croft 3 years ago committed by GitHub
commit 0effce50dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -584,6 +584,13 @@ func clamp(val, min, max int64) int64 {
}
func (s *State) readSnapshotIntervalHeader(status int, header http.Header) {
// Only proceed if this came from tfe.v2 API
contentType := header.Get("Content-Type")
if !strings.Contains(contentType, tfe.ContentTypeJSONAPI) {
log.Printf("[TRACE] Skipping intermediate state interval because Content-Type was %q", contentType)
return
}
intervalStr := header.Get(HeaderSnapshotInterval)
if intervalSecs, err := strconv.ParseInt(intervalStr, 10, 64); err == nil {
@ -600,6 +607,7 @@ func (s *State) readSnapshotIntervalHeader(status int, header http.Header) {
}
// We will only enable snapshots for intervals greater than zero
log.Printf("[TRACE] Intermediate state interval is set by header to %v", s.stateSnapshotInterval)
s.enableIntermediateSnapshots = s.stateSnapshotInterval > 0
}

@ -437,7 +437,7 @@ func testServerWithSnapshotsEnabled(t *testing.T, enabled bool) *httptest.Server
t.Fatal(err)
}
w.Header().Set("content-type", "application/json")
w.Header().Set("content-type", tfe.ContentTypeJSONAPI)
w.Header().Set("content-length", strconv.FormatInt(int64(len(fakeBodyRaw)), 10))
switch r.Method {

Loading…
Cancel
Save