csi: fix panic from assignment to nil map in plugin API (#8666)

This commit is contained in:
Tim Gross 2020-08-13 11:36:41 -04:00 committed by GitHub
parent e8a5565c1a
commit 7dca72acbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -407,6 +407,7 @@ func structsAllocListStubToApi(alloc *structs.AllocListStub) *api.AllocationList
DesiredDescription: alloc.DesiredDescription,
ClientStatus: alloc.ClientStatus,
ClientDescription: alloc.ClientDescription,
TaskStates: make(map[string]*api.TaskState, len(alloc.TaskStates)),
FollowupEvalID: alloc.FollowupEvalID,
PreemptedAllocations: alloc.PreemptedAllocations,
PreemptedByAllocation: alloc.PreemptedByAllocation,
@ -445,7 +446,7 @@ func structsRescheduleTrackerToApi(rt *structs.RescheduleTracker) *api.Reschedul
if rt == nil {
return nil
}
out := &api.RescheduleTracker{}
out := &api.RescheduleTracker{Events: []*api.RescheduleEvent{}}
for _, e := range rt.Events {
out.Events = append(out.Events, &api.RescheduleEvent{
@ -470,6 +471,7 @@ func structsTaskStateToApi(ts *structs.TaskState) *api.TaskState {
LastRestart: ts.LastRestart,
StartedAt: ts.StartedAt,
FinishedAt: ts.FinishedAt,
Events: []*api.TaskEvent{},
}
for _, te := range ts.Events {