Fix bug introduced with paused nack timers

This commit is contained in:
Alex Dadgar
2016-03-04 16:17:14 -08:00
parent 13a2bff7f8
commit 022b6dd528
2 changed files with 17 additions and 14 deletions

View File

@@ -207,11 +207,11 @@ func TestRktDriver_Start_Wait_AllocDir(t *testing.T) {
task := &structs.Task{
Name: "alpine",
Config: map[string]interface{}{
"image": "docker://alpine",
"command": "/bin/sh",
"args": []string{
"-c",
fmt.Sprintf(`echo -n %s > ${%s}/%s`, string(exp), env.AllocDir, file),
"image": "docker://alpine",
"command": "/bin/sh",
"args": []string{
"-c",
fmt.Sprintf(`echo -n %s > ${%s}/%s`, string(exp), env.AllocDir, file),
},
},
LogConfig: &structs.LogConfig{
@@ -247,13 +247,13 @@ func TestRktDriver_Start_Wait_AllocDir(t *testing.T) {
}
// Check that data was written to the shared alloc directory.
outputFile := filepath.Join(execCtx.AllocDir.SharedDir, file)
act, err := ioutil.ReadFile(outputFile)
if err != nil {
t.Fatalf("Couldn't read expected output: %v", err)
}
outputFile := filepath.Join(execCtx.AllocDir.SharedDir, file)
act, err := ioutil.ReadFile(outputFile)
if err != nil {
t.Fatalf("Couldn't read expected output: %v", err)
}
if !reflect.DeepEqual(act, exp) {
t.Fatalf("Command output is %v; expected %v", act, exp)
}
if !reflect.DeepEqual(act, exp) {
t.Fatalf("Command output is %v; expected %v", act, exp)
}
}

View File

@@ -78,6 +78,7 @@ type unackEval struct {
Eval *structs.Evaluation
Token string
NackTimer *time.Timer
Paused bool
}
// PendingEvaluations is a list of waiting evaluations.
@@ -419,7 +420,7 @@ func (b *EvalBroker) OutstandingReset(evalID, token string) error {
if unack.Token != token {
return ErrTokenMismatch
}
if !unack.NackTimer.Reset(b.nackTimeout) {
if !unack.Paused && !unack.NackTimer.Reset(b.nackTimeout) {
return ErrNackTimeoutReached
}
return nil
@@ -525,6 +526,7 @@ func (b *EvalBroker) PauseNackTimeout(evalID, token string) error {
if !unack.NackTimer.Stop() {
return ErrNackTimeoutReached
}
unack.Paused = true
return nil
}
@@ -541,6 +543,7 @@ func (b *EvalBroker) ResumeNackTimeout(evalID, token string) error {
return ErrTokenMismatch
}
unack.NackTimer.Reset(b.nackTimeout)
unack.Paused = false
return nil
}