Better handling of ChannelClosedException in Declarative pipeline

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      When pods get deleted for any reason,  there is a log/exception like so:

      hudson.remoting.ChannelClosedException: Channel "unknown": Remote call on JNLP4-connect connection from .... failed. The channel is closing down or has closed down 

      The job then appears to hang indefinitely until a timeout is reached or it's stopped manually.

      In our use case (k8s using preemptible vms) we actually expect pods to be deleted mid build and want to be able to handle pod deletion with a retry.

      I have not been able to find a way to handle this in declarative syntax.

      For testing, using a very simple declarative example:

          stages {
              stage('Try test') {
                  steps {
                      container('jnlp') {
                          sh """
                          echo Kill the pod now
                          sleep 5m
                          """
                      }
                  }
                  post {
                      failure {
                          echo "Failuuure"
                      }
                  }
              }

      But the exception does not actually trigger the failure block when the pod is killed.

      Is there currently any best practice to handle the deletion of a pod? Are there any timeout parameters that would be useful in this case?

      I'm happy to add a PR to the Readme after learning

            Assignee:
            Unassigned
            Reporter:
            Collin Lefeber
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: