Conversation
|
Please provide unit tests to ensure your change fixes the issue. Thanks. |
pkg/chartutil/dependencies.go
Outdated
| md := *c.Metadata | ||
| deps := make([]*chart.Dependency, 0, len(md.Dependencies)) | ||
| for _, dep := range md.Dependencies { | ||
| dep := *dep |
There was a problem hiding this comment.
Why is this de-referencing the address, then re-assigning a new pointer? Wouldn't a copy be safer?
What happens when you provide a list of nil dependencies? Wouldn't that result in a stack trace when you attempt to de-reference nil? How should this code handle nil dependencies?
There was a problem hiding this comment.
A copy would not give us new Dependency structs.
We need new ones because their name are modified here which leaks on other Charts:
helm/pkg/chartutil/dependencies.go
Lines 139 to 146 in 9fafb4a
When you call getAliasDependency(c.Dependencies(), req) multiple time with the same req.Name, you get new Charts structs each time but their metadata.Dependencies are the same slice which come from the Chart in c.Dependencies() that match the Dependency (req).
Then we iterate over these dependencies (*chart.Chart) and call processDependencyEnabled()
helm/pkg/chartutil/dependencies.go
Lines 186 to 191 in 9fafb4a
At this point the dependencies generated by
getAliasDependency are now the pointer c.Then we iterate over
c.Metadata.Dependencies (and call again getAliasDependency) then replace req.Name with req.Alias. But c.Metadata.Dependencies is the slice return by getAliasDependency in the parent, which may be shared with another Chart as seen before.When the
processDependencyEnabled is called with such a Chart (same name but different alias), Dependency structs in c.Metadata.Dependencies have already their name changed to the alias and the following match do not work as expected:helm/pkg/chartutil/dependencies.go
Lines 130 to 133 in 9fafb4a
The only Chart dependencies that are kept are the one in
c.Dependencies, not in c.Metadata.Dependencies.
With a new slice and new structs for .metadata.Dependencies, the req.Name = req.Alias do not leaks on other Charts.
Not sure if I'm clear enough here, sorry 😕.
Charts.Dependencies are apparently not supposed to contains nil pointers as this line would panic on the req.Name in this case:
helm/pkg/chartutil/dependencies.go
Lines 130 to 132 in 9fafb4a
But I can add checks for nil if you prefer.
Signed-off-by: Valentin Flaux <vflaux@oui.sncf>
|
Just find that there is another PR for the same issue and with the same fix: #9175 |
imported values are stored in dependency objects, which breaks if a chart dependency is shared among multiple aliases. By copying the dependency objects in the metadata values can be imported correctly. Supersedes helm#10174 Signed-off-by: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com>
imported values are stored in dependency objects, which breaks if a chart dependency is shared among multiple aliases. By copying the dependency objects in the metadata values can be imported correctly. Supersedes helm#10174 Signed-off-by: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com>
imported values are stored in dependency objects, which breaks if a chart dependency is shared among multiple aliases. By copying the dependency objects in the metadata values can be imported correctly. Supersedes helm#10174 Signed-off-by: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com>
imported values are stored in dependency objects, which breaks if a chart dependency is shared among multiple aliases. By copying the dependency objects in the metadata values can be imported correctly. Supersedes helm#10174 Signed-off-by: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com>
imported values are stored in dependency objects, which breaks if a chart dependency is shared among multiple aliases. By copying the dependency objects in the metadata values can be imported correctly. Supersedes helm#10174 Signed-off-by: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com>
imported values are stored in dependency objects, which breaks if a chart dependency is shared among multiple aliases. By copying the dependency objects in the metadata values can be imported correctly. Supersedes helm#10174 Signed-off-by: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com>
imported values are stored in dependency objects, which breaks if a chart dependency is shared among multiple aliases. By copying the dependency objects in the metadata values can be imported correctly. Supersedes helm#10174 Signed-off-by: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com>
|
This pull request has been marked as stale because it has been open for 90 days with no activity. This pull request will be automatically closed in 30 days if no further activity occurs. |
imported values are stored in dependency objects, which breaks if a chart dependency is shared among multiple aliases. By copying the dependency objects in the metadata values can be imported correctly. Supersedes helm#10174 Signed-off-by: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com>
imported values are stored in dependency objects, which breaks if a chart dependency is shared among multiple aliases. By copying the dependency objects in the metadata values can be imported correctly. Supersedes helm#10174 Signed-off-by: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com>
imported values are stored in dependency objects, which breaks if a chart dependency is shared among multiple aliases. By copying the dependency objects in the metadata values can be imported correctly. Supersedes helm#10174 Signed-off-by: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com>
imported values are stored in dependency objects, which breaks if a chart dependency is shared among multiple aliases. By copying the dependency objects in the metadata values can be imported correctly. Supersedes helm#10174 Signed-off-by: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com>
What this PR does / why we need it:
There is an issue when you use a subchart more than once with alias and that this subchart also have a subchart.
In pkg/chartutil/dependencies.go, getAliasDependency() return a partial copy of the passed chart keeping the same slice for metadata.Dependencies. This results in metadata.Dependencies been shared by multiple Charts objects.
At some point processDependencyEnabled() changes the name of each dependencies by their alias. This impact others dependencies generated by getAliasDependency() and leads to processDependencyEnabled() to not correctly handles their dependencies (as it use the name to do so and the name is now the alias).
This patch make a copy of all the dependencies in a new slice to avoid this issue.
fix #10160
Special notes for your reviewer:
If applicable: