Skip to content

fix: avoid metrics for migrating NAR during an already in-progress [backport #1079] - #1080

Merged
kalbasit merged 1 commit into
release-0.9from
backport-1079-to-release-0.9
Mar 12, 2026
Merged

kalbasit merged 1 commit into
release-0.9from
backport-1079-to-release-0.9

Conversation

@kalbasit

Copy link
Copy Markdown
Owner

Bot-based backport to release-0.9, triggered by a label in #1079.

When a NAR migration is already in-progress, do not log metrics and logs
as if the migration has succeeded.

…1079)

When a NAR migration is already in-progress, do not log metrics and logs
as if the migration has succeeded.

(cherry picked from commit 4ea3739)
@kalbasit
kalbasit enabled auto-merge (squash) March 12, 2026 22:27
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working go Pull requests that update go code labels Mar 12, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the handling of concurrent NAR (Nix Archive) migrations to chunks. Previously, if a migration was already in progress by another instance, the system would silently exit, potentially leading to misleading metrics and logs indicating a successful migration. The changes introduce a specific error to signal this condition, ensuring that subsequent attempts to migrate the same NAR correctly identify the ongoing process and avoid recording inaccurate success metrics or logs. This improves the accuracy of monitoring and prevents false positives regarding migration completion.

Highlights

  • New Error for Concurrent Migrations: Introduced "ErrMigrationInProgress" in "pkg/cache/cache.go" to explicitly signal when a NAR migration is already being handled by another instance.
  • Improved Concurrent Migration Handling: Modified "MigrateNarToChunks" to return "ErrMigrationInProgress" instead of "nil" when a migration is found to be already in progress, providing clearer error signaling.
  • Prevented Redundant Metrics and Logs: Updated "BackgroundMigrateNarToChunks" and the "migrateNarToChunks" function in "pkg/ncps" to check for "ErrMigrationInProgress" and prevent logging metrics or success messages for migrations already in progress.
Changelog
  • pkg/cache/cache.go
    • Added "ErrMigrationInProgress" error constant.
    • Modified "MigrateNarToChunks" to return "ErrMigrationInProgress" when a migration is already in progress.
    • Added a check for "ErrMigrationInProgress" in "BackgroundMigrateNarToChunks" to return early without logging metrics.
  • pkg/ncps/migrate_nar_to_chunks.go
    • Added a check for "cache.ErrMigrationInProgress" in the "migrateNarToChunks" function to prevent recording migration duration metrics.
Activity
  • No specific activity (comments, reviews, etc.) was found in the provided context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses an issue where a NAR migration already in progress was treated as a successful migration, leading to incorrect metrics and logs. By introducing a specific ErrMigrationInProgress error and handling it at the call sites, the changes ensure that such scenarios are correctly identified and skipped without being logged as successes or failures. The implementation is clean, targeted, and appears to be correct. I have no further suggestions.

@codecov

codecov Bot commented Mar 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 5.04%. Comparing base (45a2f3f) to head (a2cf1d0).
⚠️ Report is 1 commits behind head on release-0.9.

Additional details and impacted files
@@             Coverage Diff             @@
##           release-0.9   #1080   +/-   ##
===========================================
  Coverage         5.04%   5.04%           
===========================================
  Files                6       6           
  Lines              436     436           
===========================================
  Hits                22      22           
  Misses             410     410           
  Partials             4       4           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kalbasit
kalbasit merged commit f6d2242 into release-0.9 Mar 12, 2026
13 checks passed
@kalbasit
kalbasit deleted the backport-1079-to-release-0.9 branch March 12, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant