Skip to content

feat(storage): support DynamoDB tablenamePrefix for cache driver#4016

Open
AkashKumar7902 wants to merge 1 commit into
project-zot:mainfrom
AkashKumar7902:feat/dynamodb-tablename-prefix
Open

feat(storage): support DynamoDB tablenamePrefix for cache driver#4016
AkashKumar7902 wants to merge 1 commit into
project-zot:mainfrom
AkashKumar7902:feat/dynamodb-tablename-prefix

Conversation

@AkashKumar7902

Copy link
Copy Markdown
Contributor

What type of PR is this?

feature

Which issue does this PR fix: #2966

What does this PR do / Why do we need it:

Adds a new tablenamePrefix option to the dynamodb cache driver so administrators can configure all DynamoDB table names with a single prefix instead of declaring each table individually.

When tablenamePrefix is set, zot derives the following table names automatically:

Purpose Derived name (with "tablenamePrefix": "Zot")
Dedupe blob cache ZotBlobTable
Repo metadata ZotRepoMetadataTable
Repo blobs info ZotRepoBlobsInfoTable
Image metadata ZotImageMetaTable
User data ZotUserDataTable
API key ZotApiKeyDataTable
Schema version ZotVersionTable

Explicit per-table options (cacheTablename, repoMetaTablename, etc.) continue to take precedence, so existing configurations keep working unchanged.

Example new config:

"cacheDriver": {
    "name": "dynamodb",
    "endpoint": "http://localhost:4566",
    "region": "us-east-2",
    "tablenamePrefix": "Zot"
}

If an issue # is not available please add repro steps and logs showing the issue:

N/A — issue #2966 is open with the feature request.

Testing done on this change:

  • Added unit tests in pkg/storage/cache_internal_test.go covering: derivation from prefix, explicit name precedence, missing/empty/non-string prefix, and missing/empty/non-string explicit table name.
  • Added unit tests in pkg/meta/meta_internal_test.go covering the equivalent cases for the metadata tables.
  • go test ./pkg/storage/ ./pkg/meta/ passes.
  • golangci-lint run ./pkg/storage/... ./pkg/meta/... reports 0 issues.
  • examples/config-dynamodb.json was simplified to use the new tablenamePrefix and validated via the unit tests.

Automation added to e2e:

No new e2e cases. The existing search/auth e2e suite still exercises explicit per-table configuration, which the new code path preserves verbatim.

Will this break upgrades or downgrades?

No. Existing configurations that use explicit table names continue to work because explicit names always take precedence over the derived prefix. Older zot versions ignore the new tablenamePrefix field.

Does this PR introduce any user-facing change?:

Yes — administrators can configure DynamoDB tables via a single tablenamePrefix instead of seven individual table-name fields.

DynamoDB cache driver now supports a `tablenamePrefix` option that derives all required table names (`<prefix>BlobTable`, `<prefix>RepoMetadataTable`, `<prefix>RepoBlobsInfoTable`, `<prefix>ImageMetaTable`, `<prefix>UserDataTable`, `<prefix>ApiKeyDataTable`, `<prefix>VersionTable`) from a single prefix. Explicit per-table options still take precedence.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Add a tablenamePrefix option to the dynamodb cacheDriver so administrators can
configure all DynamoDB table names with a single prefix instead of declaring
each table individually. Explicit per-table names continue to override derived
names for backward compatibility.

Fixes project-zot#2966

Signed-off-by: Akash Kumar <meakash7902@gmail.com>
@AkashKumar7902 AkashKumar7902 force-pushed the feat/dynamodb-tablename-prefix branch from 02e8ebe to 4c1290e Compare April 29, 2026 21:56
@rchincha

rchincha commented May 1, 2026

Copy link
Copy Markdown
Contributor

I like this change for better ux but concern is whether this is a breaking change.

@rchincha rchincha added this to the v2.1.17 milestone May 1, 2026
@codecov

codecov Bot commented May 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.49%. Comparing base (993a17f) to head (4c1290e).
⚠️ Report is 33 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4016      +/-   ##
==========================================
+ Coverage   91.47%   91.49%   +0.02%     
==========================================
  Files         197      197              
  Lines       28353    28413      +60     
==========================================
+ Hits        25935    25997      +62     
+ Misses       1565     1563       -2     
  Partials      853      853              

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rchincha

rchincha commented May 3, 2026

Copy link
Copy Markdown
Contributor

I wouldn't drop support for earlier config. I would add this new behavior as an addendum. It is always useful to have the older way to override defaults.

DynamoDBUserDataSuffix = "UserDataTable"
DynamoDBAPIKeySuffix = "ApiKeyDataTable"
DynamoDBVersionSuffix = "VersionTable"
RedisLocksBucket = "locks"

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.

Restore this before the new entries. Will make the patch a lot cleaner.

@rchincha rchincha modified the milestones: v2.1.17, v2.1.18 May 12, 2026
@rchincha rchincha modified the milestones: v2.1.18, v2.1.19 Jun 12, 2026
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.

2 participants