mirror of
https://github.com/kemko/nomad.git
synced 2026-01-10 12:25:42 +03:00
Ensuring that ephemeral disk is present before deciding if we should migrate (#1827)
This commit is contained in:
committed by
GitHub
parent
8ba32e8720
commit
fe7d565803
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user