Skip to content

Commit

Permalink
Merge branch 'release-1.3' into update-keycloak-for-RHDH-1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-tsao authored Nov 5, 2024
2 parents 17c7fe5 + 1c7cb45 commit f378972
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 11 deletions.
61 changes: 52 additions & 9 deletions .ibm/pipelines/openshift-ci-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,30 @@ uninstall_helmchart() {

configure_namespace() {
local project=$1
if oc get namespace "${project}" >/dev/null 2>&1; then
echo "Namespace ${project} already exists! refreshing namespace"
oc delete namespace "${project}"
fi
delete_namespace $project
oc create namespace "${project}"
oc config set-context --current --namespace="${project}"
}

delete_namespace() {
local project=$1
if oc get namespace "$project" >/dev/null 2>&1; then
echo "Namespace ${project} exists. Attempting to delete..."

# Remove blocking finalizers
remove_finalizers_from_resources "$project"

# Attempt to delete the namespace
oc delete namespace "$project" --grace-period=0 --force || true

# Check if namespace is still stuck in 'Terminating' and force removal if necessary
if oc get namespace "$project" -o jsonpath='{.status.phase}' | grep -q 'Terminating'; then
echo "Namespace ${project} is stuck in Terminating. Forcing deletion..."
force_delete_namespace "$project"
fi
fi
}

configure_external_postgres_db() {
local project=$1
oc apply -f "${DIR}/resources/postgres-db/postgres.yaml" --namespace="${NAME_SPACE_POSTGRES_DB}"
Expand Down Expand Up @@ -170,9 +186,9 @@ apply_yaml_files() {
oc apply -f "$dir/resources/config_map/configmap-rbac-policy-rhdh.yaml" --namespace="${project}"
oc apply -f "$dir/auth/secrets-rhdh-secrets.yaml" --namespace="${project}"

sleep 20 # wait for Pipeline Operator to be ready
oc apply -f "$dir/resources/pipeline-run/hello-world-pipeline.yaml"
oc apply -f "$dir/resources/pipeline-run/hello-world-pipeline-run.yaml"
#sleep 20 # wait for Pipeline Operator to be ready
#oc apply -f "$dir/resources/pipeline-run/hello-world-pipeline.yaml"
#oc apply -f "$dir/resources/pipeline-run/hello-world-pipeline-run.yaml"
}

run_tests() {
Expand Down Expand Up @@ -262,7 +278,7 @@ install_pipelines_operator() {
initiate_deployments() {
add_helm_repos
configure_namespace "${NAME_SPACE}"
install_pipelines_operator "${DIR}"
#install_pipelines_operator "${DIR}"
install_helm
uninstall_helmchart "${NAME_SPACE}" "${RELEASE_NAME}"

Expand All @@ -279,7 +295,7 @@ initiate_deployments() {
configure_external_postgres_db "${NAME_SPACE_RBAC}"


install_pipelines_operator "${DIR}"
#install_pipelines_operator "${DIR}"
uninstall_helmchart "${NAME_SPACE_RBAC}" "${RELEASE_NAME_RBAC}"
apply_yaml_files "${DIR}" "${NAME_SPACE_RBAC}"
echo "Deploying image from repository: ${QUAY_REPO}, TAG_NAME: ${TAG_NAME}, in NAME_SPACE : ${RELEASE_NAME_RBAC}"
Expand All @@ -300,6 +316,33 @@ check_and_test() {
save_all_pod_logs $namespace
}

# Function to remove finalizers from specific resources in a namespace that are blocking deletion.
remove_finalizers_from_resources() {
local project=$1
echo "Removing finalizers from resources in namespace ${project} that are blocking deletion."

# Remove finalizers from stuck PipelineRuns and TaskRuns
for resource_type in "pipelineruns.tekton.dev" "taskruns.tekton.dev"; do
for resource in $(oc get "$resource_type" -n "$project" -o name); do
oc patch "$resource" -n "$project" --type='merge' -p '{"metadata":{"finalizers":[]}}' || true
echo "Removed finalizers from $resource in $project."
done
done

# Check and remove specific finalizers stuck on 'chains.tekton.dev' resources
for chain_resource in $(oc get pipelineruns.tekton.dev,taskruns.tekton.dev -n "$project" -o name); do
oc patch "$chain_resource" -n "$project" --type='json' -p='[{"op": "remove", "path": "/metadata/finalizers"}]' || true
echo "Removed Tekton finalizers from $chain_resource in $project."
done
}

# Function to forcibly delete a namespace stuck in 'Terminating' status
force_delete_namespace() {
local project=$1
echo "Forcefully deleting namespace ${project}."
oc get namespace "$project" -o json | jq '.spec = {"finalizers":[]}' | oc replace --raw "/api/v1/namespaces/$project/finalize" -f -
}

main() {
echo "Log file: ${LOGFILE}"
set_cluster_info
Expand Down
2 changes: 1 addition & 1 deletion catalog-entities/apis/petstore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ spec:
owner: janus-authors
lifecycle: production
definition:
$openapi: https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v3.0/petstore.yaml
$openapi: https://github.com/OAI/OpenAPI-Specification/blob/main/tests/v3.0/pass/petstore.yaml
2 changes: 1 addition & 1 deletion e2e-tests/playwright/e2e/plugins/tekton/tekton.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Catalog } from '../../../support/pages/Catalog';
// Pre-req: A kubernetes cluster containing pipeline and pipelinerun resources labeled with backstage.io/kubernetes-id: developer-hub
// Pre-req: A catalog entity with the matching backstage.io/kubernetes-id: developer-hub annotation as well as the janus-idp.io/tekton : <BACKSTAGE_ENTITY_NAME> annotation

test.describe('Test Tekton plugin', () => {
test.describe.skip('Test Tekton plugin', () => {
let common: Common;
let uiHelper: UIhelper;
let tekton: Tekton;
Expand Down

0 comments on commit f378972

Please sign in to comment.