Skip to content

Commit 8412bf3

Browse files
dhaiducekopenshift-ci[bot]
authored andcommitted
Add debug commands
Signed-off-by: Dale Haiducek <[email protected]>
1 parent 528958c commit 8412bf3

File tree

3 files changed

+56
-14
lines changed

3 files changed

+56
-14
lines changed

.github/workflows/kind.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,13 @@ jobs:
6464
export GOPATH=$(go env GOPATH)
6565
make wait-for-work-agent
6666
make e2e-test
67+
68+
- name: Debug
69+
if: ${{ failure() }}
70+
run: |
71+
RUN_MODE="debug" ./build/manage-clusters.sh
6772
6873
- name: Clean up cluster
6974
if: ${{ always() }}
7075
run: |
71-
DELETE_CLUSTERS="true" ./build/manage-clusters.sh
76+
RUN_MODE="delete" ./build/manage-clusters.sh

Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,29 @@ e2e-dependencies: ## Download ginkgo locally if necessary.
240240
e2e-test: e2e-dependencies
241241
$(GINKGO) -v --fail-fast --slow-spec-threshold=10s test/e2e
242242

243+
.PHONY: e2e-debug
244+
e2e-debug: ## Collect debug logs from deployed clusters.
245+
@echo "##### Gathering information from $(KIND_NAME) #####"
246+
-KUBECONFIG=$(KIND_KUBECONFIG) kubectl get managedclusteraddons --all-namespaces
247+
-KUBECONFIG=$(KIND_KUBECONFIG) kubectl -n $(CONTROLLER_NAMESPACE) get deployments
248+
-KUBECONFIG=$(KIND_KUBECONFIG) kubectl -n $(CONTROLLER_NAMESPACE) get pods
249+
-KUBECONFIG=$(KIND_KUBECONFIG) kubectl -n open-cluster-management-agent-addon get deployments
250+
-KUBECONFIG=$(KIND_KUBECONFIG) kubectl -n open-cluster-management-agent-addon get pods
251+
@echo "* Container logs in namespace $(CONTROLLER_NAMESPACE):"
252+
-@for POD in $(shell KUBECONFIG=$(KIND_KUBECONFIG) kubectl -n $(CONTROLLER_NAMESPACE) get pods -o name); do \
253+
for CONTAINER in $$(KUBECONFIG=$(KIND_KUBECONFIG) kubectl -n $(CONTROLLER_NAMESPACE) get $${POD} -o jsonpath={.spec.containers[*].name}); do \
254+
echo "* Logs for pod $${POD} from container $${CONTAINER} in namespace $(CONTROLLER_NAMESPACE)"; \
255+
KUBECONFIG=$(KIND_KUBECONFIG) kubectl -n $(CONTROLLER_NAMESPACE) logs $${POD}; \
256+
done; \
257+
done
258+
@echo "* Container logs in namespace open-cluster-management-agent-addon:"
259+
-@for POD in $(shell KUBECONFIG=$(KIND_KUBECONFIG) kubectl -n open-cluster-management-agent-addon get pods -o name); do \
260+
for CONTAINER in $$(KUBECONFIG=$(KIND_KUBECONFIG) kubectl -n open-cluster-management-agent-addon get $${POD} -o jsonpath={.spec.containers[*].name}); do \
261+
echo "* Logs for pod $${POD} from container $${CONTAINER} in namespace open-cluster-management-agent-addon"; \
262+
KUBECONFIG=$(KIND_KUBECONFIG) kubectl -n open-cluster-management-agent-addon logs $${POD}; \
263+
done; \
264+
done
265+
243266
.PHONY: fmt-dependencies
244267
fmt-dependencies:
245268
$(call go-get-tool,github.com/daixiang0/[email protected])

build/manage-clusters.sh

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#! /bin/bash
22

3+
RUN_MODE=${RUN_MODE:-"create"}
4+
35
# Number of managed clusters
46
MANAGED_CLUSTER_COUNT=${MANAGED_CLUSTER_COUNT:-1}
57
if [[ -n "${MANAGED_CLUSTER_COUNT//[0-9]}" ]] || [[ "${MANAGED_CLUSTER_COUNT}" == "0" ]]; then
@@ -12,23 +14,35 @@ CLUSTER_PREFIX=${CLUSTER_PREFIX:-"cluster"}
1214
export KIND_NAME="${KIND_PREFIX}1"
1315
export MANAGED_CLUSTER_NAME="${CLUSTER_PREFIX}1"
1416
# Deploy the hub cluster as cluster1
15-
if [ "${DELETE_CLUSTERS}" == "true" ]; then
16-
make kind-delete-cluster
17-
else
18-
make kind-deploy-controller
19-
fi
17+
case ${RUN_MODE} in
18+
delete)
19+
make kind-delete-cluster
20+
;;
21+
debug)
22+
make e2e-debug
23+
;;
24+
create)
25+
make kind-deploy-controller
26+
;;
27+
esac
2028

2129
# Deploy a variable number of managed clusters starting with cluster2
2230
for i in $(seq 2 $((MANAGED_CLUSTER_COUNT+1))); do
2331
export KIND_NAME="${KIND_PREFIX}${i}"
2432
export MANAGED_CLUSTER_NAME="${CLUSTER_PREFIX}${i}"
2533
export HUB_KUBECONFIG="${PWD}/${KIND_PREFIX}1.kubeconfig-internal"
26-
if [ "${DELETE_CLUSTERS}" == "true" ]; then
27-
make kind-delete-cluster
28-
else
29-
make kind-deploy-registration-operator-managed
30-
# Approval takes place on the hub
31-
export KIND_NAME="${KIND_PREFIX}1"
32-
make kind-approve-cluster
33-
fi
34+
case ${RUN_MODE} in
35+
delete)
36+
make kind-delete-cluster
37+
;;
38+
debug)
39+
make e2e-debug
40+
;;
41+
create)
42+
make kind-deploy-registration-operator-managed
43+
# Approval takes place on the hub
44+
export KIND_NAME="${KIND_PREFIX}1"
45+
make kind-approve-cluster
46+
;;
47+
esac
3448
done

0 commit comments

Comments
 (0)