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

Deploy failed on rsync if no port is provided via YAML configuration #1227

Closed
dakur opened this issue May 22, 2017 · 6 comments
Closed

Deploy failed on rsync if no port is provided via YAML configuration #1227

dakur opened this issue May 22, 2017 · 6 comments
Labels

Comments

@dakur
Copy link

dakur commented May 22, 2017

Q A
Issue Type Bug
Deployer Version 5.0.0
Local Machine OS Ubuntu 14.04.5 LTS
Remote Machine OS Ubuntu 14.04.5 LTS

Description

If I do not provide a port directive in YAML configuration (did not try in PHP array config), deploy fails on rsync command with error message Bad port '-l'
In the run ssh subcommand is -p parameter, but no port number provided: rsync -azP -e 'ssh -p ' ../dist/ someuser@10.0.0.2:/var/www/web/dev/releases/75

Steps to reproduce

Config your deploy like this:

.deploy-template: &deploy-template
    ssh_type: native
    ssh_multiplexing: true

    user: someuser
#    port: 22 # do not provide this
    identityFile: /root/.ssh/id_rsa


10.0.0.2:
    <<: *deploy-template
    stage: development
    deploy_path: /var/www/web/dev

Content of deploy.php

<?php

namespace Deployer;


/** @noinspection PhpIncludeInspection recipe comes from Deployer tool */
require_once 'recipe/common.php';


// deploy stages settings
inventory(__DIR__ . '/config.yml');


// task
task('deploy:copy', function () {
	upload('../dist/', '{{release_path}}');
});


// deploy process
desc('Deploy your project');
task('deploy', [
	'deploy:prepare', // checks env and prepares folder for new release
	'deploy:lock',
	'deploy:release',

	'deploy:copy',

	'deploy:copy_dirs',

	'deploy:symlink', // swap to current release

	'deploy:unlock',
	'cleanup', // remove old releases
	'success',
]);

// automatically unlock if deploy fails
after('deploy:failed', 'deploy:unlock');

Output log

➤ Executing task deploy:prepare
[10.0.0.2] > echo $0
[10.0.0.2] < ssh multiplexing initialization
[10.0.0.2] < bash
[10.0.0.2] > if [ ! -d /var/www/web/dev ]; then mkdir -p /var/www/web/dev; fi
[10.0.0.2] > if [ ! -L /var/www/web/dev/current ] && [ -d /var/www/web/dev/current ]; then echo true; fi
[10.0.0.2] > cd /var/www/web/dev && if [ ! -d .dep ]; then mkdir .dep; fi
[10.0.0.2] > cd /var/www/web/dev && if [ ! -d releases ]; then mkdir releases; fi
[10.0.0.2] > cd /var/www/web/dev && if [ ! -d shared ]; then mkdir shared; fi
• done on [10.0.0.2]
✔ Ok [1s 132ms]
➤ Executing task deploy:lock
[10.0.0.2] > if [ -f /var/www/web/dev/.dep/deploy.lock ]; then echo 'true'; fi
[10.0.0.2] > touch /var/www/web/dev/.dep/deploy.lock
• done on [10.0.0.2]
✔ Ok [38ms]
➤ Executing task deploy:release
[10.0.0.2] > cd /var/www/web/dev && (if [ -h release ]; then echo 'true'; fi)
[10.0.0.2] < true
[10.0.0.2] > cd /var/www/web/dev && (rm -rf "$(readlink release)")
[10.0.0.2] > cd /var/www/web/dev && (rm release)
[10.0.0.2] > cd /var/www/web/dev && ([ -d releases ] && [ "$(ls -A releases)" ] && echo "true" || echo "false")
[10.0.0.2] < true
[10.0.0.2] > cd /var/www/web/dev && (cd releases && ls -t -1 -d */)
[10.0.0.2] < 70/
[10.0.0.2] < 71/
[10.0.0.2] < 72/
[10.0.0.2] < 73/
[10.0.0.2] < 74/
[10.0.0.2] > cd /var/www/web/dev && (if [ -f .dep/releases ]; then echo "true"; fi)
[10.0.0.2] < true
[10.0.0.2] > cd /var/www/web/dev && (tail -n 15 .dep/releases)
[10.0.0.2] < 20170519131650,62
[10.0.0.2] < 20170519131726,63
[10.0.0.2] < 20170519132543,64
[10.0.0.2] < 20170519132842,65
[10.0.0.2] < 20170522081201,66
[10.0.0.2] < 20170522081429,67
[10.0.0.2] < 20170522081505,68
[10.0.0.2] < 20170522083904,69
[10.0.0.2] < 20170522084109,70
[10.0.0.2] < 20170522084310,71
[10.0.0.2] < 20170522084457,72
[10.0.0.2] < 20170522084625,73
[10.0.0.2] < 20170522084808,74
[10.0.0.2] < 20170522085344,75
[10.0.0.2] < 20170522085922,75
[10.0.0.2] > cd /var/www/web/dev && (if [ -d /var/www/web/dev/releases/75 ]; then echo 'true'; fi)
[10.0.0.2] > cd /var/www/web/dev && (date +"%Y%m%d%H%M%S")
[10.0.0.2] < 20170522090338
[10.0.0.2] > cd /var/www/web/dev && (echo '20170522090338,75' >> .dep/releases)
[10.0.0.2] > cd /var/www/web/dev && (mkdir /var/www/web/dev/releases/75)
[10.0.0.2] > cd /var/www/web/dev && (if [[ $(man ln 2>&1 || ln -h 2>&1 || ln --help 2>&1) =~ '--relative' ]]; then echo 'true'; fi)
[10.0.0.2] < true
[10.0.0.2] > cd /var/www/web/dev && (ln -nfs --relative /var/www/web/dev/releases/75 /var/www/web/dev/release)
• done on [10.0.0.2]
✔ Ok [288ms]
➤ Executing task deploy:copy
[10.0.0.2] > if [ -h /var/www/web/dev/release ]; then echo 'true'; fi
[10.0.0.2] < true
[10.0.0.2] > readlink /var/www/web/dev/release
[10.0.0.2] < releases/75
[10.0.0.2] > rsync -azP -e 'ssh -p ' ../dist/ someuser@10.0.0.2:/var/www/web/dev/releases/75
[10.0.0.2] < Bad port '-l'
[10.0.0.2] < rsync: connection unexpectedly closed (0 bytes received so far) [sender]
[10.0.0.2] < rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.1]
➤ Executing task deploy:failed
• done on [10.0.0.2]
✔ Ok [0ms]
➤ Executing task deploy:unlock
[10.0.0.2] > rm -f /var/www/web/dev/.dep/deploy.lock
• done on [10.0.0.2]
✔ Ok [20ms]

                                                                               
  [Symfony\Component\Process\Exception\ProcessFailedException]                 
  The command "rsync -azP -e 'ssh -p ' ../dist/ someuser@10.0.0.2:/va  
  r/www/web/dev/releases/75" failed.                         
  Exit Code: 255(Unknown error)                                                
  Working directory: /builds/gitlabgroup/web/deploy             
  Output:                                                                      
  ================                                                             
  Error Output:                                                                
  ================                                                             
  Bad port '-l'                                                                
  rsync: connection unexpectedly closed (0 bytes received so far) [sender]     
  rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.1]        
                                                                               

Exception trace:
 () at /root/.composer/vendor/symfony/process/Process.php:232
 Symfony\Component\Process\Process->mustRun() at /root/.composer/vendor/deployer/deployer/src/Utility/Rsync.php:47
 Deployer\Utility\Rsync->call() at /root/.composer/vendor/deployer/deployer/src/functions.php:434
 Deployer\upload() at /builds/gitlabgroup/web/deploy/deploy.php:16
 Deployer\Deployer::Deployer\{closure}() at n/a:n/a
 call_user_func() at /root/.composer/vendor/deployer/deployer/src/Task/Task.php:82
 Deployer\Task\Task->run() at /root/.composer/vendor/deployer/deployer/src/Executor/SeriesExecutor.php:63
 Deployer\Executor\SeriesExecutor->run() at /root/.composer/vendor/deployer/deployer/src/Console/TaskCommand.php:135
 Deployer\Console\TaskCommand->execute() at /root/.composer/vendor/symfony/console/Command/Command.php:264
 Symfony\Component\Console\Command\Command->run() at /root/.composer/vendor/symfony/console/Application.php:835
 Symfony\Component\Console\Application->doRunCommand() at /root/.composer/vendor/deployer/deployer/src/Console/Application.php:132
 Deployer\Console\Application->doRunCommand() at /root/.composer/vendor/symfony/console/Application.php:200
 Symfony\Component\Console\Application->doRun() at /root/.composer/vendor/symfony/console/Application.php:124
 Symfony\Component\Console\Application->run() at /root/.composer/vendor/deployer/deployer/src/Deployer.php:315
 Deployer\Deployer::run() at /root/.composer/vendor/deployer/deployer/bin/dep:120

deploy [-p|--parallel] [-l|--limit LIMIT] [--no-hooks] [--log LOG] [--roles ROLES] [--hosts HOSTS] [--] [<stage>]

ERROR: Job failed: exit code 1
@dakur
Copy link
Author

dakur commented May 22, 2017

P.S.: I would expect the default SSH port 22 will be set.

@antonmedv
Copy link
Member

I think bug in yaml loading of port value. Should not set null in there no port in inventory.

@dirx
Copy link
Contributor

dirx commented May 25, 2017

Run into something similar - missing identityFile in extra rsync options.

Why not using ssh arguments as a replacement for port only logic in upload & download functions:

       $sshArguments = $host->getSshArguments()->getCliArguments();
       if (empty($sshArguments) === false) {
           $config['options'] = ["-e 'ssh $sshArguments'"];
       }

@antonmedv
Copy link
Member

@dirx what if user specify everything but not -e? I think we need more intuitive system. Maybe smart merging of ssh arguments? Anyone wish to make a PR?

antonmedv added a commit that referenced this issue May 26, 2017
Fixes upload / download with optional rsync ssh option #1227
@dakur
Copy link
Author

dakur commented Jun 8, 2017

@antonmedv I guess this is fixed by #1240 ?

@antonmedv
Copy link
Member

True.

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

3 participants