cloud: don't update snapshot interval unless response is from tfe.v2

pull/33844/head
Brandon Croft 3 years ago
parent 1ac7a37d00
commit 70cf13cae3
No known key found for this signature in database
GPG Key ID: B01E32423322EB9D

@ -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