deployer icon indicating copy to clipboard operation
deployer copied to clipboard

The `cleanup` task leaves last N releases including failed ones

Open sustmi opened this issue 10 years ago • 13 comments

Example:

Option keep_releases set to 5. I have successful releases:

20160101000001
20160101000002
20160101000003
20160101000004
20160101000005

Now I want to deploy new release, but the deployment fails. I do it few more times, before I fix the bug, so my releases directory now looks like this (asterisk marks failed releases):

20160101000001
20160101000002
20160101000003
20160101000004
20160101000005
20160101000006 (*)
20160101000007 (*)
20160101000008 (*)
20160101000009 (*)
20160101000010 (*)
20160101000011 (*)
20160101000012 (*)

(There are more than 5 release directories because the cleanup task runs only if the deploy finishes with success.)

Now I finally fix the bug, the deploy finishes successfully and my releases directory looks like this:

20160101000009 (*)
20160101000010 (*)
20160101000011 (*)
20160101000012 (*)
20160101000013

If I decide to rollback to previous release, I have no successfully deployed release to rollback to.

Expected behaviour

The cleanup command should leave at least keep_releases number of successful releases.

sustmi avatar Mar 10 '16 17:03 sustmi

Agree, not is deploy fails it's does not clean up. But it's good, becouse you can always login into server and check that is going on.

I think better approach is no disable second deploy is there is broken releases. Ant you must manually run clean up command.

antonmedv avatar Mar 11 '16 06:03 antonmedv

Think for yourself, what's better: 3 cleaned up broken releases or 10 were at least 1 working release is there?

Am 11.03.2016 um 07:17 schrieb Anton Medvedev [email protected]:

Agree, not is deploy fails it's does not clean up. But it's good, becouse you can always login into server and check that is going on.

I think better approach is no disable second deploy is there is broken releases. Ant you must manually run clean up command.

— Reply to this email directly or view it on GitHub.

sr972 avatar Mar 11 '16 06:03 sr972

I am not sure if we understand each other well. I like that when a release fails, its directory stays on server and I can check its state manually. I also like the automatic cleaning. But I do not like that in situation like in my example I end-up with only one working release and four broken.

I think that cleanup command should distinguish between successful release and failed releases and always leave N successful releases.

Maybe we could have a separate command to delete the broken releases. Or maybe there could be a "redeploy" command, that would overwrite the last failed release.

I will try to think it through to realise which flow would be the best (at least from my point of view).

sustmi avatar Mar 11 '16 07:03 sustmi

Agree, i think releases dir must contains only working releases. Better way is to disable deploy and cleanup if one of releases dirs contains broken release.

antonmedv avatar Mar 11 '16 07:03 antonmedv

That is an amazing idea! Lets deploy the code to a temporary directory first (named eg. workspaces/{release number}) and the second last step (before switching the symlink to the new release) will be moving the directory to the releases directory. Sounds good to me.

sustmi avatar Mar 11 '16 07:03 sustmi

@sustmi Ok got you now. Well i think about some modifications in deployer too. So we could 'tag' releases with e.g. a file. Let's say a file called .deployer.release.yaml with status like failed, sucessfull and so on. There are other improvement ideas i want to work out. This already was one of them.

sr972 avatar Mar 11 '16 07:03 sr972

I'm thinking about placing RELEASE file into each of successfully release dirs.

antonmedv avatar Mar 11 '16 08:03 antonmedv

@elfet I would recommend not to use a file called RELEASE for several reasions

  • May be overwritten by someone else that delivers a RELEASE file
  • May be a security risk as it may deliver sensitive informations as it is readable by default in apache/nginx
  • ... to be continued

I really would use a dot file like i said above. So you could keep release sensitive informations in this file, like state of release process, should it be protected by/for cleanup process and (a thing i plan to make a PR) keep the 'internal' releasenumber from deployer (datetime) for e.g. rollback while my real release number could be entered / generated the way i want like 1.9.2.4 or so on.

Any suggestions or opinions on that?

sr972 avatar Mar 11 '16 09:03 sr972

Separate file for this also good solution. May be it's better to have file names .releases in deploy path with list of releases dirs.

antonmedv avatar Mar 11 '16 10:03 antonmedv

Ok, as it goes offtopic, i will open a new task for discussion, when i finished my ideas on this. But can't make any promises as my schedule is full of task right now :)

sr972 avatar Mar 11 '16 10:03 sr972

Ok, amy be will implement it myself.

antonmedv avatar Mar 11 '16 12:03 antonmedv

Another inspiration could be how Rocketeer handles this: it stores a file called state.json next to current, releases and shared which is a simple map of release names and boolean values indicating deployment success or failure.

mbrodala avatar Mar 19 '16 21:03 mbrodala

Fixed in v4. Now fail release deleted before deploy.

antonmedv avatar Nov 07 '16 17:11 antonmedv