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

Airbrussh::Rake::Context needs to be redesigned to be thread-safe? #81

Open
mattbrictson opened this issue May 13, 2016 · 2 comments
Open
Labels

Comments

@mattbrictson
Copy link
Owner

The Context class is built around the assumption that a given Rake task is fully completed before moving onto the next task. For example, even when Capistrano is deploying to multiple servers in parallel, the concurrency happens within a single task. In other words, all SSH executions for that task must finish before moving onto the next task.

However this assumption fails when Capistrano's invoke DSL is used within an SSHKit on block. Doing this leads to scenarios where one Rake task partially executes, then another task, and then back to the original task. In a multi-server deployment, this task switching can happen at different times in different threads.

Airbrussh::Rake::Context fails to track the current task in such scenarios. In fact, Airbrussh's entire output formatting is predicated on the linear progression of Rake tasks.

I don't know if a redesign is warranted, but it is certainly something to think about, especially if invoke is used this way often.

Perhaps the solution is to use a stack to track task execution, rather than a single variable, and to keep a separate stack in each thread.

See original discussion in #78.

@neovatar
Copy link

neovatar commented Dec 22, 2016

Just stumbled over this. We use invokes like

task('options:parse').invoke([:release_tag, :project_name, :repo_url])

in our capistrano tasks (e.g. deploy). This invoke just checks for some required options from the rake command line. Then the original task (deploy) is continued. But airbussh outputs 'options:parse' as task.

I disabled it by setting the config option "monkey_patch_rake = false", because the output is very confusing (wrong task name). Is there a workaround for this, like setting the rake task context for airbrussh after calling an invoke?

@mattbrictson
Copy link
Owner Author

This is a tough one. I don't think there is an easy workaround. You could try explicitly setting the task name, but I'm not sure it would produce the right results:

Airbrussh::Rake::Context.current_task_name = "deploy"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants