Skip to content

fix(linglong): stop migration clobbering refs and mis-ordering versions - #2149

Open
Metastarx wants to merge 2 commits into
OpenAtom-Linyaps:masterfrom
Metastarx:patch/libs-linglong-src-linglong-repo-migrate-
Open

Metastarx wants to merge 2 commits into
OpenAtom-Linyaps:masterfrom
Metastarx:patch/libs-linglong-src-linglong-repo-migrate-

Conversation

@Metastarx

Copy link
Copy Markdown

Summary

The legacy ref migration in libs/linglong/src/linglong/repo/migrate.cpp could corrupt already-migrated refs. The dedup step appended each legacy ref onto one shared prefix string, and because std::string::append mutates its receiver, every lookup after the first used a key that could never exist; refs whose stable: counterpart was already present were migrated again and the existing commits (and their layer symlinks) were overwritten. The same file's version comparison was not lexicographic either, so 2.0.0 sorted below 1.7.0 and a repository newer than 1.7.0 could re-run the legacy migration. I rebuilt the lookup key from a fresh, const prefix on every iteration and replaced the comparison with a component-by-component lexicographic order, then added regression tests for an all-prefixed repository, a partial migration, and a 2.0.0 version file that must skip the migration.

Changes

libs/linglong/src/linglong/repo/migrate.cpp        |  33 +++-
 .../ll-tests/src/linglong/repo/migrate_test.cpp    | 210 +++++++++++++++++++++
 2 files changed, 240 insertions(+), 3 deletions(-)

Verification

ctest --test-dir build-release --output-on-failure - passed (100% tests passed, 0 tests failed out of 738)

Checklist

  • I ran the verification described above
  • The change is minimal and includes no unrelated files
  • The repository contribution guidelines were followed

Copilot AI balanced review requested due to automatic review settings October 8, 2026 17:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

Hi @Metastarx. Thanks for your PR.

I'm waiting for a OpenAtom-Linyaps member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

The already-migrated check built its lookup key with std::string::append on a
single shared buffer. append mutates its receiver and returns it, so the
repository prefix accumulated one ref per loop iteration and every lookup after
the first used a key that can never exist. Such a ref was migrated a second
time, and ostree_repo_transaction_set_ref pointed the prefixed ref at the stale
legacy commit, overwriting the commit and the layer symlink that were already
there.

Version::operator< also evaluated minor and patch even when a more significant
component already differed, so 2.0.0 compared less than 1.7.0. The 1.7.0 gate
in dispatchMigrations relies on this being a real ordering, otherwise a
repository newer than 1.7.0 could re-run the legacy migration.

Signed-off-by: zhang hongyuan <100520587+Metastarx@users.noreply.github.com>
The license check requires the year range to span the last modification, so a
file created in 2024 and touched in 2026 has to read 2024-2026.  This is the
only file the check flagged on this branch; the new test file already carries
2026.

Signed-off-by: zhang hongyuan <100520587+Metastarx@users.noreply.github.com>
@Metastarx
Metastarx force-pushed the patch/libs-linglong-src-linglong-repo-migrate- branch from 2aa4ebb to bb5d925 Compare October 12, 2026 08:52
@Metastarx Metastarx changed the title Fix legacy ref migration clobbering and version comparison fix(linglong): stop migration clobbering refs and mis-ordering versions Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants