Skip to content

feat: report narinfo storage deprecated and must be migrated [backport #961] - #964

Merged
kalbasit merged 1 commit into
release-0.9from
backport-961-to-release-0.9
Feb 22, 2026
Merged

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

Conversation

@kalbasit

Copy link
Copy Markdown
Owner

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

The narinfo stored in the storage is deprecated and this is the last
release that will support their migration from storage to the database.
Include this messaging in the next release so I can clean up the code in
the following one.

The narinfo stored in the storage is deprecated and this is the last
release that will support their migration from storage to the database.
Include this messaging in the next release so I can clean up the code in
the following one.

(cherry picked from commit e32ee09)
@kalbasit
kalbasit enabled auto-merge (squash) February 22, 2026 21:45
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request go Pull requests that update go code labels Feb 22, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @kalbasit, 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 introduces a crucial user-facing warning mechanism to inform administrators about the impending deprecation of file-based narinfo storage. It ensures that users are aware of the need to migrate their narinfo data to the database before the next release, preventing potential data loss or service disruption. The changes also enhance S3 storage flexibility by adding prefix support and improve code structure with new constants.

Highlights

  • Deprecation Warning for Narinfo Storage: Implemented checks in both local and S3 storage initialization to detect the presence of file-based narinfo directories. If detected, a warning message is logged, informing users that file-based narinfo storage is deprecated and will be removed in the next release, along with instructions to migrate to the database.
  • New Storage Constants: Introduced new constants for storageType (local, s3) and storageMode (cdc, whole) to improve code clarity and maintainability. These constants are now used when setting ncps.storage_type and ncps.storage_mode attributes.
  • S3 Storage Prefix Support: Added a Prefix field to the S3 configuration and integrated it into the S3 store's key generation logic. This allows all objects stored in an S3 bucket to be placed under a specified prefix, enhancing organization and multi-tenancy capabilities.
  • Narinfo Directory Existence Check: Added HasNarinfoDir methods to both local and S3 storage implementations. These methods efficiently check for the existence of the narinfo directory (or objects under the narinfo prefix for S3) to facilitate the deprecation warning.
  • Comprehensive Testing for Narinfo Directory Check: Included new unit and integration tests for the HasNarinfoDir functionality in both local and S3 storage, covering cases where the directory exists, is empty, or does not exist, and handling error paths for S3.
Changelog
  • pkg/ncps/serve.go
    • Added storageTypeLocal, storageTypeS3, storageModeCDC, and storageModeWhole constants.
    • Implemented a check for existing local narinfo directories during local storage creation and logged a warning if found.
    • Implemented a check for existing S3 narinfo directories during S3 storage creation and logged a warning if found.
    • Updated detectExtraResourceAttrs to use the new storageType and storageMode constants for attributes.
  • pkg/s3/config.go
    • Added a Prefix field to the Config struct to allow specifying an S3 key prefix.
  • pkg/storage/local/local.go
    • Added HasNarinfoDir method to check for the existence of the local narinfo directory.
  • pkg/storage/local/local_test.go
    • Added TestHasNarinfoDir with subtests for cases where the narinfo directory does not exist, exists empty, and exists with files.
  • pkg/storage/s3/s3.go
    • Added a prefix field to the Store struct.
    • Initialized the prefix field in the New function from the S3 configuration.
    • Updated WalkNarInfos to use s.storeNarInfoPath() for constructing the prefix.
    • Added HasNarinfoDir method to efficiently check for the existence of objects under the narinfo prefix in S3.
    • Modified secretKeyPath, storeNarInfoPath, and narPath methods to incorporate the s.prefix for key generation.
  • pkg/storage/s3/s3_test.go
    • Imported the regexp package.
    • Added sanitizePrefix helper function to clean test names for use as S3 prefixes.
    • Applied a sanitized test name as a prefix to the S3 test configuration.
    • Added TestHasNarinfoDir_ErrorPaths to test error handling for ListObjects.
    • Added TestHasNarinfoDir_Integration with subtests for empty and existing narinfo prefixes.
Activity
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. ↩

@dosubot

dosubot Bot commented Feb 22, 2026

Copy link
Copy Markdown

Related Documentation

Checked 6 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@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 introduces a deprecation warning for file-based narinfo storage, guiding users towards database migration. It correctly adds checks for legacy narinfo directories in both local and S3 storage, logging a helpful warning message. Additionally, it introduces support for an S3 prefix, which is a valuable feature for organizing data within a bucket. The changes are well-implemented and include corresponding tests. The suggestion to refactor the S3 path prefixing logic to improve code clarity and maintainability remains valid.

Comment thread pkg/storage/s3/s3.go
Comment on lines 596 to 610
func (s *Store) secretKeyPath() string {
return "config/cache.key"
if s.prefix == "" {
return "config/cache.key"
}

return s.prefix + "/config/cache.key"
}

func (s *Store) storeNarInfoPath() string {
if s.prefix == "" {
return "store/narinfo"
}

return s.prefix + "/store/narinfo"
}

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.

medium

To reduce code duplication when prepending the S3 prefix, you can use path.Join. This function correctly handles joining path segments, including when the prefix is empty.

You can apply a similar simplification to the narPath function as well.

Suggested change
func (s *Store) secretKeyPath() string {
return "config/cache.key"
if s.prefix == "" {
return "config/cache.key"
}
return s.prefix + "/config/cache.key"
}
func (s *Store) storeNarInfoPath() string {
if s.prefix == "" {
return "store/narinfo"
}
return s.prefix + "/store/narinfo"
}
func (s *Store) secretKeyPath() string {
return path.Join(s.prefix, "config/cache.key")
}
func (s *Store) storeNarInfoPath() string {
return path.Join(s.prefix, "store/narinfo")
}

@codecov

codecov Bot commented Feb 22, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@             Coverage Diff             @@
##           release-0.9    #964   +/-   ##
===========================================
  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 97ac9fa into release-0.9 Feb 22, 2026
13 checks passed
@kalbasit
kalbasit deleted the backport-961-to-release-0.9 branch February 22, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant