drone-downstream icon indicating copy to clipboard operation
drone-downstream copied to clipboard

Feature: Create builds directly instead of restarting old builds

Open aknuds1 opened this issue 3 years ago • 20 comments

This PR proposes a rewrite of the plugin to, instead of re-starting old builds, create builds via Client.BuildCreate.

aknuds1 avatar Sep 24 '20 11:09 aknuds1

@aknuds1 can you look at targeting the v2 branch?

donny-dont avatar Sep 25 '20 18:09 donny-dont

@donny-dont Thanks, I wasn't aware.

aknuds1 avatar Sep 25 '20 18:09 aknuds1

Will have to fix it up later.

aknuds1 avatar Sep 25 '20 18:09 aknuds1

@donny-dont I pushed a revision now that's cleanly based on v2, where I retain the blocking functionality. Please have a look.

Also, would you mind explaining the purpose of the v2 branch, and its relation to the master branch?

aknuds1 avatar Sep 28 '20 14:09 aknuds1

@donny-dont Thanks! Will look into your feedback.

aknuds1 avatar Sep 28 '20 15:09 aknuds1

@aknuds1 with regards to the v2 branch we had this PR https://github.com/drone-plugins/drone-downstream/pull/70 which added a block option. Per https://github.com/drone-plugins/drone-downstream/issues/68 the ideal behavior was for that block that was added to be the wait option. The PR adding the params for the BuildCreate method in drone-go wasn't present yet so we merged things over into a v2 branch.

Also remember that drone-downstream is a very popular plugin so we'd need to have a proper migration path for users hence the v2.

donny-dont avatar Sep 28 '20 16:09 donny-dont

The wait, block and deploy features are important as they are actively used as far as I know.

tboerger avatar Sep 28 '20 17:09 tboerger

The block was added by @dschmidt and has yet to ship in anything. My understanding from @bradrydzewski 's bug is that what is currently block is what he thinks wait should be.

donny-dont avatar Sep 28 '20 17:09 donny-dont

The wait, block and deploy features are important as they are actively used as far as I know.

At least by me/ownCloud block is used :trollface:

The block was added by @dschmidt and has yet to ship in anything.

Agreed, probably not many people except for me are already using it, but I think it's an important feature and other people will follow once it's released.

My understanding from @bradrydzewski 's bug is that what is currently block is what he thinks wait should be.

Yeah, I tried to make the change non-breaking... which led to having two hard to distinguish options ... but I still like it better than reusing an existing option for a different function :-\

dschmidt avatar Sep 29 '20 07:09 dschmidt

Its my understanding that wait was originally there because of a limitation of the API. Remember that drone-downstream is one of the first plugins way back in the pre-1.0 days. With the new build API its not needed so we can just use wait as wait for the triggered build to end.

donny-dont avatar Sep 29 '20 18:09 donny-dont

the wait feature is only used because it was previously impossible to restart a build while it was running, which is why polling was implemented. This limitation no longer exists. Also we are moving from build restart to build create endpoint. So the wait command should no longer be relevant for this plugin.

bradrydzewski avatar Sep 29 '20 18:09 bradrydzewski

if there are concerns about this being a breaking change ...

the wait field should be repurposed to wait for the build to complete and, if the build fails, return a non-zero exit code.

my recommendation would be that we deprecate and ignore wait going forward since it should no longer be needed. We can use block to ensure that it does not break existing configurations that define wait. Since wait is deprecated and ignored, I recommend we change from block_timeout to just timeout since there will only be a single timeout going forward.

bradrydzewski avatar Sep 29 '20 18:09 bradrydzewski

Having a look at the feedback.

aknuds1 avatar Oct 02 '20 06:10 aknuds1

my recommendation would be that we deprecate and ignore wait going forward since it should no longer be needed. We can use block to ensure that it does not break existing configurations that define wait. Since wait is deprecated and ignored, I recommend we change from block_timeout to just timeout since there will only be a single timeout going forward.

@bradrydzewski For the sake of clarity, do you want for wait to be ignored or for it to enable block if set?

aknuds1 avatar Oct 02 '20 06:10 aknuds1

I've re-implemented deploy logic, but not sure what to do wrt. builds that are currently running. Please see my comment.

aknuds1 avatar Oct 02 '20 07:10 aknuds1

Is there any way forward with this?

dschmidt avatar Dec 04 '20 21:12 dschmidt

I also hope we can progress on this :)

aknuds1 avatar Dec 05 '20 09:12 aknuds1

Thanks for your work @aknuds1 ♥ I will be using this from now also.

andrewhowdencom avatar Feb 17 '21 17:02 andrewhowdencom

In testing this I found a condition in which if, for whatever reason, a new build is not created (such as if the build does not match a given set of triggers — in my case custom was missing from match events) — the plugin appeared to succeed, but then failed immediately thereafter when it was in the "block" step.

Notably, the returned build ID was 0 — like the request itself worked, but that while the event was successfully triggered, there were no builds generated.

Logs were:

2 | starting Drone build for __REPO__successfully started Drone build for __REPO__: #0
3 | with params:
4 | - DRONE_UPSTREAM_BUILD_NUMBER: 580
5 |  
6 | blocking until build is finished
7 | time="2021-02-17T20:50:53Z" level=error msg="execution failed: client error 404: {\"message\":\"sql: no rows in result set\"}\n"
8

This server is a little mutant though — theres a couple patches on there that aren't in main (yet) — but it might be worth digging into.

andrewhowdencom avatar Feb 17 '21 20:02 andrewhowdencom

Any news on this? There is a bug associated with this to my knowledge (parameter passing, old parameters get reused instead of new ones), which can lead to timeconsuming problems.

Is there a workaround for this? Will this PR be merged?

leandrolerena avatar Apr 13 '23 10:04 leandrolerena