Skip to content

Commit

Permalink
[Misc] Operator: provider tenant context fixed
Browse files Browse the repository at this point in the history
Add `subscribedSubaccountId` (that falls back to tenantId) for provider
tenant creation.
This seems to be needed by some cap / hana apis.
  • Loading branch information
Pavan-SAP committed May 29, 2024
1 parent 6ab9dfc commit ed55e37
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/controller/reconcile-capapplication.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,12 @@ func (c *Controller) reconcileCAPApplicationProviderTenant(ctx context.Context,
}

// Create a secret with the provider subscription context (dervied from the spec of CAPApplication)
// Try to get the provider subaccount id from the annotations
providerSubAccountId := ca.Annotations[AnnotationProviderSubAccountId]
// If no provider subaccount id annotation is found use provider tenantId that is needed because some cds / hana APIs seem to rely on this field instead of tenantId!
if providerSubAccountId == "" {
providerSubAccountId = ca.Spec.Provider.TenantId
}
secret, _ := c.kubeClient.CoreV1().Secrets(ca.Namespace).Create(context.TODO(), &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
GenerateName: providerTenantName + "-",
Expand All @@ -306,6 +312,7 @@ func (c *Controller) reconcileCAPApplicationProviderTenant(ctx context.Context,
SubscriptionContext: `{
"subscriptionAppName": "` + ca.Spec.BTPAppName + `",
"subscribedTenantId": "` + ca.Spec.Provider.TenantId + `",
"subscribedSubaccountId": "` + providerSubAccountId + `",
"subscribedSubdomain": "` + ca.Spec.Provider.SubDomain + `",
"globalAccountGUID": "` + ca.Spec.GlobalAccountId + `"
}`,
Expand Down
1 change: 1 addition & 0 deletions internal/controller/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
AnnotationGardenerDNSTarget = "dns.gardener.cloud/dnsnames"
AnnotationKubernetesDNSTarget = "external-dns.alpha.kubernetes.io/hostname"
AnnotationSubscriptionContextSecret = "sme.sap.com/subscription-context-secret"
AnnotationProviderSubAccountId = "sme.sap.com/provider-sub-account-id"
FinalizerCAPApplication = "sme.sap.com/capapplication"
FinalizerCAPApplicationVersion = "sme.sap.com/capapplicationversion"
FinalizerCAPTenant = "sme.sap.com/captenant"
Expand Down

0 comments on commit ed55e37

Please sign in to comment.