Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions helper/resource/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,9 @@ func (conf *StateChangeConf) WaitForStateContext(ctx context.Context) (interface
return nil, ctx.Err()
case <-timeout:
log.Printf("[WARN] WaitForState timeout after %s", conf.Timeout)
log.Printf("[WARN] WaitForState starting %s refresh grace period", refreshGracePeriod)

// cancel the goroutine and start our grace period timer
// cancel the goroutine
close(cancelCh)
timeout := time.After(refreshGracePeriod)

// we need a for loop and a label to break on, because we may have
// an extra response value to read, but still want to wait for the
// channel to close.
Expand All @@ -252,10 +249,7 @@ func (conf *StateChangeConf) WaitForStateContext(ctx context.Context) (interface
// TimeoutError and wait for the channel to close
lastResult = r
case <-ctx.Done():
log.Println("[ERROR] Context cancelation detected, abandoning grace period")
break forSelect
case <-timeout:
log.Println("[ERROR] WaitForState exceeded refresh grace period")
log.Println("[ERROR] Context cancellation detected, abandoning grace period")
break forSelect
}
}
Expand Down
2 changes: 1 addition & 1 deletion helper/resource/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func TestWaitForState_timeout(t *testing.T) {
t.Fatal("Expected timeout error. No error returned.")
}

expectedErr := "timeout while waiting for state to become 'running' (timeout: 1ms)"
expectedErr := "timeout while waiting for state to become 'running' (timeout: 1ms): failed"
if err.Error() != expectedErr {
t.Fatalf("Errors don't match.\nExpected: %q\nGiven: %q\n", expectedErr, err.Error())
}
Expand Down
4 changes: 2 additions & 2 deletions helper/resource/wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ func TestRetry_hang(t *testing.T) {
}

err := Retry(50*time.Millisecond, f)
if err == nil {
t.Fatal("should error")
if err != nil {
t.Fatal("should not error")
}
}

Expand Down