Rollback deletes wrong release

19 views
Skip to first unread message

booyah

unread,
Dec 14, 2009, 8:24:32 PM12/14/09
to Capistrano
I've been introduced to Capistrano by a colleague and must say i'm
loving it, however, I'm seeing some strange behaviour with the
rollback task:

for example, lets say I have 3 releases with 1 being the newest and 3
being the oldest. If I do cap deploy:rollback I would expect it to
roll back from release 1 to release 2 and release 1 would be deleted.

But what actually happens is that it rolls back from release 1 to
release 2 and release _3_ is deleted, even though the process of
recreating the symlink to the previous release (2) is done correctly.

any help is much appreciated...

Lee Hambley

unread,
Dec 15, 2009, 4:56:30 AM12/15/09
to capis...@googlegroups.com
Are you using file-based rails caching? We have an open bug for that, in a nutshell the `ls -xt` command we use, lists them in the `wrong` order if you are using file caching.

( this could be an easy fix, but how should we approach it? – thus we haven't )

-- Lee Hambley

Twitter: @leehambley | @capistranorb

booyah

unread,
Dec 15, 2009, 5:58:02 PM12/15/09
to Capistrano
I've come to the same conclusion. I'm not using file-based rails
caching. I'm just using it for deploying a PHP site and have
overridden a lot of the rails specific tasks in deploy.

The ordering of the releases from 'ls -xt' is the problem, but the
reason I think they're in the wrong order is because of the
timestamps. While the deploy task is running I can see that the new
release folder has correct timestamp ie now, but at the end of the
deploy task 'something' is setting the modification date of ALL the
release folders to the same timestamp, and it's completely wrong
(12-24 hours ago). Then the deploy:rollback gets it completely wrong
and the problem occurs.

Can you confirm if you're seeing the same behaviour?

I'm still trying to work out exactly where it's going wrong. I'm
trying touching release folders using before_ and after_ but still
haven't got a working solution.

booyah

unread,
Dec 15, 2009, 6:31:29 PM12/15/09
to Capistrano
I think I've been able to solve it by touched the latest release
folder after update_code:

task :after_update_code, :roles => [:web] do
# Sleep may not be needed
run "sleep 1"
run "touch #{latest_release}"
end

I deleted all releases and did a number of deploys and rollbacks and
they all worked ok. By setting the timestamp at the end of the
update_code task, the ls -xt in rollback returns the releases in the
right order.

If anyone else is having this problem please let me know if this fix
works for you too.

booyah

unread,
Dec 16, 2009, 2:28:02 AM12/16/09
to Capistrano
nb. I've found that run'ing any command that modifies any release
folder or its contents will cause the dodgy timestamp to appear
again. So be careful what you do in a :before_update_code task...

Lee Hambley

unread,
Dec 16, 2009, 10:00:39 AM12/16/09
to capis...@googlegroups.com
The solution is to figure out the way that works for your infrastructure to `ls` them in the right way, then you can overload this default:
set(:releases)          { capture("ls -xt #{releases_path}").split.reverse }
Defined in:
http://github.com/capistrano/capistrano/blob/master/lib/capistrano/recipes/deploy.rb#L53

You must use set() not _cset() when you redefine this, but you should figure one that works for your environment - we need to address this in the master (next bug fix release) Current ticket is at:
Reply all
Reply to author
Forward
0 new messages