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

drush fails to receive output from non interactive ssh commands in some circumstances #2805

Closed
johnennewdeeson opened this issue Jun 12, 2017 · 4 comments

Comments

@johnennewdeeson
Copy link

johnennewdeeson commented Jun 12, 2017

Hi,

I'm using docker and the following docker image to provide an SSH container https://hub.docker.com/r/jeroenpeeters/docker-ssh/

I want to access a docker based Drupal site using drush and drush aliases. Everything works apart from drush commands that execute SSH commands non interactively. An example being user-login e.g. drush @docker uli

Degbugging shows the SSH command is executed but drush running outside of the container receives no output from the command. If I manually run the SSH command drush creates, it works fine so its just that the output is not ending up at the local version of drush running outside the container.

On further investigation I found that in backend.inc, the process pipe gets deliberately closed. If I comment this fclose out then the command works as expected.

The line is in _drush_backend_proc_open(). In drush 8.1.12 its line 389. I've copied it below along with the comment that goes above it:-

    // If we do not close stdin here, then we cause a deadlock;
    // see: http://drupal.org/node/766080#comment-4309936
    // If we reimplement interactive commands to also use
    // _drush_proc_open, then clearly we would need to keep
    // this open longer.
    fclose($process['pipes'][0]); // <-- if I comment this line out drush @docker uli works as expected

Clearly this works in most environments, I was wondering what might be special with my setup that requires the removal of this line? What is it even there for? I couldn't work it out from the comment!

If others happen across this issue then maybe an optional toggle can be added to an alias to prevent this?

@johnennewdeeson
Copy link
Author

While debugging I also found that adding a pause before closing the process causes drush @docker uli to work as well. Don't know what this means!

    // If we do not close stdin here, then we cause a deadlock;
    // see: http://drupal.org/node/766080#comment-4309936
    // If we reimplement interactive commands to also use
    // _drush_proc_open, then clearly we would need to keep
    // this open longer.
    usleep(3000000);
    fclose($process['pipes'][0]);

@greg-1-anderson
Copy link
Member

I believe that the deadlock only happens on Windows systems. We might potentially be able to just conditionally only close this pipe on Windows boxes. Not sure if that might cause problems if the local system was non-Windows connecting to Azure or something.

@greg-1-anderson
Copy link
Member

Please confirm if this is still an issue on the HEAD of master. Drush is now using the Symfony Process component rather than backend invoke. Should work better.

@johnennewdeeson
Copy link
Author

Sorry, we stopped ssh'ing into Docker containers so I don't have an environment to test this anymore.
We do some magic inside of a drush.wrapper script to rewrite docker aliased commands so they get passed through docker exec instead now, its quite cool if you're using Docker for local development env.

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

No branches or pull requests

2 participants