deis / controller

Deis Workflow Controller (API)
https://deis.com
MIT License
41 stars 53 forks source link

feat(deploys): deploy releases asynchronously #1269

Closed kwent closed 7 years ago

kwent commented 7 years ago

Deploy releases asynchronously

Requires https://github.com/deis/workflow/pull/776 Requires https://github.com/deis/workflow-cli/pull/296 Requires https://github.com/deis/controller-sdk-go/pull/118

Idea

This idea of this PR is too be able to create a build (which is creating a release) without deploying the release right away.

Solution implemented

This is possible via a deploy_now flag on the follow endpoint:

POST /v2/apps/example-go/builds/ HTTP/1.1
Host: deis.example.com
Content-Type: application/json
Authorization: token abc123

{"image": "deis/example-go:latest", "deploy_now": false}

A new endpoint allows us to deploy a release later on:

POST /v2/apps/example-go/releases/deploy/ HTTP/1.1
Host: deis.example.com
Content-Type: application/json
Authorization: token abc123

{"version": 1}

TODO

Other idea

Another idea would be to implement a Deploy model/object/table and keep track of the deploys with the following attributes app, timestamp, release, who, status. This will introduce a deis deploys -a app command as well.

2 scenarios would be the following:

deis-admin commented 7 years ago

Thanks for the contribution! Please ensure your commits follow our style guide. This code will be tested once a Deis maintainer reviews it.

deis-bot commented 7 years ago

@bacongobbler, @mboersma and @Joshua-Anderson are potential reviewers of this pull request based on my analysis of git blame information. Thanks @kwent!

bacongobbler commented 7 years ago

I'm kind of concerned about adding new fields to the request, but as long as older versions of the client can still interact with the controller (i.e. false is defaulted when the field is not present in the request) then I'm fine with this. Our semver contract dictates that we maintain API backwards compatiblilty.

vdice commented 7 years ago

Jenkins, test this please.

kwent commented 7 years ago

@bacongobbler If you don't pass deploy_now attribute to the POST /v2/apps/example-go/builds/ endpoint. It's defaulted to true by default. So not changing the default behavior and maintaining backwards compatibility.

vdice commented 7 years ago

@kwent thanks for the PR! Will the additional code and workflow-cli PR(s) covering the TODOs mentioned in the description also be ready soon as well? I've added this to the 2.13 milestone currently scheduled for April 5th.

kwent commented 7 years ago

@vdice I did some work on it . (Updated description). But i might need some help. Not sure i covered everything that needs to be updated.

vdice commented 7 years ago

@kwent Great, thanks. I'll take a look at all of the PRs soon but in the meantime, when convenient, can you squash and rebase this into one commit, while also adding requires workflow-cli#296 somewhere in the git commit message like so? That way the e2e run should pick up/use the workflow-cli artifact as well...

codecov-io commented 7 years ago

Codecov Report

Merging #1269 into master will decrease coverage by 0.03%. The diff coverage is 86.66%.

@@            Coverage Diff             @@
##           master    #1269      +/-   ##
==========================================
- Coverage   87.29%   87.25%   -0.04%     
==========================================
  Files          44       44              
  Lines        3887     3900      +13     
  Branches      675      676       +1     
==========================================
+ Hits         3393     3403      +10     
- Misses        326      329       +3     
  Partials      168      168

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 24675b5...71cff13. Read the comment docs.

kwent commented 7 years ago

@vdice Done.

vdice commented 7 years ago

Jenkins, test this please.

kwent commented 7 years ago

@vdice Jenkins failed with

Installing Workflow CLI version '37ede0d' via url 'https://storage.googleapis.com/workflow-cli-master/37ede0d/deis-37ede0d-linux-amd64'
17:17:05 curl: (22) The requested URL returned error: 404 Not Found
vdice commented 7 years ago

@kwent Ah yes -- we need to get the workflow-cli artifact building (and uploaded) from https://github.com/deis/controller-sdk-go/pull/118 -- encountering build errors currently; will comment on that ticket.

vdice commented 7 years ago

Jenkins, test this please.

vdice commented 7 years ago

E2E tests success! :tada: https://ci.deis.io/job/workflow-chart-e2e/1076/consoleFull

bacongobbler commented 7 years ago

So this PR adds the idea of delaying the release... But after the release has been delayed, how does one deploy it with the CLI? Can you run me through the typical story on how one would use this feature? I see reference documentation on the API but nothing on how one would actually use this feature in the real world.

bacongobbler commented 7 years ago

Essentially I'm looking for another section in https://deis.com/docs/workflow/applications/deploying-apps/ to flesh this feature out.

kwent commented 7 years ago

@bacongobbler

Here is my workflow story:

We have an Jenkins listening to our git push and doing the build for us. Output of this process is docker image. We don't want to deploy them now but we want deis to be aware of those builds and let the developer choose what release to deploy later on via deis deploy / deis releases:deploy.

mboersma commented 7 years ago

These PRs haven't been updated in a few months. @kwent I'm going to close this, but please re-open if you can address the remaining issues, and thanks again!