-
Notifications
You must be signed in to change notification settings - Fork 299
*: fixed broken template and metadata #1520
*: fixed broken template and metadata #1520
Conversation
|
Great catch, and gross. |
2d2f4f0 to
bbea486
Compare
|
Added test and it has failed. Now, let's apply the fix... |
416ac85 to
1c96e6a
Compare
|
@jonboulle done |
job/job.go
Outdated
| values[i] = unitPrintf(v, *uni) | ||
| processedValues := make([]string, len(values)) | ||
|
|
||
| for i, v := range values { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kayrus thanks for the catch! you can put this inside the same previous loop:
if uni != nil { processedvalues := make() for ... { ...} requirements[key] = processedvalues } else { requirements[key] = values }
Otherwise it's ok too!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
@kayrus perhaps also improve the commit log of the 4th patch (the fix), same wording as for this PR ? otherwise lgtm. Thank you! |
1c96e6a to
0a13c7b
Compare
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.
0a13c7b to
a23ce6f
Compare
|
@jonboulle lgtm, thanks! |
|
@jonboulle I suppose we have to show that the issue is covered by tests, and then fix it. so from my point of view the commit order is fine |
Resolves #1514
The problem was caused by the code optimization. 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 byrequirements()function, its content was modified byvalues[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.Now we don't modify source contents.