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
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) {