From e048189e18fb5f870af0d5b48d03bca4f5c96037 Mon Sep 17 00:00:00 2001 From: mesaj Date: Thu, 31 Jul 2025 09:26:53 +0200 Subject: [PATCH] Add log collection for kubernetes events and vcluster pods Change-Id: I05d92f9a8241c9b98b9ef16a966ace1e7f5b389b Signed-off-by: mesaj --- jenkins/ci-pipelines/ci_stage_3.groovy | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/jenkins/ci-pipelines/ci_stage_3.groovy b/jenkins/ci-pipelines/ci_stage_3.groovy index 11b4755f..6c49cda8 100644 --- a/jenkins/ci-pipelines/ci_stage_3.groovy +++ b/jenkins/ci-pipelines/ci_stage_3.groovy @@ -516,7 +516,14 @@ void run_robot_systest(String tagName, void archive_logs(Map remote) { - sshCommand remote: remote, command: '''mkdir -p logs/dags''' + sshCommand remote: remote, command: '''mkdir -p logs/dags logs/vcluster logs/events''' + // Collect Kubernetes events + sshCommand remote: remote, command: ''' + echo "Extracting Kubernetes events" + kubectl get events --all-namespaces --sort-by='.lastTimestamp' -o wide > logs/events/k8s-events.log 2>&1 || true + kubectl get events -n osm --sort-by='.lastTimestamp' -o wide > logs/events/osm-events.log 2>&1 || true + kubectl get events -n vcluster --sort-by='.lastTimestamp' -o wide > logs/events/vcluster-events.log 2>&1 || true + ''' if (useCharmedInstaller) { sshCommand remote: remote, command: ''' for pod in `kubectl get pods -n osm | grep -v operator | grep -v NAME| awk '{print $1}'`; do @@ -545,12 +552,21 @@ void archive_logs(Map remote) { echo "Extracting logs from Airflow DAGs from pod ${schedulerPod}"; \ kubectl -n osm cp ${schedulerPod}:/opt/airflow/logs/scheduler/latest/dags logs/dags -c scheduler 2>&1 || true ''' + // Collect vcluster namespace logs + sshCommand remote: remote, command: ''' + echo "Extracting logs from vcluster namespace" + for pod in `kubectl get pods -n vcluster | grep -v NAME | awk '{print $1}'`; do + echo "Extracting log for vcluster pod: $pod" + kubectl logs -n vcluster $pod --timestamps=true --all-containers 2>&1 \ + > logs/vcluster/$pod.log || true + done + ''' } sh 'rm -rf logs' - sshCommand remote: remote, command: '''ls -al logs''' + sshCommand remote: remote, command: '''ls -al logs logs/vcluster logs/events''' sshGet remote: remote, from: 'logs', into: '.', override: true - archiveArtifacts artifacts: 'logs/*.log, logs/dags/*.log' + archiveArtifacts artifacts: 'logs/*.log, logs/dags/*.log, logs/vcluster/*.log, logs/events/*.log' } String get_value(String key, String output) { -- 2.25.1