generate: key envMap by variable name rather than full env string#810
Open
crawfordxx wants to merge 1 commit into
Open
generate: key envMap by variable name rather than full env string#810crawfordxx wants to merge 1 commit into
crawfordxx wants to merge 1 commit into
Conversation
createEnvCacheMap was storing the full 'KEY=value' string as the map
key. addEnv looks entries up by just the variable name ('KEY'), so every
lookup missed and AddProcessEnv/RemoveProcessEnv always appended a new
entry instead of replacing the existing one.
Fix by extracting the name part (everything before the first '=') and
using that as the map key, consistent with how addEnv performs lookups.
Signed-off-by: crawfordxx <crawfordxx@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
createEnvCacheMapstores the entire env string (KEY=value) as the map key. TheaddEnvmethod looks entries up by just the variable name (KEY), so every lookup misses andAddProcessEnv/RemoveProcessEnvalways append a new entry rather than replacing the existing one. Callers that override a pre-existing environment variable silently get duplicate entries.Fix
Key
envMapby the variable name only (the part before the first=), which is whataddEnvand all callers expect.Impact
Downstream users such as containerd's NRI plugin (which calls
AddProcessEnv/RemoveProcessEnvto apply NRI container adjustments) are affected: env-var overrides for pre-existing container env vars are silently dropped.