@@ -1069,17 +1069,23 @@ 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
+ select {
1073
+ case c .allocUpdates <- alloc :
1074
+ case <- c .shutdownCh :
1075
+ }
1076
+ }
1077
+
1078
+ // stripAllocation strips the allocation of fields which can be re-assembled in
1079
+ // the server.
1080
+ func (c * Client ) stripAllocation (alloc * structs.Allocation ) * structs.Allocation {
1073
1081
stripped := new (structs.Allocation )
1074
1082
stripped .ID = alloc .ID
1075
1083
stripped .NodeID = c .Node ().ID
1076
1084
stripped .TaskStates = alloc .TaskStates
1077
1085
stripped .ClientStatus = alloc .ClientStatus
1078
1086
stripped .ClientDescription = alloc .ClientDescription
1079
- select {
1080
- case c .allocUpdates <- stripped :
1081
- case <- c .shutdownCh :
1082
- }
1087
+
1088
+ return stripped
1083
1089
}
1084
1090
1085
1091
// allocSync is a long lived function that batches allocation updates to the
@@ -1103,7 +1109,10 @@ func (c *Client) allocSync() {
1103
1109
if blockedAlloc , ok := c .blockedAllocations [alloc .ID ]; ok && alloc .Terminated () {
1104
1110
var prevAllocDir * allocdir.AllocDir
1105
1111
if ar , ok := c .getAllocRunners ()[alloc .ID ]; ok {
1106
- prevAllocDir = ar .GetAllocDir ()
1112
+ tg := alloc .Job .LookupTaskGroup (alloc .TaskGroup )
1113
+ if tg != nil && tg .EphemeralDisk .Sticky {
1114
+ prevAllocDir = ar .GetAllocDir ()
1115
+ }
1107
1116
}
1108
1117
if err := c .addAlloc (blockedAlloc , prevAllocDir ); err != nil {
1109
1118
c .logger .Printf ("[ERR] client: failed to add alloc which was previously blocked %q: %v" ,
@@ -1120,7 +1129,9 @@ func (c *Client) allocSync() {
1120
1129
1121
1130
sync := make ([]* structs.Allocation , 0 , len (updates ))
1122
1131
for _ , alloc := range updates {
1123
- sync = append (sync , alloc )
1132
+ // Only send the fields that are updatable by the client.
1133
+ stripped := c .stripAllocation (alloc )
1134
+ sync = append (sync , stripped )
1124
1135
}
1125
1136
1126
1137
// Send to server.
@@ -1393,7 +1404,7 @@ func (c *Client) runAllocs(update *allocUpdates) {
1393
1404
// previous allocation
1394
1405
var prevAllocDir * allocdir.AllocDir
1395
1406
tg := add .Job .LookupTaskGroup (add .TaskGroup )
1396
- if tg != nil && tg .EphemeralDisk != nil && tg .EphemeralDisk .Sticky == true && ar != nil {
1407
+ if tg != nil && tg .EphemeralDisk != nil && tg .EphemeralDisk .Sticky && ar != nil {
1397
1408
prevAllocDir = ar .GetAllocDir ()
1398
1409
}
1399
1410
0 commit comments