Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ CREATE TYPE IF NOT EXISTS ess_api.entity_type (
CREATE TABLE IF NOT EXISTS ess_api.namespaces (
namespace text,
oauth_authorizations map<text, frozen<authorization>>, -- new primary column for tenant (non-notary) auths, oauth wins over ssa on read-merge
ssa_authorizations map<text, frozen<authorization>>, -- legacy column kept until all supported ESS versions stop selecting it
notary_authorizations map<text, frozen<authorization>>,
entity_types map<text, frozen<entity_type>>,
created_at timestamp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ INSERT INTO ess_api.namespaces (
updated_at,
entity_hash_size,
require_lwt_for_secret_version_writes,
ssa_authorizations,
notary_authorizations
)
VALUES (
Expand All @@ -14,5 +15,6 @@ VALUES (
toTimestamp(now()),
10,
False,
{'nvcf-api': {id: 'nvcf-api', name: 'nvcf api service client', jwks_url: 'http://openbao-server.vault-system.svc.cluster.local:8200/v1/services/ess-api/jwt/jwks', issuer: 'http://ess-api.ess.svc.cluster.local', type: 'SSA'}},
{'nvcf-api': {id: 'nvcf-api', name: 'nvcf notary client', jwks_url: 'http://notary.nvcf.svc.cluster.local:8080/.well-known/jwks.json', issuer: 'http://notary.nvcf.svc.cluster.local:8080', type: 'NOTARY'}}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- SSA registration unblocks nvct-api -> ess-api outbound calls, such as
-- nvct-api writing task secrets.
--
-- NOTARY registration unblocks ess-init -> ess-api secret reads from the
-- worker pod. ess-init presents the notary-signed assertion JWT with sub=
-- nvct-api, and ess-api looks the subject up in notary_authorizations.

UPDATE ess_api.namespaces
SET
ssa_authorizations = ssa_authorizations + {
Comment on lines +8 to +10

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Restore the column before this migration references it.

05_add_nvct_authorizations.up.sql runs before 09_restore_legacy_ssa_authorizations.up.sql. On clusters created with the OAuth-only schema, ssa_authorizations is absent at line 10, so this migration fails before migration 09 can add the column or seed either authorization map. Make this migration self-contained, or move the SSA update behind the schema-restoration step, and test the OAuth-only upgrade path.

🤖 Prompt for 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.

In `@migrations/cassandra/keyspaces/ess_api/05_add_nvct_authorizations.up.sql`
around lines 8 - 10, Make 05_add_nvct_authorizations.up.sql safe for OAuth-only
schemas by ensuring ssa_authorizations exists before the UPDATE that adds NVCT
authorizations, or defer that SSA update until
09_restore_legacy_ssa_authorizations.up.sql restores the column. Preserve both
authorization-map seeding paths and verify the migration ordering for OAuth-only
upgrades.

'nvct-api': {
id: 'nvct-api',
name: 'nvct api service client',
jwks_url: 'http://openbao-server.vault-system.svc.cluster.local:8200/v1/services/ess-api/jwt/jwks',
issuer: 'http://ess-api.ess.svc.cluster.local',
type: 'SSA'
}
},
notary_authorizations = notary_authorizations + {
'nvct-api': {
id: 'nvct-api',
name: 'nvct api notary client',
jwks_url: 'http://notary.nvcf.svc.cluster.local:8080/.well-known/jwks.json',
issuer: 'http://notary.nvcf.svc.cluster.local:8080',
type: 'NOTARY'
}
}
WHERE namespace = 'nvcf';
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- Keep 0.6.1 compatible with ESS images that still select the legacy
-- ssa_authorizations column while oauth_authorizations migration is in flight.
-- The column can be removed in a later release after all supported ESS images
-- stop selecting it.

ALTER TABLE ess_api.namespaces ADD IF NOT EXISTS (
ssa_authorizations map<text, frozen<authorization>>
);

UPDATE ess_api.namespaces
SET
ssa_authorizations = ssa_authorizations + {
'nvcf-api': {
id: 'nvcf-api',
name: 'nvcf api service client',
jwks_url: 'http://openbao-server.vault-system.svc.cluster.local:8200/v1/services/ess-api/jwt/jwks',
issuer: 'http://ess-api.ess.svc.cluster.local',
type: 'SSA'
},
'nvct-api': {
id: 'nvct-api',
name: 'nvct api service client',
jwks_url: 'http://openbao-server.vault-system.svc.cluster.local:8200/v1/services/ess-api/jwt/jwks',
issuer: 'http://ess-api.ess.svc.cluster.local',
type: 'SSA'
}
}
WHERE namespace = 'nvcf';
Loading