Page MenuHomePhabricator

Allow deploying services from a branch
Closed, InvalidPublic

Description

Currently, Scap only supports deploying the master branch of the service deploy repo. Generally, this works well for normal deployment pipeline for simple features, however, for more complicated and risky deployments this is not enough.

When some code is merged into deployment repo master, deployment of other features/fixes is blocked until the HEAD of the master is deployed into production. For risky, large changes, we sometimes need to hold a change in the beta cluster, or on canary nodes in production for an extended period of time and during that period we're effectively blocked out of deployments. If the need for a quick fix arises we're facing a complex situation when the master of the deploy repo has to be reset to the same state as currently deployed into production. In order to avoid that, we would like to be able to create feature branches in the deploy repo of the service and deploy them via scap, thus we need the ability to deploy via scap from a branch other than the master branch.

Event Timeline

This should work already.

It works in the scap test setup:

vagrant@stretch:/srv/deployment/mockbase/deploy$ ssh scap-target-01 -- git -C /srv/deployment/mockbase/deploy rev-parse --verify HEAD
bea157c445842f9f69ffcf56d43ed4c21925d67e
vagrant@stretch:/srv/deployment/mockbase/deploy$ git rev-parse --verify HEAD
bea157c445842f9f69ffcf56d43ed4c21925d67e
vagrant@stretch:/srv/deployment/mockbase/deploy$ git branch
* master
  test
vagrant@stretch:/srv/deployment/mockbase/deploy$ git checkout test
Switched to branch 'test'
vagrant@stretch:/srv/deployment/mockbase/deploy$ scap deploy -fl scap-target-01 'test'
15:49:50 Unable to find remote tracking branch/tag for /srv/deployment/mockbase/deploy
15:49:50 Started deploy [mockbase/deploy@UNKNOWN]
15:49:50 Deploying Rev: HEAD = a9a823ee56de8c5016bd005bea39f7d27b68776b
15:49:50 Started deploy [mockbase/deploy@UNKNOWN]: test
15:49:50 
== DEFAULT ==
:* scap-target-01
mockbase/deploy: fetch stage(s): 100% (ok: 1; fail: 0; left: 0)                 
mockbase/deploy: config_deploy stage(s): 100% (ok: 1; fail: 0; left: 0)         
mockbase/deploy: promote and restart_service stage(s): 100% (ok: 1; fail: 0; left: 0)
15:49:56 
== DEFAULT ==
:* scap-target-01
mockbase/deploy: finalize stage(s): 100% (ok: 1; fail: 0; left: 0)              
15:49:57 Finished deploy [mockbase/deploy@UNKNOWN]: test (duration: 00m 07s)
15:49:57 Finished deploy [mockbase/deploy@UNKNOWN] (duration: 00m 07s)
vagrant@stretch:/srv/deployment/mockbase/deploy$ ssh scap-target-01 -- git -C /srv/deployment/mockbase/deploy rev-parse --verify HEAD
a9a823ee56de8c5016bd005bea39f7d27b68776b
vagrant@stretch:/srv/deployment/mockbase/deploy$ git rev-parse --verify HEAD
a9a823ee56de8c5016bd005bea39f7d27b68776b

Scap checks out a specific SHA1 onto targets. That SHA1 comes from either specifying --rev [SHA1] or specifying a specific git_rev in scap.cfg. If neither one of those are set, it falls back to HEAD.

You can check the commit that scap wants to deploy by looking at the git_rev in .git/DEPLOY_HEAD on the deployment host. If you haven't specified a rev it should match the output of: git rev-parse --verify HEAD. You can see it update with scap deploy --init (this won't deploy, but it should update the .git/DEPLOY_HEAD file that will be used in subsequent deploys).

Let me know if this isn't working as expected or if I'm misunderstanding the use-case.

Pchelolo edited projects, added Services (done); removed Services (watching).

It indeed works, thank you and sorry for false report.