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