Coder Social home page Coder Social logo

Should fail on non-zero exit about sake HOT 11 CLOSED

aldy505 avatar aldy505 commented on August 19, 2024
Should fail on non-zero exit

from sake.

Comments (11)

aldy505 avatar aldy505 commented on August 19, 2024 1

I can't find the exact issue as I was searching on the CD pipeline, maybe I executed it from my local machine. As I remembered it, it's just a normal npm install (Nodejs stuff) that got a timeout error, and I also remembered that I put the --any-errors-fatal flag.

But I will surely create a repro over the weekend if that's okay.

from sake.

aldy505 avatar aldy505 commented on August 19, 2024 1

Or maybe you should add an option whether to exit with code 1 or equal to the error code returned by the task. I guess providing both options would be a better way to put things.

from sake.

alajmo avatar alajmo commented on August 19, 2024

There's the flag any-errors-fatal and config spec setting any_errors_fatal that you can enable to stop task execution on all servers when exit code is non-zero. But perhaps, you mean the output of sake is sent to stdout instead of stderr?

Could you copy your command's actual and wanted output and relevant config settings/tasks?

from sake.

alajmo avatar alajmo commented on August 19, 2024

Just to clarify, it should fail on non-zero exit already, if the setting any-errors-fatal is set. So, could be there's a bug, but I tried with a simple script and it seemed to work as intended:

$ go run ../../main.go run lala -t pihole --any-errors-fatal=false

TASK [lala]

172.24.2.3 | 123
172.24.2.3 | Process exited with status 1

TASK [lala]

172.24.2.3 | 123
172.24.2.3 | Process exited with status 1

$ go run ../../main.go run lala -t pihole --any-errors-fatal=true

TASK [lala]

172.24.2.3 | 123
172.24.2.3 | Process exited with status 1
  lala:
    cmd: |
      echo 123 
      exit 1

from sake.

aldy505 avatar aldy505 commented on August 19, 2024

Sorry it took a while. I ran it on the CD server with the sake configuration as:

pull_master:
    desc: Pull from the master branch
    cmd: |
      git remote set-url origin https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/some-organization/some-repository.git
      git pull
      git remote set-url origin https://github.com/some-organization/some-repository.git
    work_dir: /home/user/some-repository
    env:
      GIT_USERNAME: $(echo $GIT_USERNAME)
      GIT_PASSWORD: $(echo $GIT_PASSWORD)
      DEBIAN_FRONTEND: noninteractive

The CD results is (the first line is the command I executed):

Run yes | sake run pull_master --servers onpremise -i /root/.ssh/id_ed25519 --known-hosts-file /root/.ssh/known_hosts --any-errors-fatal
Unknown Host: ***:22 
Fingerprint: <redacted>
Would you like to add it? type (y)es or (n)o: 
TASK [pull_master: Pull from the master branch] 
*** | error: No such remote 'origin'
*** | There is no tracking information for the current branch.
*** | Please specify which branch you want to merge with.
*** | See git-pull(1) for details.
*** | 
*** |     git pull <remote> <branch>
*** | 
*** | If you wish to set tracking information for this branch you can do so with:
*** | 
*** |     git branch --set-upstream-to=<remote>/<branch> master
*** | 
*** | Process exited with status 2
*** | error: No such remote 'origin'

from sake.

alajmo avatar alajmo commented on August 19, 2024

Thanks for finding the bug, the issue is that the exit code for sake is 0, even if the tasks have a different exit code.
The simplest solution is to exit with code 1 if there's an error with the task execution, which I'll add.

from sake.

aldy505 avatar aldy505 commented on August 19, 2024

Hi @alajmo

I want to know if there are any progress to this particular issue. If you don't have time to work on this one, I might be able to submit a PR later this weekend.

from sake.

alajmo avatar alajmo commented on August 19, 2024

I was on vacation but I got back yesterday so will most likely solve it tonight (I did find the responsible code and it should be an easy fix).

from sake.

aldy505 avatar aldy505 commented on August 19, 2024

from sake.

alajmo avatar alajmo commented on August 19, 2024

Fix should be working now for release v0.10.2, the following changes are included:

  • If a task fails, then return the last exit code from said task iff --any-errors-fatal=true, otherwise the exit code will be 0
  • If a host is unreachable and --ignore-unreachable=false, return error code 4

Note, it only outputs correct exit code for serial host execution (since there's some additional work needed for parallel execution, like what if multiple hosts have different exit codes).

from sake.

aldy505 avatar aldy505 commented on August 19, 2024

Thank you! I will test it right away.

from sake.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.