support path-scoped registry credentials#1109
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughRegistry credential matching is upgraded from host-only lookup to path-scope-based matching. Five new scope utility functions are added to ChangesPath-scoped registry credential matching
CLI Help Text Fix
Sequence Diagram(s)sequenceDiagram
participant Client
participant WorkflowSpec
participant common
participant PostgresConnector
participant RegistryAPI
Client->>WorkflowSpec: validate_registry(image_info, user, disabled_registries)
WorkflowSpec->>common: registry_scope_matches_image(disabled_scope, image_info)
alt any disabled scope matches
WorkflowSpec-->>Client: return None
else no match
WorkflowSpec->>RegistryAPI: registry_auth(url, empty credentials)
WorkflowSpec->>PostgresConnector: get_matching_registry_creds(user, image_info)
PostgresConnector->>common: matching_registry_scopes(image_info, all_scopes)
PostgresConnector-->>WorkflowSpec: [(scope, cred), ...]
loop each matching credential
WorkflowSpec->>RegistryAPI: registry_auth(url, username, token)
alt auth succeeds
WorkflowSpec-->>Client: return
end
end
WorkflowSpec-->>Client: raise OSMOCredentialError(image_scope)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1109 +/- ##
==========================================
+ Coverage 57.41% 57.50% +0.08%
==========================================
Files 211 211
Lines 26658 26707 +49
Branches 4046 4054 +8
==========================================
+ Hits 15306 15357 +51
+ Misses 10659 10654 -5
- Partials 693 696 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/utils/common.py`:
- Around line 459-465: The normalize_registry_scope() function needs to
canonicalize the default HTTPS port to match the behavior of
image_registry_scope(). After calling registry_parse() on the parsed netloc to
get the registry value, strip the explicit default port 443 (`:443`) from the
registry string before using it in the return statement. This ensures that
equivalent scopes like `registry.example.com:443/org` and
`registry.example.com/org` normalize to the same value and can be properly
matched.
In `@src/utils/connectors/postgres.py`:
- Around line 1562-1566: The bulk registry credential API returns raw
row.profile keys without normalization, causing inconsistency with the
single-item get_registry_cred() function which normalizes lookup keys. In the
dictionary comprehension that returns the registry credentials (in the section
showing row.profile as the key), normalize the row.profile value using the same
normalization logic applied in get_registry_cred() before using it as the
dictionary key. This ensures equivalent scopes behave consistently between
direct and bulk lookups and properly matches path-scoped credentials regardless
of whether persisted profiles are already in canonical form.
- Around line 1574-1579: Refactor this code to filter matching registry scopes
before decrypting credentials rather than decrypting all and filtering. Instead
of calling get_all_registry_creds(user) which decrypts every credential, first
get only the registry credential keys, use common.matching_registry_scopes() to
identify which scopes match the image_info, and then decrypt only those specific
matching credentials. This prevents unrelated bad credentials from failing valid
image auth paths and eliminates unnecessary decryption work.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: f835dd78-05d8-4c80-a9d4-e29a5289da8e
📒 Files selected for processing (10)
src/cli/credential.pysrc/lib/utils/common.pysrc/lib/utils/tests/test_common.pysrc/service/core/workflow/objects.pysrc/service/core/workflow/tests/test_helpers.pysrc/utils/connectors/postgres.pysrc/utils/job/task.pysrc/utils/job/tests/test_task.pysrc/utils/job/tests/test_workflow_helpers.pysrc/utils/job/workflow.py
Description
OSMO previously resolved Docker registry credentials using only the registry hostname. This prevented users from configuring separate credentials for different repository paths under the same registry host.
Issue #1113
This PR adds path-scoped registry credential support and aligns OSMO more closely with Kubernetes docker config matching behavior.
What Changed
dockerconfigjsonimage pull secrets to include all matching auth entries.Matching Behavior
For an image like:
These credential scopes match:
<registry-host>/team-b<registry-host>These credential scopes do not match:
<registry-host>/team-a<registry-host>/team-b/subpathThe generated docker config includes all matching credentials, ordered most-specific first.
Testing
Bazel Tests
bazel test \ //src/lib/utils/tests:test_common \ //src/utils/job/tests:test_task_pure \ //src/utils/job/tests:test_task \ //src/utils/job/tests:test_workflow_helpers \ //src/service/core/workflow/tests:test_helpers \ //src/cli/tests:test_credentialResult:
Manual CLI Validation
Using the Bazel-built CLI, created multiple registry credentials under the same host:
Then verified:
This validates that OSMO now stores path-scoped registry credentials separately and resolves only path-segment-compatible credentials for image validation and image pull secret generation.
Checklist
Summary by CodeRabbit
New Features
Documentation