@@ -244,9 +244,7 @@ func (p *planner) applyPlan(plan *structs.Plan, result *structs.PlanResult, snap
244244
245245 // Setup the update request
246246 req := structs.ApplyPlanResultsRequest {
247- AllocUpdateRequest : structs.AllocUpdateRequest {
248- Job : plan .Job ,
249- },
247+ Job : plan .Job ,
250248 Deployment : result .Deployment ,
251249 DeploymentUpdates : result .DeploymentUpdates ,
252250 IneligibleNodes : result .IneligibleNodes ,
@@ -256,74 +254,38 @@ func (p *planner) applyPlan(plan *structs.Plan, result *structs.PlanResult, snap
256254
257255 preemptedJobIDs := make (map [structs.NamespacedID ]struct {})
258256
259- if p .srv .peersCache .ServersMeetMinimumVersion (p .srv .Region (), MinVersionPlanNormalization , true ) {
260- // Initialize the allocs request using the new optimized log entry format.
261- // Determine the minimum number of updates, could be more if there
262- // are multiple updates per node
263- req .AllocsStopped = make ([]* structs.AllocationDiff , 0 , len (result .NodeUpdate ))
264- req .AllocsUpdated = make ([]* structs.Allocation , 0 , len (result .NodeAllocation ))
265- req .AllocsPreempted = make ([]* structs.AllocationDiff , 0 , len (result .NodePreemptions ))
266-
267- for _ , updateList := range result .NodeUpdate {
268- for _ , stoppedAlloc := range updateList {
269- req .AllocsStopped = append (req .AllocsStopped , normalizeStoppedAlloc (stoppedAlloc , unixNow ))
270- }
271- }
272-
273- for _ , allocList := range result .NodeAllocation {
274- req .AllocsUpdated = append (req .AllocsUpdated , allocList ... )
275- }
276-
277- // Set the time the alloc was applied for the first time. This can be used
278- // to approximate the scheduling time.
279- updateAllocTimestamps (req .AllocsUpdated , unixNow )
257+ // Initialize the allocs request using the new optimized log entry format.
258+ // Determine the minimum number of updates, could be more if there
259+ // are multiple updates per node
260+ req .AllocsStopped = make ([]* structs.AllocationDiff , 0 , len (result .NodeUpdate ))
261+ req .AllocsUpdated = make ([]* structs.Allocation , 0 , len (result .NodeAllocation ))
262+ req .AllocsPreempted = make ([]* structs.AllocationDiff , 0 , len (result .NodePreemptions ))
280263
281- err := signAllocIdentities (p .srv .encrypter , plan .Job , req .AllocsUpdated , now )
282- if err != nil {
283- return nil , err
284- }
285-
286- for _ , preemptions := range result .NodePreemptions {
287- for _ , preemptedAlloc := range preemptions {
288- req .AllocsPreempted = append (req .AllocsPreempted , normalizePreemptedAlloc (preemptedAlloc , unixNow ))
289-
290- // Gather jobids to create follow up evals
291- appendNamespacedJobID (preemptedJobIDs , preemptedAlloc )
292- }
264+ for _ , updateList := range result .NodeUpdate {
265+ for _ , stoppedAlloc := range updateList {
266+ req .AllocsStopped = append (req .AllocsStopped , normalizeStoppedAlloc (stoppedAlloc , unixNow ))
293267 }
294- } else {
295- // COMPAT 0.11: This branch is deprecated and will only be used to support
296- // application of older log entries. Expected to be removed in a future version.
297-
298- // Determine the minimum number of updates, could be more if there
299- // are multiple updates per node
300- minUpdates := len (result .NodeUpdate )
301- minUpdates += len (result .NodeAllocation )
268+ }
302269
303- // Initialize using the older log entry format for Alloc and NodePreemptions
304- req .Alloc = make ([] * structs. Allocation , 0 , minUpdates )
305- req . NodePreemptions = make ([] * structs. Allocation , 0 , len ( result . NodePreemptions ))
270+ for _ , allocList := range result . NodeAllocation {
271+ req .AllocsUpdated = append ( req . AllocsUpdated , allocList ... )
272+ }
306273
307- for _ , updateList := range result .NodeUpdate {
308- req .Alloc = append (req .Alloc , updateList ... )
309- }
310- for _ , allocList := range result .NodeAllocation {
311- req .Alloc = append (req .Alloc , allocList ... )
312- }
274+ // Set the time the alloc was applied for the first time. This can be used
275+ // to approximate the scheduling time.
276+ updateAllocTimestamps (req .AllocsUpdated , unixNow )
313277
314- for _ , preemptions := range result .NodePreemptions {
315- req .NodePreemptions = append (req .NodePreemptions , preemptions ... )
316- }
278+ err := signAllocIdentities (p .srv .encrypter , plan .Job , req .AllocsUpdated , now )
279+ if err != nil {
280+ return nil , err
281+ }
317282
318- // Set the time the alloc was applied for the first time. This can be used
319- // to approximate the scheduling time.
320- updateAllocTimestamps (req .Alloc , unixNow )
283+ for _ , preemptions := range result . NodePreemptions {
284+ for _ , preemptedAlloc := range preemptions {
285+ req . AllocsPreempted = append (req .AllocsPreempted , normalizePreemptedAlloc ( preemptedAlloc , unixNow ) )
321286
322- // Set modify time for preempted allocs if any
323- // Also gather jobids to create follow up evals
324- for _ , alloc := range req .NodePreemptions {
325- alloc .ModifyTime = unixNow
326- appendNamespacedJobID (preemptedJobIDs , alloc )
287+ // Gather jobids to create follow up evals
288+ appendNamespacedJobID (preemptedJobIDs , preemptedAlloc )
327289 }
328290 }
329291
0 commit comments