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

chore: Add logs and cluster objects collecting for tests #1176

Merged
merged 6 commits into from
Nov 17, 2021
Merged
Changes from 1 commit
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
36 changes: 36 additions & 0 deletions .github/bin/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,48 @@ collectLogs() {

set +e
chectl server:logs --chenamespace=${NAMESPACE} --directory=${ARTIFACTS_DIR}
collectK8sResourcesForNamespace $NAMESPACE
collectPodsLogsForNamespace $NAMESPACE
mmorhun marked this conversation as resolved.
Show resolved Hide resolved

collectDevworkspaceOperatorLogs
mmorhun marked this conversation as resolved.
Show resolved Hide resolved
oc get events -n ${DEVWORKSPACE_CONTROLLER_TEST_NAMESPACE} > ${ARTIFACTS_DIR}/events-${DEVWORKSPACE_CONTROLLER_TEST_NAMESPACE}.txt
oc get events -n ${DEVWORKSPACE_CHE_OPERATOR_TEST_NAMESPACE} > ${ARTIFACTS_DIR}/events-${DEVWORKSPACE_CHE_OPERATOR_TEST_NAMESPACE}.txt
mmorhun marked this conversation as resolved.
Show resolved Hide resolved
set -e
}

collectK8sResourcesForNamespace() {
namespace="$1"
if [[ -z $namespace ]]; then return; fi

declare -a KINDS=("pods" "deployments" "services"
"configmaps" "secrets"
"serviceaccounts" "roles" "rolebindings"
"checlusters" "checlusterbackups" "checlusterrestores"
mmorhun marked this conversation as resolved.
Show resolved Hide resolved
)
for kind in "${KINDS[@]}" ; do
dir="${ARTIFACTS_DIR}/cluster/${kind}"
mkdir -p $dir

names=$(kubectl get -n $namespace $kind --no-headers=true -o custom-columns=":metadata.name")
mmorhun marked this conversation as resolved.
Show resolved Hide resolved
for name in $names ; do
kubectl get -n $namespace $kind $name -o yaml > "${dir}/${name}.yaml"
mmorhun marked this conversation as resolved.
Show resolved Hide resolved
done
done
}

collectPodsLogsForNamespace() {
namespace="$1"
if [[ -z $namespace ]]; then return; fi

dir="${ARTIFACTS_DIR}/cluster/logs"
mkdir -p $dir

PODS=$(kubectl get -n $namespace pods --no-headers=true -o custom-columns=":metadata.name")
for pod in $PODS ; do
kubectl logs -n $namespace $pod > "${dir}/${pod}.log"
done
}

collectDevworkspaceOperatorLogs() {
mkdir -p ${ARTIFACTS_DIR}/devworkspace-operator

Expand Down