Skip to content
Merged
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
19 changes: 2 additions & 17 deletions .ci/pipelines/install-methods/operator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,6 @@ prepare_operator() {
k8s_wait::crd "backstages.rhdh.redhat.com" 300 10 || return 1
}

# Waits for the Crunchy Data PostgreSQL Operator's PostgresCluster CRD to become available.
# Must be called after the Crunchy DB CRD is created and before RHDH is deployed
# with internal DB disabled and configured to use Crunchy DB as the external PostgreSQL database.
wait_for_crunchy_crd() {
log::info "Verifying PostgresCluster CRD is available before deploying Backstage CR..."
k8s_wait::crd "postgresclusters.postgres-operator.crunchydata.com" 60 5 || {
log::error "PostgresCluster CRD not available - operator won't be able to create internal database"
return 1
}
}

deploy_rhdh_operator() {
local namespace=$1
local backstage_crd_path=$2
Expand Down Expand Up @@ -95,11 +84,9 @@ deploy_rhdh_operator() {
return 0
fi

# Wait for the operator to create the database resource (5 minutes max)
# The operator can create either PostgresCluster (Crunchy) or StatefulSet (built-in)
# Wait for the operator to create the database StatefulSet (5 minutes max)
if ! common::poll_until \
"oc get postgrescluster -n '$namespace' --no-headers 2>/dev/null | grep -q 'backstage-psql' || \
oc get statefulset -n '$namespace' --no-headers 2>/dev/null | grep -q 'backstage-psql'" \
"oc get statefulset -n '$namespace' --no-headers 2>/dev/null | grep -q 'backstage-psql'" \
60 5 "Database resource created by operator"; then
log::error "Database resource not created after 5 minutes"
_operator_debug_info "$namespace"
Expand All @@ -118,8 +105,6 @@ _operator_debug_info() {
oc logs -n "${OPERATOR_MANAGER:-rhdh-operator}" -l control-plane=controller-manager --tail=50 || true
log::info "Checking for StatefulSet..."
oc get statefulset -n "$namespace" || true
log::info "Checking for PostgresCluster..."
oc get postgrescluster -n "$namespace" 2> /dev/null || echo "No PostgresCluster CRD or resources found"
}

delete_rhdh_operator() {
Expand Down
6 changes: 2 additions & 4 deletions .ci/pipelines/jobs/ocp-operator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ initiate_operator_deployments() {
apply_yaml_files "${DIR}" "${NAME_SPACE_RBAC}" "${rbac_rhdh_base_url}"
config::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}"
wait_for_crunchy_crd || return 1
deploy_rhdh_operator "${NAME_SPACE_RBAC}" "${DIR}/resources/rhdh-operator/rhdh-start-rbac.yaml"
}

Expand Down Expand Up @@ -63,20 +62,19 @@ initiate_operator_deployments_osd_gcp() {
common::save_artifact "${PW_PROJECT_SHOWCASE_OPERATOR_RBAC}" "/tmp/configmap-dynamic-plugins-rbac.yaml"

oc apply -f /tmp/configmap-dynamic-plugins-rbac.yaml -n "${NAME_SPACE_RBAC}"
wait_for_crunchy_crd || return 1
deploy_rhdh_operator "${NAME_SPACE_RBAC}" "${DIR}/resources/rhdh-operator/rhdh-start-rbac.yaml"
}

run_operator_runtime_config_change_tests() {
# Deploy `showcase-runtime` to run tests that require configuration changes at runtime.
# Uses enableLocalDb=false with external Crunchy PostgreSQL for both runtime and schema-mode tests.
# Uses enableLocalDb=false with the external PostgreSQL for both runtime and schema-mode tests.
namespace::configure "${NAME_SPACE_RUNTIME}"

local runtime_url="https://backstage-${RELEASE_NAME}-${NAME_SPACE_RUNTIME}.${K8S_CLUSTER_ROUTER_BASE}"
local postgres_ready
postgres_ready=false

# Set up real external PostgreSQL (Crunchy) instead of placeholder secrets.
# Set up the real external PostgreSQL instead of placeholder secrets.
# Creates postgres-cred and postgres-crt secrets in NAME_SPACE_RUNTIME.
# IMPORTANT: Must be called AFTER namespace is created but BEFORE operator deployment.
namespace::configure "${NAME_SPACE_POSTGRES_DB}"
Expand Down
5 changes: 2 additions & 3 deletions .ci/pipelines/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ Functions: `k8s_wait::deployment`, `k8s_wait::job`, `k8s_wait::service`, `k8s_wa

Operator and OLM installations.

Functions: `operator::install_subscription`, `operator::check_status`,
`operator::install_postgres_ocp`, `operator::install_postgres_k8s`, `operator::install_pipelines`,
`operator::install_olm`, `operator::uninstall_olm`
Functions: `operator::install_subscription`, `operator::install_pipelines`,
`operator::install_tekton`, `operator::install_olm`, `operator::uninstall_olm`

### `helm.sh`

Expand Down
34 changes: 0 additions & 34 deletions .ci/pipelines/lib/operators.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ fi
readonly OPERATORS_LIB_SOURCED=1

# Constants
readonly OPERATOR_STATUS_SUCCEEDED="Succeeded"
readonly OPERATOR_NAMESPACE="openshift-operators"

# Create OpenShift Operator subscription
Expand Down Expand Up @@ -39,39 +38,6 @@ EOD
return $?
}

# Monitor operator status until expected phase is reached
# Args: timeout_seconds, namespace, operator_name, expected_status (default: "Succeeded")
operator::check_status() {
local timeout=${1:-300}
local namespace=$2
local operator_name=$3
local expected_status=${4:-${OPERATOR_STATUS_SUCCEEDED}}

log::info "Checking the status of operator '${operator_name}' in namespace '${namespace}' with a timeout of ${timeout} seconds."
log::info "Expected status: ${expected_status}"

timeout "${timeout}" bash -c "
while true; do
CURRENT_PHASE=\$(oc get csv -n '${namespace}' -o jsonpath='{.items[?(@.spec.displayName==\"${operator_name}\")].status.phase}')
echo \"Operator '${operator_name}' current phase: \${CURRENT_PHASE}\"
[[ \"\${CURRENT_PHASE}\" == \"${expected_status}\" ]] && echo \"Operator '${operator_name}' is now in '${expected_status}' phase.\" && break
sleep 10
done
" || log::error "Timed out after ${timeout} seconds. Operator '${operator_name}' did not reach '${expected_status}' phase."
return $?
}

# Install Crunchy Postgres Operator from OpenShift Marketplace
operator::install_postgres_ocp() {
operator::install_subscription crunchy-postgres-operator "${OPERATOR_NAMESPACE}" v5 crunchy-postgres-operator certified-operators openshift-marketplace
operator::check_status 300 "${OPERATOR_NAMESPACE}" "Crunchy Postgres for Kubernetes" "${OPERATOR_STATUS_SUCCEEDED}" || return 1

# Wait for PostgresCluster CRD to be registered
log::info "Waiting for PostgresCluster CRD to be registered..."
k8s_wait::crd "postgresclusters.postgres-operator.crunchydata.com" 120 5 || return 1
return 0
}

# Install Red Hat OpenShift Pipelines operator if not present
operator::install_pipelines() {
local display_name="Red Hat OpenShift Pipelines"
Expand Down
21 changes: 11 additions & 10 deletions .ci/pipelines/lib/schema-mode-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,25 @@ configure_schema_mode_runtime_env() {
done
else
local pdb="${NAME_SPACE_POSTGRES_DB:-postgress-external-db}"
local crunchy_cluster="${SCHEMA_MODE_CRUNCHY_CLUSTER_NAME:-postgress-external-db}"
if oc get svc postgress-external-db-primary -n "${pdb}" &> /dev/null; then
# Name and labels deployed by resources/postgres-db/postgres.yaml
local external_db="postgress-external-db"
if oc get svc "${external_db}-primary" -n "${pdb}" &> /dev/null; then
forward_namespace="${pdb}"
log::info "Schema-mode (${install_method}): no in-cluster Postgres Service in ${runtime_namespace}; using Crunchy cluster in ${pdb}"
local crunchy_admin_secret="${crunchy_cluster}-pguser-janus-idp"
if oc get secret "${crunchy_admin_secret}" -n "${pdb}" &> /dev/null; then
admin_password=$(oc get secret "${crunchy_admin_secret}" -n "${pdb}" -o jsonpath='{.data.password}' 2> /dev/null | base64 -d || true)
log::info "Schema-mode (${install_method}): no in-cluster Postgres Service in ${runtime_namespace}; using external PostgreSQL in ${pdb}"
local external_db_secret="${external_db}-pguser-rhdh"
if oc get secret "${external_db_secret}" -n "${pdb}" &> /dev/null; then
admin_password=$(oc get secret "${external_db_secret}" -n "${pdb}" -o jsonpath='{.data.password}' 2> /dev/null | base64 -d || true)
fi
if [[ -z "${admin_password}" ]]; then
log::warn "Schema-mode (${install_method}): could not read ${crunchy_admin_secret} password in ${pdb}; schema tests remain opt-in."
log::warn "Schema-mode (${install_method}): could not read ${external_db_secret} password in ${pdb}; schema tests remain opt-in."
return 1
fi
postgres_service=$(oc get pods -n "${pdb}" \
-l "postgres-operator.crunchydata.com/cluster=${crunchy_cluster},postgres-operator.crunchydata.com/data=postgres" \
-l "app.kubernetes.io/name=${external_db}" \
--field-selector=status.phase=Running \
-o jsonpath='{.items[0].metadata.name}' 2> /dev/null)
if [[ -z "${postgres_service}" ]]; then
log::warn "Schema-mode (${install_method}): no Running Postgres pod in ${pdb} for cluster ${crunchy_cluster}; schema tests remain opt-in."
log::warn "Schema-mode (${install_method}): no Running Postgres pod in ${pdb} for ${external_db}; schema tests remain opt-in."
return 1
fi
forward_via_pod=1
Expand All @@ -101,7 +102,7 @@ configure_schema_mode_runtime_env() {
export SCHEMA_MODE_PORT_FORWARD_RESOURCE="${pf_target}"

if [[ "${forward_via_pod}" -eq 1 ]]; then
export SCHEMA_MODE_DB_ADMIN_USER="${SCHEMA_MODE_DB_ADMIN_USER:-janus-idp}"
export SCHEMA_MODE_DB_ADMIN_USER="${SCHEMA_MODE_DB_ADMIN_USER:-rhdh}"
else
export SCHEMA_MODE_DB_ADMIN_USER="${SCHEMA_MODE_DB_ADMIN_USER:-postgres}"
fi
Expand Down
Loading
Loading