@@ -1069,13 +1069,34 @@ func (c *Client) updateNodeStatus() error {
1069
1069
1070
1070
// updateAllocStatus is used to update the status of an allocation
1071
1071
func (c * Client ) updateAllocStatus (alloc * structs.Allocation ) {
1072
- // Only send the fields that are updatable by the client.
1072
+ // If this alloc was blocking another alloc and transitioned to a
1073
+ // terminal state then start the blocked allocation
1074
+ c .blockedAllocsLock .Lock ()
1075
+ if blockedAlloc , ok := c .blockedAllocations [alloc .ID ]; ok && alloc .Terminated () {
1076
+ var prevAllocDir * allocdir.AllocDir
1077
+ if ar , ok := c .getAllocRunners ()[alloc .ID ]; ok {
1078
+ tg := alloc .Job .LookupTaskGroup (alloc .TaskGroup )
1079
+ if tg != nil && tg .EphemeralDisk != nil && tg .EphemeralDisk .Sticky {
1080
+ prevAllocDir = ar .GetAllocDir ()
1081
+ }
1082
+ }
1083
+ if err := c .addAlloc (blockedAlloc , prevAllocDir ); err != nil {
1084
+ c .logger .Printf ("[ERR] client: failed to add alloc which was previously blocked %q: %v" ,
1085
+ blockedAlloc .ID , err )
1086
+ }
1087
+ delete (c .blockedAllocations , blockedAlloc .PreviousAllocation )
1088
+ }
1089
+ c .blockedAllocsLock .Unlock ()
1090
+
1091
+ // Strip all the information that can be reconstructed at the server. Only
1092
+ // send the fields that are updatable by the client.
1073
1093
stripped := new (structs.Allocation )
1074
1094
stripped .ID = alloc .ID
1075
1095
stripped .NodeID = c .Node ().ID
1076
1096
stripped .TaskStates = alloc .TaskStates
1077
1097
stripped .ClientStatus = alloc .ClientStatus
1078
1098
stripped .ClientDescription = alloc .ClientDescription
1099
+
1079
1100
select {
1080
1101
case c .allocUpdates <- stripped :
1081
1102
case <- c .shutdownCh :
@@ -1096,22 +1117,6 @@ func (c *Client) allocSync() {
1096
1117
case alloc := <- c .allocUpdates :
1097
1118
// Batch the allocation updates until the timer triggers.
1098
1119
updates [alloc .ID ] = alloc
1099
-
1100
- // If this alloc was blocking another alloc and transitioned to a
1101
- // terminal state then start the blocked allocation
1102
- c .blockedAllocsLock .Lock ()
1103
- if blockedAlloc , ok := c .blockedAllocations [alloc .ID ]; ok && alloc .Terminated () {
1104
- var prevAllocDir * allocdir.AllocDir
1105
- if ar , ok := c .getAllocRunners ()[alloc .ID ]; ok {
1106
- prevAllocDir = ar .GetAllocDir ()
1107
- }
1108
- if err := c .addAlloc (blockedAlloc , prevAllocDir ); err != nil {
1109
- c .logger .Printf ("[ERR] client: failed to add alloc which was previously blocked %q: %v" ,
1110
- blockedAlloc .ID , err )
1111
- }
1112
- delete (c .blockedAllocations , blockedAlloc .PreviousAllocation )
1113
- }
1114
- c .blockedAllocsLock .Unlock ()
1115
1120
case <- syncTicker .C :
1116
1121
// Fast path if there are no updates
1117
1122
if len (updates ) == 0 {
@@ -1403,7 +1408,7 @@ func (c *Client) runAllocs(update *allocUpdates) {
1403
1408
// previous allocation
1404
1409
var prevAllocDir * allocdir.AllocDir
1405
1410
tg := add .Job .LookupTaskGroup (add .TaskGroup )
1406
- if tg != nil && tg .EphemeralDisk != nil && tg .EphemeralDisk .Sticky == true && ar != nil {
1411
+ if tg != nil && tg .EphemeralDisk != nil && tg .EphemeralDisk .Sticky && ar != nil {
1407
1412
prevAllocDir = ar .GetAllocDir ()
1408
1413
}
1409
1414
0 commit comments