@@ -62,17 +62,11 @@ func (nr *NodeReconciler) Compute(
6262 compatHadExistingDeployment := nr .DeploymentCurrent != nil
6363
6464 result := new (NodeReconcileResult )
65- var deploymentComplete bool
6665 for nodeID , allocs := range nodeAllocs {
67- diff , deploymentCompleteForNode := nr .computeForNode (job , nodeID , eligibleNodes ,
66+ diff := nr .computeForNode (job , nodeID , eligibleNodes ,
6867 notReadyNodes , taintedNodes , required , allocs , terminal ,
6968 serverSupportsDisconnectedClients )
7069 result .Append (diff )
71-
72- deploymentComplete = deploymentCompleteForNode
73- if deploymentComplete {
74- break
75- }
7670 }
7771
7872 // COMPAT(1.14.0) prevent a new deployment from being created in the case
@@ -83,8 +77,6 @@ func (nr *NodeReconciler) Compute(
8377 nr .DeploymentCurrent = nil
8478 }
8579
86- nr .DeploymentUpdates = append (nr .DeploymentUpdates , nr .setDeploymentStatusAndUpdates (deploymentComplete , job )... )
87-
8880 return result
8981}
9082
@@ -102,8 +94,7 @@ func (nr *NodeReconciler) Compute(
10294// 8. those that may still be running on a node that has resumed reconnected.
10395//
10496// This method mutates the NodeReconciler fields, and returns a new
105- // NodeReconcilerResult object and a boolean to indicate wither the deployment
106- // is complete or not.
97+ // NodeReconcilerResult object.
10798func (nr * NodeReconciler ) computeForNode (
10899 job * structs.Job , // job whose allocs are going to be diff-ed
109100 nodeID string ,
@@ -114,7 +105,7 @@ func (nr *NodeReconciler) computeForNode(
114105 liveAllocs []* structs.Allocation , // non-terminal allocations that exist
115106 terminal structs.TerminalByNodeByName , // latest terminal allocations (by node, id)
116107 serverSupportsDisconnectedClients bool , // flag indicating whether to apply disconnected client logic
117- ) ( * NodeReconcileResult , bool ) {
108+ ) * NodeReconcileResult {
118109 result := new (NodeReconcileResult )
119110
120111 // cancel deployments that aren't needed anymore
@@ -322,10 +313,6 @@ func (nr *NodeReconciler) computeForNode(
322313 })
323314 }
324315
325- // as we iterate over require groups, we'll keep track of whether the
326- // deployment is complete or not
327- deploymentComplete := false
328-
329316 // Scan the required groups
330317 for name , tg := range required {
331318
@@ -343,7 +330,6 @@ func (nr *NodeReconciler) computeForNode(
343330 dstate .AutoPromote = tg .Update .AutoPromote
344331 dstate .ProgressDeadline = tg .Update .ProgressDeadline
345332 }
346- dstate .DesiredTotal = len (eligibleNodes )
347333 }
348334
349335 // Check for an existing allocation
@@ -405,7 +391,6 @@ func (nr *NodeReconciler) computeForNode(
405391
406392 // check if deployment is place ready or complete
407393 deploymentPlaceReady := ! deploymentPaused && ! deploymentFailed
408- deploymentComplete = nr .isDeploymentComplete (tg .Name , result , isCanarying [tg .Name ])
409394
410395 // check if perhaps there's nothing else to do for this TG
411396 if existingDeployment ||
@@ -426,7 +411,7 @@ func (nr *NodeReconciler) computeForNode(
426411 }
427412 }
428413
429- return result , deploymentComplete
414+ return result
430415}
431416
432417func (nr * NodeReconciler ) createDeployment (job * structs.Job , tg * structs.TaskGroup ,
@@ -485,74 +470,6 @@ func (nr *NodeReconciler) createDeployment(job *structs.Job, tg *structs.TaskGro
485470 nr .DeploymentCurrent .TaskGroups [tg .Name ] = dstate
486471}
487472
488- func (nr * NodeReconciler ) isDeploymentComplete (groupName string , buckets * NodeReconcileResult , isCanarying bool ) bool {
489- complete := len (buckets .Place )+ len (buckets .Migrate )+ len (buckets .Update ) == 0
490-
491- if ! complete || nr .DeploymentCurrent == nil || isCanarying {
492- return false
493- }
494-
495- // ensure everything is healthy
496- if dstate , ok := nr .DeploymentCurrent .TaskGroups [groupName ]; ok {
497- if dstate .HealthyAllocs < dstate .DesiredTotal { // Make sure we have enough healthy allocs
498- complete = false
499- }
500- }
501-
502- return complete
503- }
504-
505- func (nr * NodeReconciler ) setDeploymentStatusAndUpdates (deploymentComplete bool , job * structs.Job ) []* structs.DeploymentStatusUpdate {
506- statusUpdates := []* structs.DeploymentStatusUpdate {}
507-
508- if d := nr .DeploymentCurrent ; d != nil {
509-
510- // Deployments that require promotion should have appropriate status set
511- // immediately, no matter their completness.
512- if d .RequiresPromotion () {
513- if d .HasAutoPromote () {
514- d .StatusDescription = structs .DeploymentStatusDescriptionRunningAutoPromotion
515- } else {
516- d .StatusDescription = structs .DeploymentStatusDescriptionRunningNeedsPromotion
517- }
518- return statusUpdates
519- }
520-
521- // Mark the deployment as complete if possible
522- if deploymentComplete {
523- if job .IsMultiregion () {
524- // the unblocking/successful states come after blocked, so we
525- // need to make sure we don't revert those states
526- if d .Status != structs .DeploymentStatusUnblocking &&
527- d .Status != structs .DeploymentStatusSuccessful {
528- statusUpdates = append (statusUpdates , & structs.DeploymentStatusUpdate {
529- DeploymentID : nr .DeploymentCurrent .ID ,
530- Status : structs .DeploymentStatusBlocked ,
531- StatusDescription : structs .DeploymentStatusDescriptionBlocked ,
532- })
533- }
534- } else {
535- statusUpdates = append (statusUpdates , & structs.DeploymentStatusUpdate {
536- DeploymentID : nr .DeploymentCurrent .ID ,
537- Status : structs .DeploymentStatusSuccessful ,
538- StatusDescription : structs .DeploymentStatusDescriptionSuccessful ,
539- })
540- }
541- }
542-
543- // Mark the deployment as pending since its state is now computed.
544- if d .Status == structs .DeploymentStatusInitializing {
545- statusUpdates = append (statusUpdates , & structs.DeploymentStatusUpdate {
546- DeploymentID : nr .DeploymentCurrent .ID ,
547- Status : structs .DeploymentStatusPending ,
548- StatusDescription : structs .DeploymentStatusDescriptionPendingForPeer ,
549- })
550- }
551- }
552-
553- return statusUpdates
554- }
555-
556473// materializeSystemTaskGroups is used to materialize all the task groups
557474// a system or sysbatch job requires.
558475func materializeSystemTaskGroups (job * structs.Job ) map [string ]* structs.TaskGroup {
0 commit comments