Skip to content

Conversation

@gustavolira
Copy link
Member

Description

Please explain the changes you made here.

Which issue(s) does this PR fix

  • Fixes #?

PR acceptance criteria

Please make sure that the following steps are complete:

  • GitHub Actions are completed and successful
  • Unit Tests are updated and passing
  • E2E Tests are updated and passing
  • Documentation is updated if necessary (requirement for new features)
  • Add a screenshot if the change is UX/UI related

How to test changes / Special notes to the reviewer

@openshift-ci
Copy link

openshift-ci bot commented Nov 10, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign pataknight for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gustavolira gustavolira changed the title Initial step to refactor the CI chore(CI): Initial step to refactor the CI Nov 10, 2025
@gustavolira gustavolira changed the title chore(CI): Initial step to refactor the CI chore(CI): initial step to refactor the CI Nov 10, 2025
@github-actions
Copy link
Contributor

@zdrapela
Copy link
Member

/review

@rhdh-qodo-merge
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🔒 Security concerns

Sensitive information handling:
Several functions read and propagate secret/token data (e.g., OCM_CLUSTER_TOKEN, PostgreSQL credentials, GitHub/Keycloak secrets in env.sh). Ensure secrets are not logged via log_info/log_debug and avoid writing them to shared artifacts. Additionally, in k8s.sh create_secret_dockerconfigjson writes provided dockerconfigjson directly; validate inputs are base64-encoded and avoid echoing their values.

⚡ Recommended focus areas for review

Possible Issue

In perform_helm_install, when the values file is missing the error message references an undefined variable values_path. This will print an empty/incorrect path and can mislead debugging. Use the actual original_values variable in the error message.

local original_values="${PIPELINES_ROOT}/config/helm-values/${value_file}"

if [[ ! -f "${original_values}" ]]; then
    log_error "Values file not found: ${values_path}"
    return 1
fi
Portability Concern

apply_yaml_files uses base64 -w 0 for encoding dh_target_url which is not available on macOS. Elsewhere you implemented a cross-platform base64 wrapper; consider reusing it to avoid failures on non-GNU systems.

local dh_target_url=$(echo -n "test-backstage-customization-provider-${project}.${K8S_CLUSTER_ROUTER_BASE}" | base64 -w 0)
local rhdh_base_url_encoded=$(echo -n "${rhdh_base_url}" | base64 | tr -d '\n')
local rhdh_base_url_http=$(echo -n "${rhdh_base_url/https/http}" | base64 | tr -d '\n')

export DH_TARGET_URL="${dh_target_url}"
export RHDH_BASE_URL="${rhdh_base_url_encoded}"
export RHDH_BASE_URL_HTTP="${rhdh_base_url_http}"

# Apply service account and secrets
📚 Focus areas based on broader codebase context

Plugin Merge Risk

The code attempts to strip orchestrator plugins using yq path .global.dynamicPlugins..."*, but similar helm values use .global.dynamic.plugins. This mismatch likely leaves orchestrator plugins unmodified when INSTALL_ORCHESTRATOR_PLUGINS=false. Align the yq path to the actual schema and add a test to verify removal. (Ref 1)

cp "${in_file}" "${out_file}"

if [[ "${INSTALL_ORCHESTRATOR_PLUGINS:-true}" != "true" ]]; then
  log_info "Removing orchestrator plugins from Helm values (INSTALL_ORCHESTRATOR_PLUGINS=false)"
  if command -v yq &>/dev/null; then
    # delete any element in dynamicPlugins array where package contains 'orchestrator'
    yq -i 'del(.global.dynamicPlugins."*"[] | select(.package | test("orchestrator")))' "${out_file}"
  else
    log_warning "yq not found – cannot strip orchestrator plugins."
  fi
fi

Reference reasoning: The referenced helm values show dynamic plugins under global.dynamic.plugins. Using a different key path in preprocessing will not affect those entries, leading to unintended plugin retention.

📄 References
  1. redhat-developer/rhdh-chart/charts/backstage/ci/with-orchestrator-values.yaml [1-21]
  2. redhat-developer/rhdh-chart/charts/orchestrator-software-templates-infra/ci/upstream-values.yaml [1-27]
  3. redhat-developer/rhdh-chart/charts/orchestrator-software-templates/templates/tekton/tekton-tasks.yaml [219-243]
  4. redhat-developer/rhdh-chart/charts/orchestrator-software-templates/templates/tekton/tekton-tasks.yaml [197-218]
  5. redhat-developer/rhdh-chart/charts/orchestrator-software-templates/templates/tekton/tekton-tasks.yaml [155-171]
  6. redhat-developer/rhdh-chart/charts/orchestrator-software-templates/templates/tekton/tekton-tasks.yaml [172-196]
  7. redhat-developer/rhdh-operator/config/profile/rhdh/plugin-deps/tekton.yaml [172-196]
  8. redhat-developer/rhdh-operator/config/profile/rhdh/plugin-deps/tekton.yaml [321-342]

@github-actions
Copy link
Contributor

- Create new modular pipeline structure in pipelines/ directory
- Add platform abstraction layer (OpenShift, AKS, EKS, GKE)
- Implement core utilities (env, k8s, logging, reporting)
- Add deployment modules (Helm, PostgreSQL, orchestrator workflows)
- Create job handlers for different CI scenarios (pull, nightly, upgrade)
- Extract PostgreSQL TLS certificates to temporary directory (security)
- Add orchestrator feature flags (INSTALL_ORCHESTRATOR_INFRA/PLUGINS)
- Fix code review findings (Qodo analysis):
  - Fix undefined variable in error message
  - Replace base64 -w 0 with portable version for macOS
  - Correct yq path for orchestrator plugin removal
- Update .gitignore for pipeline artifacts

This refactoring improves code organization, portability, and
security while maintaining compatibility with existing CI workflows.
@github-actions
Copy link
Contributor

@gustavolira
Copy link
Member Author

@zdrapela Any comments here?

@schultzp2020
Copy link
Contributor

@gustavolira can you please update the description and add a linked issue? 🙏

@zdrapela
Copy link
Member

zdrapela commented Nov 19, 2025

Can you please remove the AKS, GKE, and EKS completely? We want to only focus on OCP here for now. Also, remove ocp-upgrade, we can add that later too. There are still many files in pipelines/modules/platform/*

Can we also set up a job in OpenShift CI that would allow us to verify it runs here?

Sorry for the delay, but it still is a scary PR to review 😅

Copy link
Member

@zdrapela zdrapela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First round of comments. It would be good to do a second round after we have it configured in OpenShift CI

Comment on lines +93 to +94
case "${JOB_NAME}" in
*pull*ocp*helm*)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not get rid ot this detection by JOB_NAME and move it to openshift/release repo? You already have the Makefile, so let's use it. The entrypoint for ocp-helm pull is here: https://github.com/openshift/release/blob/3951d20775795d07b42e9f10d4df22d61af55182/ci-operator/step-registry/redhat-developer/rhdh/ocp/helm/redhat-developer-rhdh-ocp-helm-commands.sh#L180-L181 and it's similar for others.


# Detect OpenShift platform (wrapper for common function)
# Usage: detect_ocp
detect_ocp() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set -euo pipefail # Exit on error, undefined variables, and pipe failures

# Source core modules
# shellcheck source=../../core/k8s.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you tell me what's your ShellCheck config? I cannot get my ShellCheck to follow the sourcing if it wasn't absolute :(

@@ -0,0 +1,479 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the file

@@ -0,0 +1,277 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the file

Comment on lines +119 to +123
for file in "${files[@]}"; do
if [[ -f "${file}" ]]; then
sed_inplace "s/namespace:.*/namespace: ${project}/g" "${file}"
fi
done
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replacing namespace in the files is redundant when you apply the file to a specific namespace instead (which is already happening). What's more, it is making changes in files that you don't want to commit.

Comment on lines +329 to +339
local postgres_password=$(oc get secret/postgress-external-db-pguser-janus-idp \
-n "${NAME_SPACE_POSTGRES_DB}" -o jsonpath='{.data.password}')
sed_inplace "s|POSTGRES_PASSWORD:.*|POSTGRES_PASSWORD: ${postgres_password}|g" \
"${resources_dir}/postgres-cred.yaml"

local postgres_host=$(echo -n "postgress-external-db-primary.${NAME_SPACE_POSTGRES_DB}.svc.cluster.local" | \
base64 | tr -d '\n')
sed_inplace "s|POSTGRES_HOST:.*|POSTGRES_HOST: ${postgres_host}|g" \
"${resources_dir}/postgres-cred.yaml"

oc apply -f "${resources_dir}/postgres-cred.yaml" --namespace="${project}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use envsubst < file.yaml | oc apply --namespace="${project}" -f - anywhere possible. It's substantially better than using sed

Comment on lines +133 to +134
echo ""
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be notified is secret is not populated. This will hide a missing env var, which is hard to debug

@github-actions
Copy link
Contributor

This PR is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 21 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants