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

Add verbosity level and quiet flag in ssh command based on debug flag #5869

Merged

Conversation

thelovekesh
Copy link
Member

@thelovekesh thelovekesh commented Nov 10, 2023

Fixes: #5378
Related #5859

As reported in the above ticket, in case the SSH command fails it doesn't output the exact reason why it's failing because it uses the -q flag in it which suppresses SSH command logs as per its man page.

Suppressing the SSH logs makes sense to keep the WP CLI output cleaner, but it can be hard to debug due to the lack of proper logs. This PR proposes to replace the -q flag with -vvv flag while using the --debug flag with the wp command.

Examples

wp --ssh=wordpress:/my/path --version
> wp '--ssh=wordpress:/my/path' '--version'
Error: Cannot connect over SSH using provided configuration.
Script wp handling the wp event returned with error code 255
wp --debug --ssh=wordpress:/my/path --version
> wp '--debug' '--ssh=wordpress:/my/path' '--version'
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\DeclareAbstractBaseCommand (0.004s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\IncludeFrameworkAutoloader (0.004s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\ConfigureRunner (0.004s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\IncludeRequestsAutoloader (0.004s)
Debug (bootstrap): Setting RequestsLibrary::$version to v2 (0.004s)
Debug (bootstrap): Setting RequestsLibrary::$source to wp-core (0.004s)
Debug (bootstrap): Setting RequestsLibrary::$class_name to \WpOrg\Requests\Requests (0.004s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\InitializeColorization (0.004s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\InitializeLogger (0.004s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\DefineProtectedCommands (0.004s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\LoadExecCommand (0.005s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\LoadRequiredCommand (0.005s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\IncludePackageAutoloader (0.005s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\IncludeFallbackAutoloader (0.005s)
Debug (bootstrap): Fallback autoloader paths: /home/thelovekesh/Desktop/work/travelopia/moorings/vendor/wp-cli/wp-cli/vendor/autoload.php (0.005s)
Debug (bootstrap): Loading detected autoloader: /home/thelovekesh/Desktop/work/travelopia/moorings/vendor/wp-cli/wp-cli/vendor/autoload.php (0.005s)
Debug (bootstrap): Attaching command 'config edit' to hook before_wp_load (0.008s)
Debug (bootstrap): Attaching command 'config path' to hook before_wp_load (0.008s)
Debug (bootstrap): Attaching command 'config list' to hook before_wp_load (0.008s)
Debug (bootstrap): Attaching command 'config get' to hook before_wp_load (0.008s)
Debug (bootstrap): Attaching command 'config is-true' to hook before_wp_load (0.009s)
Debug (bootstrap): Attaching command 'config set' to hook before_wp_load (0.009s)
Debug (bootstrap): Attaching command 'config delete' to hook before_wp_load (0.009s)
Debug (bootstrap): Attaching command 'config has' to hook before_wp_load (0.009s)
Debug (bootstrap): Attaching command 'config shuffle-salts' to hook before_wp_load (0.009s)
Debug (commands): Adding command: config (0.009s)
Debug (bootstrap): Attaching command 'core download' to hook before_wp_load (0.009s)
Debug (bootstrap): Attaching command 'core version' to hook before_wp_load (0.01s)
Debug (commands): Adding command: core (0.01s)
Debug (bootstrap): Attaching command 'eval' to hook before_wp_load (0.01s)
Debug (commands): Adding command: eval (0.01s)
Debug (bootstrap): Attaching command 'eval-file' to hook before_wp_load (0.01s)
Debug (commands): Adding command: eval-file (0.01s)
Debug (bootstrap): Attaching command 'db' to hook after_wp_config_load (0.011s)
Debug (bootstrap): Attaching command 'db clean' to hook after_wp_load (0.011s)
Debug (bootstrap): Attaching command 'db tables' to hook after_wp_load (0.011s)
Debug (bootstrap): Attaching command 'db size' to hook after_wp_load (0.011s)
Debug (bootstrap): Attaching command 'db prefix' to hook after_wp_load (0.011s)
Debug (bootstrap): Attaching command 'db search' to hook after_wp_load (0.011s)
Debug (bootstrap): Attaching command 'db columns' to hook after_wp_load (0.011s)
Debug (commands): Adding command: db (0.011s)
Debug (commands): Adding command: comment (0.011s)
Debug (commands): Adding command: meta in comment Namespace (0.012s)
Debug (commands): Adding command: menu (0.012s)
Debug (commands): Adding command: item in menu Namespace (0.012s)
Debug (commands): Adding command: location in menu Namespace (0.012s)
Debug (commands): Deferring command: network meta (0.012s)
Debug (commands): Adding command: option (0.013s)
Debug (commands): Adding command: post (0.013s)
Debug (commands): Adding command: meta in post Namespace (0.013s)
Debug (commands): Adding command: term in post Namespace (0.013s)
Debug (commands): Adding command: post-type (0.014s)
Debug (commands): Adding command: site (0.014s)
Debug (commands): Adding command: meta in site Namespace (0.014s)
Debug (commands): Adding command: option in site Namespace (0.014s)
Debug (commands): Adding command: taxonomy (0.015s)
Debug (commands): Adding command: term (0.015s)
Debug (commands): Adding command: meta in term Namespace (0.015s)
Debug (commands): Adding command: user (0.016s)
Debug (commands): Adding command: application-password in user Namespace (0.016s)
Debug (commands): Adding command: meta in user Namespace (0.016s)
Debug (commands): Adding command: session in user Namespace (0.016s)
Debug (commands): Adding command: term in user Namespace (0.016s)
Debug (commands): Adding command: network (0.016s)
Debug (hooks): Processing hook "after_add_command:network" with 1 callbacks (0.017s)
Debug (hooks): On hook "after_add_command:network": Closure in file /home/thelovekesh/Desktop/work/travelopia/moorings/vendor/wp-cli/wp-cli/php/class-wp-cli.php at line 695 (0.017s)
Debug (commands): Adding command: meta in network Namespace (0.017s)
Debug (commands): Adding command: plugin (0.018s)
Debug (commands): Adding command: auto-updates in plugin Namespace (0.018s)
Debug (commands): Adding command: theme (0.019s)
Debug (commands): Adding command: auto-updates in theme Namespace (0.019s)
Debug (commands): Adding command: mod in theme Namespace (0.019s)
Debug (bootstrap): Attaching command 'package' to hook before_wp_load (0.02s)
Debug (commands): Adding command: package (0.02s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\RegisterFrameworkCommands (0.02s)
Debug (bootstrap): Adding framework command: /home/thelovekesh/Desktop/work/travelopia/moorings/vendor/wp-cli/wp-cli/php/commands/cli.php (0.02s)
Debug (bootstrap): Attaching command 'cli' to hook before_wp_load (0.021s)
Debug (bootstrap): Attaching command 'cli has-command' to hook after_wp_load (0.021s)
Debug (commands): Adding command: cli (0.021s)
Debug (bootstrap): Attaching command 'cli cache' to hook before_wp_load (0.021s)
Debug (commands): Adding command: cache in cli Namespace (0.021s)
Debug (bootstrap): Attaching command 'cli alias' to hook before_wp_load (0.021s)
Debug (commands): Adding command: alias in cli Namespace (0.021s)
Debug (bootstrap): Adding framework command: /home/thelovekesh/Desktop/work/travelopia/moorings/vendor/wp-cli/wp-cli/php/commands/help.php (0.021s)
Debug (commands): Adding command: help (0.021s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\RegisterDeferredCommands (0.021s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\InitializeContexts (0.021s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\LaunchRunner (0.021s)
Debug (bootstrap): No readable global config found (0.022s)
Debug (bootstrap): No project config found (0.022s)
Debug (bootstrap): argv: /home/thelovekesh/Desktop/work/travelopia/moorings/vendor/wp-cli/wp-cli/bin/../php/boot-fs.php --debug --ssh=wordpress:/my/path --version (0.022s)
Debug (bootstrap): SSH scheme:  (0.022s)
Debug (bootstrap): SSH user:  (0.022s)
Debug (bootstrap): SSH host: wordpress (0.022s)
Debug (bootstrap): SSH port:  (0.022s)
Debug (bootstrap): SSH path: /my/path (0.022s)
Debug (bootstrap): SSH key:  (0.022s)
Debug (bootstrap): SSH proxyjump:  (0.022s)
Debug (bootstrap): Running SSH command: ssh -T -vvv 'wordpress' 'cd '\''/my/path'\''; wp '\''--debug'\'' '\''--version'\''' (0.022s)
OpenSSH_8.9p1 Ubuntu-3ubuntu0.4, OpenSSL 3.0.2 15 Mar 2022
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/thelovekesh/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/thelovekesh/.ssh/known_hosts2'
debug2: resolving "wordpress" port 22
debug3: resolve_host: lookup wordpress:22
ssh: Could not resolve hostname wordpress: Temporary failure in name resolution
Error: Cannot connect over SSH using provided configuration.
Script wp handling the wp event returned with error code 255

@thelovekesh thelovekesh requested a review from a team as a code owner November 10, 2023 20:02
@swissspidy
Copy link
Member

Nice, looks like the tests caught this change 👍

Copy link
Member

@danielbachhuber danielbachhuber left a comment

Choose a reason for hiding this comment

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

Can you update the pull request description to include:

  1. The significance of -q, and the implications of removing it?
  2. The behavior before and after the change?

Thanks!

Copy link
Member

@danielbachhuber danielbachhuber left a comment

Choose a reason for hiding this comment

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

Thanks for the detailed description, @thelovekesh !

@danielbachhuber danielbachhuber merged commit 00ca209 into wp-cli:main Nov 11, 2023
65 checks passed
@thelovekesh thelovekesh deleted the add/ssh-verbosity-wrt-debug-flag branch November 11, 2023 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display full output when there's an SSH connection error
3 participants