catalog icon indicating copy to clipboard operation
catalog copied to clipboard

Remote-ssh-commands task hangs after scripts been executed

Open yeeyaa opened this issue 8 months ago • 0 comments

Expected Behavior

Scripts runs fine in remote-ssh-commands session. When scripts are done, the task should run to complete status.

Actual Behavior

When running a remote-ssh-commands task in one of our pipelines. The defined scripts have been executed as we can see from the log, however, the drone-ssh command won't exit thus causing the taskrun to timeout eventually. Hence causing the pipelinerun to fail.

Steps to Reproduce the Problem

  1. Define some scripts to run using the remote-ssh-commands task

Additional Info

We have even switched using the latest tag for the drone-ssh docker image. Issue still the same.

Our task definition in the pipeline:

    - displayName: Install PAC - BRT
      name: task-install-pac-brt-cluster
      params:
        - name: HOST
          value: $(params.pac-fyre-host)
        - name: USERNAME
          value: $(params.default-brt-login-user)
        - name: SSH_SCRIPT
          value: |
            #!/usr/bin/bash
            $(params.path-to-pipeline-scripts)/install_lsf_brt.sh
            sleep 60
            $(params.path-to-pipeline-scripts)/install_pac_brt.sh
      runAfter:
        - task-build-hpc-package
        - copy-repo-to-remote-host
      taskRef:
        kind: Task
        name: remote-ssh-commands
      timeout: 30m0s
      when:
        - input: $(params.should-run-install-pac-brt-cluster)
          operator: in
          values:
            - 'yes'
            - 'y'
            - 'YES'
            - 'yes'
      workspaces:
        - name: credentials

I have modified the remote-ssh-commands yaml a bit to print some information after the drone-ssh finishes. But the message is never printed on the console.

...
  steps:
    - computeResources: {}
      image: 'docker.io/appleboy/drone-ssh:latest'
      name: ssh
      script: |

        export script="$(params.SSH_SCRIPT)"
        cmd=""
        [[ -f ./privatekey ]] && cmd="$cmd -i ./privatekey"
        [[ -f ./password ]] && cmd="$cmd -P $(cat ./password)"
        [[ -f ./passphrase ]] && cmd="$cmd --ssh-passphrase $(cat ./passphrase)"
        [[ -f ./fingerprint ]] && cmd="$cmd --fingerprint $(cat ./fingerprint)"
        [[ -f ./ciphers ]] && cmd="$cmd --ciphers $(cat ./ciphers)"
        [[ $(params.USE_INSECURE_CIPHER) == "true" ]] && cmd="$cmd --useInsecureCipher true"

        drone-ssh -H $(params.HOST) -p $(params.PORT) -u $(params.USERNAME) -T $(params.COMMAND_TIMEOUT) -s "$script" $cmd
        echo "drome-ssh session finished, ending task."
      workingDir: $(workspaces.credentials.path)
...

yeeyaa avatar Jun 12 '24 11:06 yeeyaa