Skip to content

Commit

Permalink
*: Prevented unit's Contents modification
Browse files Browse the repository at this point in the history
Resolves coreos#1514

The problem was caused by the [code optimization](coreos#1376). Before that each unit was stored in its own variable. Then this code was optimized and units became stored in hash map (`getAllUnitsHashMap`). Each hash was assigned to the unit's pointer. And when template unit was checked by `requirements()` function, its content was modified by `values[i] = unitPrintf(v, *uni)` code. Once templated unit was modified, all related units (which have same hash) were modified too, because they are related to one pointer.
  • Loading branch information
kayrus committed Mar 31, 2016
1 parent 9b54b9f commit b130ebc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,14 @@ func (j *Job) requirements() map[string][]string {
}

if uni != nil {
processedValues := make([]string, len(values))
for i, v := range values {
values[i] = unitPrintf(v, *uni)
processedValues[i] = unitPrintf(v, *uni)
}
requirements[key] = processedValues
} else {
requirements[key] = values
}
requirements[key] = values
}

return requirements
Expand Down

0 comments on commit b130ebc

Please sign in to comment.