Merge pull request #1128 from hashicorp/f-restrict-inplace
Task is not eligible for update if User, Meta, or Resources change
This commit is contained in:
commit
2fb4d1d0cb
|
@ -127,6 +127,9 @@ func Job() *structs.Job {
|
|||
},
|
||||
},
|
||||
},
|
||||
Meta: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
Meta: map[string]string{
|
||||
|
|
|
@ -293,27 +293,24 @@ func tasksUpdated(a, b *structs.TaskGroup) bool {
|
|||
if at.Driver != bt.Driver {
|
||||
return true
|
||||
}
|
||||
if at.User != bt.User {
|
||||
return true
|
||||
}
|
||||
if !reflect.DeepEqual(at.Config, bt.Config) {
|
||||
return true
|
||||
}
|
||||
if !reflect.DeepEqual(at.Env, bt.Env) {
|
||||
return true
|
||||
}
|
||||
if !reflect.DeepEqual(at.Resources, bt.Resources) {
|
||||
return true
|
||||
}
|
||||
if !reflect.DeepEqual(at.Meta, bt.Meta) {
|
||||
return true
|
||||
}
|
||||
if !reflect.DeepEqual(at.Artifacts, bt.Artifacts) {
|
||||
return true
|
||||
}
|
||||
|
||||
// Inspect the network to see if the dynamic ports are different
|
||||
if len(at.Resources.Networks) != len(bt.Resources.Networks) {
|
||||
return true
|
||||
}
|
||||
for idx := range at.Resources.Networks {
|
||||
an := at.Resources.Networks[idx]
|
||||
bn := bt.Resources.Networks[idx]
|
||||
if len(an.DynamicPorts) != len(bn.DynamicPorts) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -376,6 +376,34 @@ func TestTasksUpdated(t *testing.T) {
|
|||
if !tasksUpdated(j1.TaskGroups[0], j7.TaskGroups[0]) {
|
||||
t.Fatalf("bad")
|
||||
}
|
||||
|
||||
j8 := mock.Job()
|
||||
j8.TaskGroups[0].Tasks[0].User = "foo"
|
||||
if !tasksUpdated(j1.TaskGroups[0], j8.TaskGroups[0]) {
|
||||
t.Fatalf("bad")
|
||||
}
|
||||
|
||||
j9 := mock.Job()
|
||||
j9.TaskGroups[0].Tasks[0].Artifacts = []*structs.TaskArtifact{
|
||||
{
|
||||
GetterSource: "http://foo.com/bar",
|
||||
},
|
||||
}
|
||||
if !tasksUpdated(j1.TaskGroups[0], j9.TaskGroups[0]) {
|
||||
t.Fatalf("bad")
|
||||
}
|
||||
|
||||
j10 := mock.Job()
|
||||
j10.TaskGroups[0].Tasks[0].Meta["baz"] = "boom"
|
||||
if !tasksUpdated(j1.TaskGroups[0], j10.TaskGroups[0]) {
|
||||
t.Fatalf("bad")
|
||||
}
|
||||
|
||||
j11 := mock.Job()
|
||||
j11.TaskGroups[0].Tasks[0].Resources.CPU = 1337
|
||||
if !tasksUpdated(j1.TaskGroups[0], j11.TaskGroups[0]) {
|
||||
t.Fatalf("bad")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvictAndPlace_LimitLessThanAllocs(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue