Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #332 - Uninstalling all older gems when autoupdating #493

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion fixtures/scripts/_head.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,3 @@ function halt_nodes {
echo "Node at TCP port ${p} stopped!"
done
}

11 changes: 11 additions & 0 deletions fixtures/scripts/redeploy-on-upgrade.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ function start_node {
cd ..
}

echo "Installing old version of zold"
gem install zold --version 0.0.1

high=$(reserve_port)
primary=$(start_node ${high} 9.9.9 --standalone)

Expand All @@ -24,6 +27,14 @@ trap "halt_nodes ${high}" EXIT

wait_for_file ${low}/restarted

echo "Check if old version has been uninstalled"
zold_gems=$(gem list zold)
if [[ "${zold_gems}" == *"zold"* ]]; then
echo "Old versions of Zold gem have not been uninstalled"
exit 16
fi
sleep 5

echo "High node logs (port ${high}):"
cat ${high}/log
echo "Low node logs (port ${low}):"
Expand Down
4 changes: 3 additions & 1 deletion lib/zold/commands/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ def nohup(opts)
begin
code = exec("#{myself} #{args.join(' ')}", nohup_log)
raise "Exit code is #{code}" if code != 0
exec(opts['nohup-command'], nohup_log)
Open3.popen3('gem uninstall zold -a --ignore-dependencies') do
exec(opts['nohup-command'], nohup_log)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emilianodellacasa this looks a bit weird... First, we won't see the output of that uninstall. Second, what if the user wants to change the command and do sudo gem uninstall? It's impossible, right? I would better simply change the default command in nohup-command to something like gem uninstall && gem install

Copy link
Contributor Author

@emilianodellacasa emilianodellacasa Oct 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yegor256 What if we add another option to ./zold to change the uninstall command to whatever the user wants? Also, I don't see the problem in not showing the output of the uninstall, the user won't see it anyway.

Lastly, by including the uninstall command in the nohup-command as you propose , user could skip that part and I think it is important that there is only one instance of Zold gem running.

end
rescue StandardError => e
nohup_log.print(Backtrace.new(e).to_s)
if cycle < opts['nohup-max-cycles']
Expand Down