From: mesaj Date: Thu, 31 Jul 2025 07:26:53 +0000 (+0200) Subject: Add log collection for kubernetes events and vcluster pods X-Git-Tag: v18.0.0~26 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F06%2F15306%2F1;p=osm%2Fdevops.git Add log collection for kubernetes events and vcluster pods Change-Id: I05d92f9a8241c9b98b9ef16a966ace1e7f5b389b Signed-off-by: mesaj --- 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) {