Skip to content
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

Fix debugger for openshift cluster. #488

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
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"CHE_POSTGRES_SECRET": "che-postgres-secret",
"CHE_SERVER_TRUST_STORE_CONFIGMAP_NAME": "ca-certs"
},
"envFile": "/tmp/che-operator-debug.env",
"cwd": "${workspaceFolder}",
"args": [
"--defaults-path",
Expand Down
3 changes: 1 addition & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"reveal": "always"
},
"group": "build"
}
}
]
}

25 changes: 19 additions & 6 deletions local-debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@

set -e

if [ $# -ne 1 ]; then
echo -e "Wrong number of parameters.\nUsage: ./loca-debug.sh <custom-resource-yaml>\n"
exit 1
fi

command -v delv >/dev/null 2>&1 || { echo "operator-sdk is not installed. Aborting."; exit 1; }
command -v operator-sdk >/dev/null 2>&1 || { echo -e $RED"operator-sdk is not installed. Aborting."$NC; exit 1; }

Expand All @@ -28,8 +23,26 @@ set +e
kubectl create namespace $CHE_NAMESPACE
set -e

CR="${1}"
if [ -z "${CR}" ]; then
CR="./deploy/crds/org_v1_che_cr.yaml"
echo "[INFO] First argument is an empty. Set up default CR file: ${CR}"
fi

kubectl apply -f deploy/crds/org_v1_che_crd.yaml
kubectl apply -f $1 -n $CHE_NAMESPACE
kubectl apply -f "${CR}" -n $CHE_NAMESPACE
cp templates/keycloak_provision /tmp/keycloak_provision
cp templates/oauth_provision /tmp/oauth_provision

ENV_FILE=/tmp/che-operator-debug.env
rm -rf "${ENV_FILE}"
touch "${ENV_FILE}"
CLUSTER_API_URL=$(oc whoami --show-server=true) || true
if [ -n "${CLUSTER_API_URL}" ]; then
echo "CLUSTER_API_URL='${CLUSTER_API_URL}'" > "${ENV_FILE}"
echo "[INFO] Set up cluster api url: ${CLUSTER_API_URL}"
fi

echo "[WARN] Make sure that your CR contains valid ingress domain!"

operator-sdk up local --namespace=${CHE_NAMESPACE} --enable-delve
8 changes: 6 additions & 2 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,15 @@ func IsTestMode() (isTesting bool) {
}

func GetClusterPublicHostname(isOpenShift4 bool) (hostname string, err error) {
// Could be set for debug scripts.
CLUSTER_API_URL := os.Getenv("CLUSTER_API_URL")
if CLUSTER_API_URL != "" {
return CLUSTER_API_URL, nil
}
if isOpenShift4 {
return getClusterPublicHostnameForOpenshiftV4()
} else {
return getClusterPublicHostnameForOpenshiftV3()
}
return getClusterPublicHostnameForOpenshiftV3()
}

// getClusterPublicHostnameForOpenshiftV3 is a hacky way to get OpenShift API public DNS/IP
Expand Down