Update installer for Ubuntu22 and K8s 1.26.5
[osm/devops.git] / jenkins / ci-pipelines / ci_stage_3.groovy
index 1506d87..31eab9d 100644 (file)
@@ -124,13 +124,13 @@ void run_robot_systest(String tagName,
 
 void archive_logs(Map remote) {
 
-    sshCommand remote: remote, command: '''mkdir -p logs'''
+    sshCommand remote: remote, command: '''mkdir -p logs/dags'''
     if (useCharmedInstaller) {
         sshCommand remote: remote, command: '''
-            for container in `kubectl get pods -n osm | grep -v operator | grep -v NAME| awk '{print $1}'`; do
-                logfile=`echo $container | cut -d- -f1`
+            for pod in `kubectl get pods -n osm | grep -v operator | grep -v NAME| awk '{print $1}'`; do
+                logfile=`echo $pod | cut -d- -f1`
                 echo "Extracting log for $logfile"
-                kubectl logs -n osm $container --timestamps=true 2>&1 > logs/$logfile.log
+                kubectl logs -n osm $pod --timestamps=true 2>&1 > logs/$logfile.log
             done
         '''
     } else {
@@ -148,12 +148,17 @@ void archive_logs(Map remote) {
                 > logs/$statefulset.log
             done
         '''
+        sshCommand remote: remote, command: '''
+            schedulerPod="$(kubectl get pods -n osm | grep airflow-scheduler| awk '{print $1; exit}')"; \
+            echo "Extracting logs from Airflow DAGs from pod ${schedulerPod}"; \
+            kubectl cp -n osm ${schedulerPod}:/opt/airflow/logs/scheduler/latest/dags logs/dags -c scheduler
+        '''
     }
 
     sh 'rm -rf logs'
     sshCommand remote: remote, command: '''ls -al logs'''
     sshGet remote: remote, from: 'logs', into: '.', override: true
-    sh 'cp logs/* .'
+    sh 'cp logs/*.log logs/dags/*.log .'
     archiveArtifacts artifacts: '*.log'
 }
 
@@ -437,6 +442,30 @@ node("${params.NODE}") {
                         }
                     }
                     println('VM is ready and accepting ssh connections')
+
+                    //////////////////////////////////////////////////////////////////////////////////////////////
+                    println('Applying sshd config workaround for Ubuntu 22.04 and old jsch client in Jenkins...')
+
+                    sh( returnStatus: true,
+                        script: "ssh -T -i ${SSH_KEY} " +
+                            "-o StrictHostKeyChecking=no " +
+                            "-o UserKnownHostsFile=/dev/null " +
+                            "ubuntu@${IP_ADDRESS} " +
+                            "'echo HostKeyAlgorithms +ssh-rsa | sudo tee -a /etc/ssh/sshd_config'")
+                    sh( returnStatus: true,
+                        script: "ssh -T -i ${SSH_KEY} " +
+                            "-o StrictHostKeyChecking=no " +
+                            "-o UserKnownHostsFile=/dev/null " +
+                            "ubuntu@${IP_ADDRESS} " +
+                            "'echo PubkeyAcceptedKeyTypes +ssh-rsa | sudo tee -a /etc/ssh/sshd_config'")
+                    sh( returnStatus: true,
+                        script: "ssh -T -i ${SSH_KEY} " +
+                            "-o StrictHostKeyChecking=no " +
+                            "-o UserKnownHostsFile=/dev/null " +
+                            "ubuntu@${IP_ADDRESS} " +
+                            "'sudo systemctl restart sshd'")
+                    //////////////////////////////////////////////////////////////////////////////////////////////
+
                 } // stage("Spawn Remote VM")
 
 ///////////////////////////////////////////////////////////////////////////////////////
@@ -449,7 +478,7 @@ node("${params.NODE}") {
                         user: 'ubuntu',
                         identityFile: SSH_KEY,
                         allowAnyHosts: true,
-                        logLevel: 'DEBUG',
+                        logLevel: 'INFO',
                         pty: true
                     ]
 
@@ -748,7 +777,10 @@ EOF"""
             } // if (params.SAVE_ARTIFACTS_OVERRIDE || stage_archive)
         } // dir(OSM_DEVOPS)
     } finally {
-       stage('Archive Container Logs') {
+        // stage('Debug') {
+        //     sleep 900
+        // }
+        stage('Archive Container Logs') {
             if ( ARCHIVE_LOGS_FLAG ) {
                 try {
                     // Archive logs