Skip to content

Commit

Permalink
Fix probe ASAP
Browse files Browse the repository at this point in the history
Signed-off-by: Luis Gustavo S. Barreto <gustavo@ossystems.com.br>
  • Loading branch information
gustavosbarreto committed Jan 31, 2018
1 parent ec581e0 commit 7f3b4a3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 4 additions & 0 deletions updatehub/probe_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ func (state *ProbeState) Handle(uh *UpdateHub) (State, bool) {
uh.Settings.PollingRetries = 0
}

if uh.Settings.ProbeASAP {
uh.Settings.ProbeASAP = false
}

uh.Settings.LastPoll = time.Now()
uh.Settings.ExtraPollingInterval = 0
uh.Settings.Save(uh.Store)
Expand Down
2 changes: 0 additions & 2 deletions updatehub/updatehub.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,6 @@ func (uh *UpdateHub) Start() {

if uh.Settings.ProbeASAP {
uh.state = NewProbeState(uh.DefaultApiClient)
uh.Settings.ProbeASAP = false
uh.Settings.Save(uh.Store)
}
}

Expand Down
4 changes: 2 additions & 2 deletions updatehub/updatehub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1983,11 +1983,11 @@ func TestStart(t *testing.T) {
(time.Time{}).UTC(),
&ProbeState{},
func(t *testing.T, uh *UpdateHub, state State) {
assert.Equal(t, false, uh.Settings.ProbeASAP)
assert.Equal(t, true, uh.Settings.ProbeASAP)

data, err := afero.ReadFile(uh.Store, uh.Settings.RuntimeSettingsPath)
assert.NoError(t, err)
assert.True(t, strings.Contains(string(data), "ProbeASAP=false"))
assert.True(t, strings.Contains(string(data), "ProbeASAP=true"))
assert.True(t, strings.Contains(string(data), "Retries=0"))
assert.True(t, strings.Contains(string(data), "ExtraInterval=0"))
// timestamps are relative to "Now()" so just test if they were written
Expand Down

0 comments on commit 7f3b4a3

Please sign in to comment.