@@ -104,6 +104,9 @@ data:
104
104
if [[ $ACCOUNT_IAM != "False" ]]; then
105
105
info "Beginning restore of account_iam database..."
106
106
oc -n $CSDB_NAMESPACE exec -t $CNPG_PRIMARY_POD -c postgres -- pg_restore -U postgres --dbname account_iam --format=c --clean --exit-on-error -v /run/cs-db_backup/cs-db_account_iam_backup.dump
107
+
108
+ # Update IDP configuration with actual cluster domain
109
+ update_idp_config
107
110
fi
108
111
oc -n $CSDB_NAMESPACE exec -t $CNPG_PRIMARY_POD -c postgres -- psql -U postgres -c "\list" -c "\dn" -c "\du"
109
112
else
@@ -121,6 +124,42 @@ data:
121
124
wait_for_oidc
122
125
}
123
126
127
+ function update_idp_config {
128
+ info "Updating IDP configuration with actual cluster domain..."
129
+
130
+ # Get the cluster domain from the management ingress
131
+ CLUSTER_DOMAIN=$(oc get route console -n openshift-console -o jsonpath='{.spec.host}' | sed 's/^console-openshift-console\.//')
132
+
133
+ if [[ -z $CLUSTER_DOMAIN ]]; then
134
+ error "Could not determine cluster domain. Please update IDP configuration manually."
135
+ return 1
136
+ fi
137
+
138
+ info "Detected cluster domain: $CLUSTER_DOMAIN"
139
+
140
+ # Construct the new IDP URL based on the cluster domain and namespace
141
+ NEW_IDP_URL="https://cp-console.${CSDB_NAMESPACE}.${CLUSTER_DOMAIN}/idprovider/v1/auth"
142
+
143
+ info "Updating IDP URLs to: $NEW_IDP_URL"
144
+
145
+ # Check if account_iam database exists
146
+ ACCOUNT_IAM_EXISTS=$(oc -n $CSDB_NAMESPACE exec -t $CNPG_PRIMARY_POD -c postgres -- psql -U postgres -c "\list" | grep "account_iam" || echo False)
147
+
148
+ if [[ $ACCOUNT_IAM_EXISTS != "False" ]]; then
149
+ # Update the idp column in the idp_config table
150
+ oc -n $CSDB_NAMESPACE exec -t $CNPG_PRIMARY_POD -c postgres -- psql -U postgres -d account_iam -c "
151
+ UPDATE accountiam.idp_config
152
+ SET idp = '$NEW_IDP_URL',
153
+ modified_ts = NOW()
154
+ WHERE idp LIKE '%/idprovider/v1/%';
155
+ "
156
+
157
+ success "IDP configuration updated successfully."
158
+ else
159
+ warning "account_iam database not found, skipping IDP configuration update."
160
+ fi
161
+ }
162
+
124
163
function wait_for_oidc {
125
164
job_name="oidc-client-registration"
126
165
info "Waiting for job $job_name to complete in namespace $CSDB_NAMESPACE."
0 commit comments