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 @@ -193,17 +193,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 @@ -244,11 +233,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 @@ -267,8 +254,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
1 change: 0 additions & 1 deletion .ci/pipelines/jobs/ocp-localization.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ handle_ocp_localization() {
K8S_CLUSTER_ROUTER_BASE=$(oc get route console -n openshift-console -o=jsonpath='{.spec.host}' | sed 's/^[^.]*\.//')
export K8S_CLUSTER_ROUTER_BASE

cluster_setup_ocp_helm
base_deployment "${PW_PROJECT_SHOWCASE}"
deploy_test_backstage_customization_provider "${NAME_SPACE}"

Expand Down
2 changes: 0 additions & 2 deletions .ci/pipelines/jobs/ocp-nightly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ handle_ocp_nightly() {
K8S_CLUSTER_ROUTER_BASE=$(oc get route console -n openshift-console -o=jsonpath='{.spec.host}' | sed 's/^[^.]*\.//')
export K8S_CLUSTER_ROUTER_BASE

cluster_setup_ocp_helm

if [[ "${JOB_NAME}" == *osd-gcp* ]]; then
log::info "Detected OSD-GCP job, using OSD-GCP specific deployment"
initiate_deployments_osd_gcp "${PW_PROJECT_SHOWCASE}" "${PW_PROJECT_SHOWCASE_RBAC}"
Expand Down
4 changes: 0 additions & 4 deletions .ci/pipelines/jobs/ocp-operator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,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 @@ -68,7 +67,6 @@ 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"
}

Expand Down Expand Up @@ -102,8 +100,6 @@ handle_ocp_operator() {
local url="https://backstage-${RELEASE_NAME}-${NAME_SPACE}.${K8S_CLUSTER_ROUTER_BASE}"
local rbac_url="https://backstage-${RELEASE_NAME_RBAC}-${NAME_SPACE_RBAC}.${K8S_CLUSTER_ROUTER_BASE}"

cluster_setup_ocp_operator

if [[ "${JOB_NAME}" =~ osd-gcp ]]; then
# OSD-GCP internal registry is unreliable under parallel load; reduce
# concurrent skopeo pushes and allow retries (RHDHBUGS-1136).
Expand Down
1 change: 0 additions & 1 deletion .ci/pipelines/jobs/ocp-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ handle_ocp_pull() {

K8S_CLUSTER_ROUTER_BASE=$(oc get route console -n openshift-console -o=jsonpath='{.spec.host}' | sed 's/^[^.]*\.//')
export K8S_CLUSTER_ROUTER_BASE
cluster_setup_ocp_helm
initiate_deployments "${PW_PROJECT_SHOWCASE}" "${PW_PROJECT_SHOWCASE_RBAC}"
deploy_test_backstage_customization_provider "${NAME_SPACE}"
local url="https://${RELEASE_NAME}-developer-hub-${NAME_SPACE}.${K8S_CLUSTER_ROUTER_BASE}"
Expand Down
2 changes: 0 additions & 2 deletions .ci/pipelines/jobs/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ handle_ocp_helm_upgrade() {
K8S_CLUSTER_ROUTER_BASE=$(oc get route console -n openshift-console -o=jsonpath='{.spec.host}' | sed 's/^[^.]*\.//')
export K8S_CLUSTER_ROUTER_BASE

cluster_setup_ocp_helm

local url="https://${RELEASE_NAME}-developer-hub-${NAME_SPACE}.${K8S_CLUSTER_ROUTER_BASE}"
UPGRADE_PHASE="baseline-deploy"
initiate_upgrade_base_deployments \
Expand Down
4 changes: 1 addition & 3 deletions .ci/pipelines/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ 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_olm`,
`operator::uninstall_olm`
Functions: `operator::install_tekton`, `operator::install_olm`, `operator::uninstall_olm`

### `helm.sh`

Expand Down
63 changes: 0 additions & 63 deletions .ci/pipelines/lib/operators.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,69 +8,6 @@ if [[ -n "${OPERATORS_LIB_SOURCED:-}" ]]; then
fi
readonly OPERATORS_LIB_SOURCED=1

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

# Create OpenShift Operator subscription
# Args: name, namespace, channel, package, source_name, source_namespace
operator::install_subscription() {
local name=$1
local namespace=$2
local channel=$3
local package=$4
local source_name=$5
local source_namespace=$6

oc apply -f - << EOD
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: $name
namespace: $namespace
spec:
channel: $channel
installPlanApproval: Automatic
name: $package
source: $source_name
sourceNamespace: $source_namespace
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 Tekton Pipelines (alternative to OpenShift Pipelines for Kubernetes)
operator::install_tekton() {
local display_name="tekton-pipelines-webhook"
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 @@ -65,24 +65,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 @@ -108,7 +109,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