@@ -20,65 +20,56 @@ export const NO_CEPH_CREDENTIALS = "NO_CEPH_CREDENTIALS" as const
2020function resolveS3Config ( ctx : AuroraPortalContext ) : { endpoint : string ; region : string } {
2121 try {
2222 const service = ctx . openstack ?. service ( "ceph" )
23- const endpoint = service ?. getEndpoint ?.( )
24-
25- if ( endpoint ) {
26- // Extract base URL by removing Swift path suffix.
27- // Ceph RGW serves both Swift and S3 APIs on the same host but different paths:
28- // Swift: https://rgw.st1.qa-de-1.cloud.sap/swift/v1/AUTH_xxx
29- // S3: https://rgw.st1.qa-de-1.cloud.sap
30- const swiftIndex = endpoint . indexOf ( "/swift/" )
31- const baseEndpoint = swiftIndex !== - 1 ? endpoint . substring ( 0 , swiftIndex ) : endpoint
32-
33- const token = ctx . openstack ?. getToken ?.( )
34-
35- if ( ! token ?. tokenData ?. catalog ) {
36- throw new Error ( "OpenStack token or service catalog not available" )
37- }
38-
39- // Find Ceph service in catalog by checking common type/name patterns
40- const cephService = token . tokenData . catalog . find (
41- ( s ) => s . type === "ceph" || s . name === "ceph" || s . type === "object-store" || s . type === "object-store-ceph"
42- )
43-
44- if ( ! cephService ) {
45- throw new Error ( "Ceph service not found in OpenStack service catalog" )
46- }
47-
48- const openstackRegion = cephService . endpoints ?. [ 0 ] ?. region
49-
50- if ( ! openstackRegion ) {
51- throw new Error ( "Region not found in Ceph service endpoints" )
52- }
53-
54- // Construct Ceph-compatible region identifier using the pattern from Go SDK / Terraform.
55- // Standard format: ceph-objectstore-st1-{region} (e.g., ceph-objectstore-st1-eu-de-2)
56- // Exception: qa-de-1 uses "ec" prefix for historical reasons (ceph-objectstore-ec-st1-qa-de-1)
57- //
58- // This identifier is used for:
59- // 1. AWS Signature V4 request signing (region field in Authorization header)
60- // 2. LocationConstraint in CreateBucket API calls
61- //
62- // See: https://documentation.global.cloud.sap/docs/customer/storage/obj-v2-ceph/ceph-storage-options/
63- const QA_DE_1_REGION = "qa-de-1"
64- const CEPH_REGION_PREFIX_STANDARD = "ceph-objectstore-st1"
65- const CEPH_REGION_PREFIX_EC = "ceph-objectstore-ec-st1"
66-
67- const region =
68- openstackRegion === QA_DE_1_REGION
69- ? `${ CEPH_REGION_PREFIX_EC } -${ openstackRegion } `
70- : `${ CEPH_REGION_PREFIX_STANDARD } -${ openstackRegion } `
71-
72- return { endpoint : baseEndpoint , region }
23+
24+ if ( ! service ) {
25+ throw new Error ( "Ceph service not found in OpenStack service catalog" )
26+ }
27+
28+ const endpoint = service . getEndpoint ?.( )
29+
30+ if ( ! endpoint ) {
31+ throw new Error ( "Ceph service endpoint not found in catalog. Ensure the Ceph service is registered in OpenStack." )
32+ }
33+
34+ // Extract base URL by removing Swift path suffix.
35+ // Ceph RGW serves both Swift and S3 APIs on the same host but different paths:
36+ // Swift: https://rgw.st1.qa-de-1.cloud.sap/swift/v1/AUTH_xxx
37+ // S3: https://rgw.st1.qa-de-1.cloud.sap
38+ const swiftIndex = endpoint . indexOf ( "/swift/" )
39+ const baseEndpoint = swiftIndex !== - 1 ? endpoint . substring ( 0 , swiftIndex ) : endpoint
40+
41+ const endpoints = service . availableEndpoints ?.( )
42+ const openstackRegion = endpoints ?. [ 0 ] ?. region
43+
44+ if ( ! openstackRegion ) {
45+ throw new Error ( "Region not found in Ceph service endpoints" )
7346 }
47+
48+ // Construct Ceph-compatible region identifier using the pattern from Go SDK / Terraform.
49+ // Standard format: ceph-objectstore-st1-{region} (e.g., ceph-objectstore-st1-eu-de-2)
50+ // Exception: qa-de-1 uses "ec" prefix for historical reasons (ceph-objectstore-ec-st1-qa-de-1)
51+ //
52+ // This identifier is used for:
53+ // 1. AWS Signature V4 request signing (region field in Authorization header)
54+ // 2. LocationConstraint in CreateBucket API calls
55+ //
56+ // See: https://documentation.global.cloud.sap/docs/customer/storage/obj-v2-ceph/ceph-storage-options/
57+ const QA_DE_1_REGION = "qa-de-1"
58+ const CEPH_REGION_PREFIX_STANDARD = "ceph-objectstore-st1"
59+ const CEPH_REGION_PREFIX_EC = "ceph-objectstore-ec-st1"
60+
61+ const region =
62+ openstackRegion === QA_DE_1_REGION
63+ ? `${ CEPH_REGION_PREFIX_EC } -${ openstackRegion } `
64+ : `${ CEPH_REGION_PREFIX_STANDARD } -${ openstackRegion } `
65+
66+ return { endpoint : baseEndpoint , region }
7467 } catch ( error ) {
7568 console . error ( "[ceph] Failed to resolve Ceph service from catalog:" , error )
7669 throw new Error ( "Ceph service not found in catalog. Ensure the Ceph service is registered in OpenStack." , {
7770 cause : error ,
7871 } )
7972 }
80-
81- throw new Error ( "Ceph service endpoint not found in catalog. Ensure the Ceph service is registered in OpenStack." )
8273}
8374
8475/**
0 commit comments