Ensuring that ephemeral disk is present before deciding if we should migrate (#1827)

This commit is contained in:
Diptanu Choudhury
2016-10-19 11:12:25 -07:00
committed by GitHub
parent 8ba32e8720
commit fe7d565803
2 changed files with 26 additions and 1 deletions

View File

@@ -3074,7 +3074,17 @@ func (a *Allocation) ShouldMigrate() bool {
return false
}
if tg := a.Job.LookupTaskGroup(a.TaskGroup); tg != nil && !tg.EphemeralDisk.Migrate || !tg.EphemeralDisk.Sticky {
tg := a.Job.LookupTaskGroup(a.TaskGroup)
// if the task group is nil or the ephemeral disk block isn't present then
// we won't migrate
if tg == nil || tg.EphemeralDisk == nil {
return false
}
// We won't migrate any data is the user hasn't enabled migration or the
// disk is not marked as sticky
if !tg.EphemeralDisk.Migrate || !tg.EphemeralDisk.Sticky {
return false
}

View File

@@ -1223,6 +1223,21 @@ func TestAllocation_ShouldMigrate(t *testing.T) {
if alloc2.ShouldMigrate() {
t.Fatalf("bad: %v", alloc)
}
alloc3 := Allocation{
TaskGroup: "foo",
Job: &Job{
TaskGroups: []*TaskGroup{
{
Name: "foo",
},
},
},
}
if alloc3.ShouldMigrate() {
t.Fatalf("bad: %v", alloc)
}
}
func TestTaskArtifact_Validate_Checksum(t *testing.T) {