Skip to content

feat: include target path hash in generated file names to prevent naming collisions#511

Open
ShantKhatri wants to merge 4 commits into
score-spec:mainfrom
ShantKhatri:fix/issue-506
Open

feat: include target path hash in generated file names to prevent naming collisions#511
ShantKhatri wants to merge 4 commits into
score-spec:mainfrom
ShantKhatri:fix/issue-506

Conversation

@ShantKhatri

Copy link
Copy Markdown
Contributor

Description

This PR updates the host filename generation logic in convertFilesIntoVolumes() to ensure strict uniqueness for injected container files.

Previously, the host filename was generated using only the workload name and the file's basename (%s-files-%s). This PR updates the format to include both the container name and an 8-character SHA-256 hash of the full target path: fmt.Sprintf("%s-%s-files-%s-%s", workloadName, containerName, hash[:8], filepath.Base(target))

All associated tests have been updated to expect this new filename format.

What does this PR do?

This change is required because the previous logic caused two severe silent overwrite bugs on the host filesystem:

  1. Intra-container collision: If a single container mounted /etc/app/config.yaml and /opt/app/config.yaml, the identical basenames caused them to resolve to the same host filename and silently overwrite each other.
  2. Cross-container collision: If a web container and a worker container both mounted a file to /etc/config.yaml, the absence of the container name in the host filename caused them to silently overwrite each other.

By combining the container name and the path hash, we guarantee that no two file mounts will ever generate the same host filename, while keeping the basename visible for human readability when debugging.

Fixes #506

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • New chore (expected functionality to be implemented)

Checklist:

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • I've signed off with an email address that matches the commit author.

…ing collisions

Signed-off-by: Prashantkumar Khatri <khatri2105104@st.jmi.ac.in>
…ross container collisions

Signed-off-by: Prashantkumar Khatri <khatri2105104@st.jmi.ac.in>
@ShantKhatri ShantKhatri marked this pull request as draft June 19, 2026 12:21
Signed-off-by: Prashantkumar Khatri <khatri2105104@st.jmi.ac.in>
@ShantKhatri ShantKhatri force-pushed the fix/issue-506 branch 2 times, most recently from fa41169 to 90b5b34 Compare June 19, 2026 12:53
@ShantKhatri ShantKhatri marked this pull request as ready for review June 19, 2026 13:12
@ShantKhatri

Copy link
Copy Markdown
Contributor Author

Hi @mathieu-benoit @chris-stephenson , I wanna mention that previously, if two different containers (e.g., web and worker) in the same workload mounted a file to the exact same target path (e.g., /etc/config.yaml), their host files would silently overwrite each other because the container name was excluded from the filename generation.

By injecting both the containerName and the target path hash (%s-%s-files-%s-%s), this PR guarantees strict uniqueness for both intra-container and cross-container file mounts. Happy to hear any feedback or suggestions on this!

Note: This PR also fixes a related cross-container collision bug.

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.

[bug] file mount collision on identical basenames in same workload

1 participant