← Back to issue list

fix: migrate overlay files before running stage or prime

View original Github issue

Metadata

Project
craft-parts
Number
#1617
Type
pull request
State
merged
Author
tigarmo
Labels
Created
Updated
Closed

Current evaluation

Merged fix that migrates overlay files before stage or prime steps. Resolves a state tracking bug causing priming failures with symlinks. Approved by reviewers and passed all CI checks.

Suggested action:

No scores available.

Issue body

This commit switches the order of calling _run_step() and _migrate_overlay* so that the overlay migration always happens *before* the default step behavior. This is the desired behavior, but the previous code had a corner-case when a part has content coming from both 'build' and 'overlay', like this: ```yaml parts: p1: override-build: | mkdir ${CRAFT_PART_INSTALL}/my-dir override-overlay: | mkdir my-dir touch my-dir/my-file ``` ... in this situation, the previous code would *first* stage the `my-dir`directory coming from `override-build` and *then* migrate `my-dir` and `my-dir/my-file` from the overlay to stage. Because of the way the migration happens, the `my-dir` dir coming from build would "shadow" the `my-dir` dir coming from stage, which meant the migrate state would *not* record `my-dir` as coming from the overlay. This is a bug in and of itself but it was usually harmless. A failure happens if another, separate part gets primed *before* `p1`. In that case, we would try to do the migration of overlay contents from stage to prime, which in this case meant migrating the `my-dir/my-file` file but **not** the `my-dir` dir because it did not get recorded. Then, the migration of `my-dir/my-file` would *maybe* work: - if `my-file` is a regular file, the code would follow a path that recreates the directory structure to hardlink the file (to save storage); - if `my-file` is a special file like a symlink the code would try to copy it to `${prime}/my-dir/`, which doesn't exist. Then a failure happens with a cryptic message that suggests that `${stage}/my-dir/my-file` doesn't exist, but this is just bad formatting of the error message. In my view the main cause of this bug is the fact that overlay files are not correctly recorded in the state file - I added a test to check this scenario and I think it's sufficient to validate this particular bugfix. ---

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Merged fix that migrates overlay files before stage or prime steps. Resolves a state tracking bug causing priming failures with symlinks. Approved by reviewers and passed all CI checks.
qwen3.6-35b-a3b-mtp-q6 Fixed overlay migration order to precede stage and prime steps, resolving a bug where overlay contents were shadowed by build artifacts and caused prime failures. Merged with a validation test.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#1619 fix: migrate overlay files before running stage or prime (#1617) craft-parts merged Merged cherry-pick of canonical/craft-parts#1617. Resolves changelog conflicts and migrates overlay files before stage or prime execution. Approved by two reviewers and merged following CI validation.
85%
#1123 fix: Prime content from overlay when split into partitions craft-parts merged Merged fix for priming overlay content when split into partitions. Replaces direct overlay reliance with stage directory and migration state. Approved by three reviewers, passed all CI checks, and resolves issue #1127.
82%
#121 overlay: migrate overlay data to stage and prime (CRAFT-468, CRAFT-82) craft-parts merged Merged after two approvals and CI. Migrates overlay data to stage and prime, translates overlayfs whiteouts and opaque directories to OCI, and cleans shared areas. Collision detection is deferred.
79%
#1190 fix(overlay): detect conflicts between overlay and install craft-parts merged Merged fix enhancing Stage step collision detection to account for overlay contents, preventing conflicts with install directories. Includes integration tests, passed all CI checks, and received approval from three reviewers.
74%
#1618 fix: handle dependencies when organizing to overlay craft-parts merged Merged following approval and successful CI checks. Resolves dependency ordering during overlay organization by prioritizing BUILD steps over dependency STAGE steps, fixing issue #1611. Code was rebased on main prior to integration.
72%
#834 fix: use partitions for stage-packages tracking craft-parts merged Merged to fix issue #804. The change updates stage-package tracking to scan primed files per partition, resolving failures in common partitioned setups. Multi-partition tracking still requires deeper refactoring. Approved by three reviewers and passed CI.
71%
#1670 Change file migrations such that files move from stage to prime rather than coming from the part each time snapcraft closed Closed as obsolete. The stage-to-prime migration redesign is unnecessary since the stage filter now inherits to prime. Maintainer closed the issue and recommended filing a separate bug for hard link concerns.
71%
#1579 fix(state): track override-overlay changes craft-parts merged Merged fix for #1566 that tracks override-overlay changes in OverlayState.properties_of_interest() for consistent dirty checks. Approved by two reviewers, passed CI except unrelated OSV-scanner warnings, and includes focused unit tests.
70%