Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .ibm/pipelines/jobs/ocp-operator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ initiate_operator_deployments() {
create_dynamic_plugins_config "${DIR}/value_files/${HELM_CHART_RBAC_VALUE_FILE_NAME}" "/tmp/configmap-dynamic-plugins-rbac.yaml"
oc apply -f /tmp/configmap-dynamic-plugins-rbac.yaml -n "${NAME_SPACE_RBAC}"
deploy_rhdh_operator "${NAME_SPACE_RBAC}" "${DIR}/resources/rhdh-operator/rhdh-start-rbac.yaml"
enable_orchestrator_plugins_op "${NAME_SPACE_RBAC}"
enable_orchestrator_plugins_op "${NAME_SPACE_RBAC}"
deploy_orchestrator_workflows_operator "${NAME_SPACE_RBAC}"
}

Expand Down
2 changes: 2 additions & 0 deletions .ibm/pipelines/resources/config_map/app-config-rhdh-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ permission:
- permission
- scaffolder
- kubernetes
- scorecard
- orchestrator
admin:
users:
- name: user:default/rhdh-qe
Expand Down
76 changes: 36 additions & 40 deletions .ibm/pipelines/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,12 @@ deploy_orchestrator_workflows_operator() {
# Wait for backstage and sonata flow pods to be ready before continuing
wait_for_deployment $namespace backstage-psql 15
wait_for_deployment $namespace backstage-rhdh 15

# DEBUG: Sleep for 2 hours to allow manual troubleshooting
echo "Sleeping for 2 hours (7200 seconds) to allow manual debugging..."
sleep 7200
echo "Sleep completed, continuing with deployment..."

wait_for_deployment $namespace sonataflow-platform-data 20
wait_for_deployment $namespace sonataflow-platform-jobs-service 20

Expand Down Expand Up @@ -1320,28 +1326,6 @@ EOF
echo "All workflow pods are now running!"
}

# Helper function to wait for backstage resource to exist in namespace
wait_for_backstage_resource() {
local namespace=$1
local max_attempts=40 # 40 attempts * 15 seconds = 10 minutes

local sleep_interval=15

echo "Waiting for backstage resource to exist in namespace: $namespace"

for ((i=1; i<=max_attempts; i++)); do
if [[ $(oc get backstage -n "$namespace" -o json | jq '.items | length') -gt 0 ]]; then
echo "Backstage resource found in namespace: $namespace"
return 0
fi
echo "Attempt $i/$max_attempts: No backstage resource found, waiting ${sleep_interval}s..."
sleep $sleep_interval
done

echo "Error: No backstage resource found after 10 minutes"
return 1
}

# Helper function to enable orchestrator plugins by merging default and custom dynamic plugins
enable_orchestrator_plugins_op() {
local namespace=$1
Expand All @@ -1354,11 +1338,21 @@ enable_orchestrator_plugins_op() {
fi

echo "Enabling orchestrator plugins in namespace: $namespace"

# Wait for backstage resource to exist
wait_for_backstage_resource "$namespace"
sleep 5


# Construct backstage deployment name based on namespace
# Pattern: backstage-rhdh for non-RBAC, backstage-rhdh-rbac for RBAC
local backstage_deployment
if [[ "$namespace" == *"rbac"* ]]; then
backstage_deployment="backstage-rhdh-rbac"
else
backstage_deployment="backstage-rhdh"
fi

echo "Waiting for backstage deployment: $backstage_deployment in namespace: $namespace"
# Wait for backstage deployment to be ready (15 minutes timeout)
wait_for_deployment "$namespace" "$backstage_deployment" 15
# sleep 5 # Commented out for testing

# Setup working directory
local work_dir="/tmp/orchestrator-plugins-merge"
rm -rf "$work_dir" && mkdir -p "$work_dir"
Expand Down Expand Up @@ -1397,7 +1391,18 @@ enable_orchestrator_plugins_op() {
echo "Error: Failed to append default plugins to custom plugins"
return 1
fi


# For RBAC namespaces, disable all tech-radar plugins (frontend and backend) if they exist
# These plugins are mistakenly enabled in the RBAC values file and cause deployment issues
# Using global replacement to handle duplicate entries
if [[ "$namespace" == *"rbac"* ]]; then
echo "Disabling all tech-radar plugins (frontend and backend) for RBAC namespace..."
# Disable frontend plugin (all instances)
yq eval '(.plugins[] | select(.package == "./dynamic-plugins/dist/backstage-community-plugin-tech-radar") | .disabled) = true' -i "$work_dir/custom-plugins.yaml" || true
# Disable backend plugin (all instances)
yq eval '(.plugins[] | select(.package == "./dynamic-plugins/dist/backstage-community-plugin-tech-radar-backend-dynamic") | .disabled) = true' -i "$work_dir/custom-plugins.yaml" || true
fi

# Use the modified custom file as the final merged result
if ! cp "$work_dir/custom-plugins.yaml" "$work_dir/merged-plugins.yaml"; then
echo "Error: Failed to create merged plugins file"
Expand All @@ -1410,24 +1415,15 @@ enable_orchestrator_plugins_op() {
-n "$namespace" --dry-run=client -o yaml | oc apply -f -; then
echo "Error: Failed to apply updated dynamic-plugins configmap"
return 1
fi

# Find and restart backstage deployment
echo "Finding backstage deployment..."
local backstage_deployment
backstage_deployment=$(oc get deployment -n "$namespace" --no-headers | grep "^backstage-rhdh" | awk '{print $1}' | head -1)

if [[ -z "$backstage_deployment" ]]; then
echo "Error: No backstage deployment found matching pattern 'backstage-rhdh*'"
return 1
fi


# Restart backstage deployment (using the deployment name determined earlier)
echo "Restarting backstage deployment: $backstage_deployment"
if ! oc rollout restart deployment/"$backstage_deployment" -n "$namespace"; then
echo "Error: Failed to restart backstage deployment"
return 1
fi

# Cleanup
rm -rf "$work_dir"

Expand Down
Loading
Loading