-
Notifications
You must be signed in to change notification settings - Fork 82
ci: add HyperShift support and PR image wait for OpenShift CI migration #1073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e9e2323
3e1676d
90231f5
6a7c775
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,12 @@ set -e | |
| # only exit with zero if all commands of the pipeline exit successfully | ||
| set -o pipefail | ||
|
|
||
| PR_IMAGE_TAG="pr-${PULL_NUMBER}" | ||
| if [[ "${REPO_NAME:-}" == "che-server" ]]; then | ||
| PR_IMAGE_TAG="pr-${PULL_NUMBER}" | ||
| else | ||
| PR_IMAGE_TAG="next" | ||
| echo "[INFO] Not a che-server PR (repo: ${REPO_OWNER:-unknown}/${REPO_NAME:-unknown}), using image tag: ${PR_IMAGE_TAG}" | ||
| fi | ||
|
|
||
| export CHE_NAMESPACE=${CHE_NAMESPACE:-"eclipse-che"} | ||
| export CHE_SERVER_IMAGE=${CHE_SERVER_IMAGE:-"quay.io/eclipse/che-server:${PR_IMAGE_TAG}"} | ||
|
|
@@ -36,6 +41,10 @@ export CUSTOM_CONFIG_MAP_NAME=${CUSTOM_CONFIG_MAP_NAME:-"custom-ca-certificates" | |
| export GIT_SSL_CONFIG_MAP_NAME=${GIT_SSL_CONFIG_MAP_NAME:-"che-self-signed-cert"} | ||
|
|
||
| waitForPRImage() { | ||
| if [[ "${REPO_NAME:-}" != "che-server" ]]; then | ||
| echo "------- [INFO] Skipping PR image wait (not a che-server PR, using ${PR_IMAGE_TAG}) -------" | ||
| return 0 | ||
| fi | ||
| echo "------- [INFO] Waiting for PR image ${CHE_SERVER_IMAGE} to be available on registry -------" | ||
| CURRENT_TIME=$(date +%s) | ||
| ENDTIME=$((CURRENT_TIME + 1800)) | ||
|
|
@@ -66,26 +75,81 @@ provisionOpenShiftOAuthUser() { | |
| echo "------- [INFO] Start provisioning Openshift OAuth user -------" | ||
| htpasswd -c -B -b users.htpasswd ${OCP_ADMIN_USER_NAME} ${OCP_LOGIN_PASSWORD} | ||
| htpasswd -b users.htpasswd ${OCP_NON_ADMIN_USER_NAME} ${OCP_LOGIN_PASSWORD} | ||
| oc create secret generic htpass-secret --from-file=htpasswd="users.htpasswd" -n openshift-config | ||
| oc apply -f ".ci/openshift-ci/htpasswdProvider.yaml" | ||
|
|
||
| if [ -f "${SHARED_DIR}/nested_kubeconfig" ]; then | ||
| provisionOpenShiftOAuthUserHyperShift | ||
| else | ||
| provisionOpenShiftOAuthUserIPI | ||
| fi | ||
|
|
||
| oc adm policy add-cluster-role-to-user cluster-admin ${OCP_ADMIN_USER_NAME} | ||
|
|
||
| echo "------- [INFO] Waiting for htpasswd auth to be working up to 5 minutes -------" | ||
| echo "------- [INFO] Waiting for htpasswd auth to be working up to 10 minutes -------" | ||
| CURRENT_TIME=$(date +%s) | ||
| ENDTIME=$((CURRENT_TIME + 300)) | ||
| ENDTIME=$((CURRENT_TIME + 600)) | ||
| while [ "$(date +%s)" -lt $ENDTIME ]; do | ||
| if oc login -u=${OCP_ADMIN_USER_NAME} -p=${OCP_LOGIN_PASSWORD} --insecure-skip-tls-verify=false; then | ||
| if oc login -u=${OCP_ADMIN_USER_NAME} -p=${OCP_LOGIN_PASSWORD} --insecure-skip-tls-verify; then | ||
| echo "======= [INFO] OpenShift OAuth htpasswd is configured. ======= | ||
| ======= [INFO] Login to OCP cluster with admin user credentials is success.=======" | ||
| return 0 | ||
| fi | ||
| sleep 5 | ||
| sleep 10 | ||
| done | ||
|
|
||
| echo "####### [ERROR] Error occurred while waiting OpenShift OAuth htpasswd setup. Try to rerun test. #######" | ||
| exit 1 | ||
| } | ||
|
|
||
| provisionOpenShiftOAuthUserIPI() { | ||
| echo "------- [INFO] IPI environment: configuring OAuth directly -------" | ||
| oc create secret generic htpass-secret --from-file=htpasswd="users.htpasswd" -n openshift-config | ||
| oc apply -f ".ci/openshift-ci/htpasswdProvider.yaml" | ||
| } | ||
|
|
||
| provisionOpenShiftOAuthUserHyperShift() { | ||
| echo "------- [INFO] HyperShift environment: configuring OAuth via HostedCluster API -------" | ||
|
|
||
| local CLUSTER_NAME | ||
| CLUSTER_NAME=$(cat "${SHARED_DIR}/cluster-name") | ||
|
|
||
| local MGMT_KUBECONFIG | ||
| if [ -f "${SHARED_DIR}/mgmt_kubeconfig" ]; then | ||
| MGMT_KUBECONFIG="${SHARED_DIR}/mgmt_kubeconfig" | ||
| else | ||
| echo "####### [ERROR] Management cluster kubeconfig not found #######" | ||
| exit 1 | ||
| fi | ||
|
|
||
| local HYPERSHIFT_NS | ||
| HYPERSHIFT_NS=$(cat "${SHARED_DIR}/hypershift-clusters-namespace" 2>/dev/null || echo "clusters") | ||
|
|
||
| KUBECONFIG="${MGMT_KUBECONFIG}" oc create secret generic htpass-secret \ | ||
| --from-file=htpasswd="users.htpasswd" -n "${HYPERSHIFT_NS}" | ||
|
|
||
| KUBECONFIG="${MGMT_KUBECONFIG}" oc get hostedcluster "${CLUSTER_NAME}" \ | ||
| -n "${HYPERSHIFT_NS}" -o json > /tmp/hostedcluster.json | ||
|
|
||
| python3 -c " | ||
| import json | ||
| with open('/tmp/hostedcluster.json') as f: | ||
| hc = json.load(f) | ||
| cfg = hc.setdefault('spec', {}).setdefault('configuration', {}).setdefault('oauth', {}) | ||
| idps = cfg.setdefault('identityProviders', []) | ||
| idps.append({ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Update an existing If the HostedCluster already has a provider named 🤖 Prompt for AI Agents |
||
| 'htpasswd': {'fileData': {'name': 'htpass-secret'}}, | ||
| 'mappingMethod': 'claim', | ||
| 'name': 'htpasswd', | ||
| 'type': 'HTPasswd' | ||
| }) | ||
| with open('/tmp/hostedcluster.json', 'w') as f: | ||
| json.dump(hc, f) | ||
| " | ||
|
|
||
| KUBECONFIG="${MGMT_KUBECONFIG}" oc replace -f /tmp/hostedcluster.json | ||
|
|
||
| echo "------- [INFO] HostedCluster OAuth patched, waiting for rollout -------" | ||
| } | ||
|
|
||
| configureGitSelfSignedCertificate() { | ||
| echo "------- [INFO] Configure self-signed certificate for Git provider -------" | ||
| oc adm new-project ${CHE_NAMESPACE} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🛡️ Detected with Advanced Tier | 🟠 Major | 🏗️ Heavy lift
Sensitive Data Exposure
Reachability: Internal
Exploitability: Difficult
CWE: CWE-295 — Improper Certificate Validation
Keep certificate verification enabled for the admin login.
If an attacker can intercept or redirect the CI runner’s connection, the bare
--insecure-skip-tls-verifyflag lets a counterfeit endpoint receiveOCP_ADMIN_USER_NAMEandOCP_LOGIN_PASSWORD. The previous=falsevalue did not disable verification. Use the cluster’s trusted CA instead of disabling verification. (github.com)🧰 Tools
🪛 Shellcheck (0.11.0)
[info] 91-91: Double quote to prevent globbing and word splitting.
(SC2086)
[info] 91-91: Double quote to prevent globbing and word splitting.
(SC2086)
View in Security blast radius
🤖 Prompt for AI Agents