Skip to content

internal/exec/stages/files: fix wrong map key in unit preset duplicate check - #2291

Open
vishnu2ko5 wants to merge 1 commit into
coreos:mainfrom
vishnu2ko5:fix-units-preset-duplicate-check
Open

internal/exec/stages/files: fix wrong map key in unit preset duplicate check#2291
vishnu2ko5 wants to merge 1 commit into
coreos:mainfrom
vishnu2ko5:fix-units-preset-duplicate-check

Conversation

@vishnu2ko5

Copy link
Copy Markdown

What this PR does / why we need it:
This PR fixes a bug in the duplicate detection logic for systemd unit presets within the files stage.

Previously, when checking if a unit was already present in the presets map (to prevent conflicting enabled/disabled states for the same unit), the code incorrectly checked presets[unit.Name] instead of the dynamically constructed key (which is formatted as unitName-enabled or unitName-disabled). Because the bare unit name never exists as a key in the map, the duplicate check always evaluated to false. This effectively disabled the conflict detection entirely and made the error return path dead code.

This PR corrects the map lookup to use the proper key, restoring the intended protection against duplicate/conflicting unit declarations.

Fixes:
(Add the related issue number here if you opened an issue for this, e.g., Fixes #XYZ)

Special notes for your reviewer:

  • Verified that presets[key] is properly scoped and correctly identifies duplicate entries matching the fmt.Sprintf("%s-%s", unit.Name, identifier) pattern.

…e check

The duplicate check for systemd units incorrectly used the bare unit name
rather than the suffixed key, effectively disabling duplicate detection and
making the error path dead code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant