mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 17:35:43 +03:00
Fix bug introduced with paused nack timers
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user