screwdriver-cd / screwdriver

An open source build platform designed for continuous delivery.
http://screwdriver.cd
Other
1.02k stars 170 forks source link

Bookends should always run #473

Closed d2lam closed 6 years ago

d2lam commented 7 years ago

Currently, if the build fails in the middle, bookends would not be executed. This shouldn't be the case. For example, if users store some deploy logs in the artifact folder. If the build breaks, they need to be able to look at the logs to debug. However, the screwdriver-artifact-bookend won't run since the build breaks.

d2lam commented 7 years ago

Verifying that it works: https://cd.screwdriver.cd/pipelines/122/builds/3708 The step exit fails, but it still runs the step stuff (since alwaysRun is set to true for this step) and also runs the bookend:

screen shot 2017-04-24 at 2 37 00 pm

One thing is that the status of these steps are Failure. I think we should make those steps (for example, stuff and artifact-bookend) to be Success if runs successfully, while keeping the build status as Failure.

I can dig into this more if that is the expected behavior.

petey commented 7 years ago

Yeah, this should definitely keep the correct step status.

d2lam commented 7 years ago

Actually this is not working. Those steps were not run successfully (returning code 254). Need to look into this more.

d2lam commented 7 years ago

@minz1027 and I did some investigation on this.

d2lam commented 7 years ago

Consulted with @rphan about this. The trap route would not work for us. One way that could get this work is to have a wrapper script and this script would run all the steps. In wrapper.sh:

. /tmp/step1.sh
. /tmp/step2.sh      # if this step fails, step3 will still run
. /tmp/step3.sh

However, this will require a lot of refactor in launcher. Currently, each command is fed into the pty like this: https://github.com/screwdriver-cd/launcher/blob/master/executor/executor.go#L83

A few concerns:

@petey we should figure out the priority on this. It's going to be a big change. If we choose to not implement this yet, should we roll back the change? Technically, it won't affect anything. The alwaysRun would just not work.

d2lam commented 7 years ago

Discussed with the team and decided to roll back this feature. We should revisit this later.

d2lam commented 7 years ago

Reason to roll back: based on current implementation of launcher, it's impossible to stay in the shell if the step fails & exits.

d2lam commented 6 years ago

Update Dec 8, 2017 Taking another stab at this, following some of the ideas here: https://github.com/screwdriver-cd/screwdriver/blob/master/design/director.md

PR is opened: https://github.com/screwdriver-cd/launcher/pull/133

Implementation details:

jithine commented 6 years ago

This now works as expected. Thanks @d2lam @minz1027