mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
client: fixed a bug where corrupt client state could panic the client (#19972)
This commit is contained in:
3
.changelog/19972.txt
Normal file
3
.changelog/19972.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
client: Fixed a bug where corrupt client state could panic the client
|
||||
```
|
||||
@@ -1876,6 +1876,14 @@ func TestClient_hasLocalState(t *testing.T) {
|
||||
|
||||
c.stateDB = cstate.NewMemDB(c.logger)
|
||||
|
||||
t.Run("nil Job", func(t *testing.T) {
|
||||
alloc := mock.BatchAlloc()
|
||||
alloc.Job = nil
|
||||
c.stateDB.PutAllocation(alloc)
|
||||
|
||||
must.False(t, c.hasLocalState(alloc))
|
||||
})
|
||||
|
||||
t.Run("plain alloc", func(t *testing.T) {
|
||||
alloc := mock.BatchAlloc()
|
||||
c.stateDB.PutAllocation(alloc)
|
||||
|
||||
@@ -4770,6 +4770,9 @@ func (j *Job) Warnings() error {
|
||||
|
||||
// LookupTaskGroup finds a task group by name
|
||||
func (j *Job) LookupTaskGroup(name string) *TaskGroup {
|
||||
if j == nil {
|
||||
return nil
|
||||
}
|
||||
for _, tg := range j.TaskGroups {
|
||||
if tg.Name == name {
|
||||
return tg
|
||||
|
||||
Reference in New Issue
Block a user