Fixed
Status Update
Comments
je...@google.com <je...@google.com> #2
Thanks for the report! I agree that the proposed behavior---having gcloud's exit status match the command's---would be a better behavior. I've created a ticket internally to track this.
ed...@gmail.com <ed...@gmail.com> #3
The problem described here has become worse lately (0.9.81).
The current behavior of `gcloud compute ssh` is to only ever return 0:
```
$ gcloud compute ssh root@REDACTED "exit 1"; echo $?
0
$ gcloud compute ssh root@REDACTED "exit 2"; echo $?
0
```
Unless the return value of the command was 255, which is special-cased in the gcloud SDK to mean 'error':
```
$ gcloud compute ssh root@REDACTED "exit 255"; echo $?
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255]. Seehttps://cloud.google.com/compute/docs/troubleshooting#ssherrors for troubleshooting hints.
1
```
This is a critical flaw in the implementation of 'gcloud compute ssh'. Please let exit code pass through from ssh, stop trying to interpret or block it.
The current behavior of `gcloud compute ssh` is to only ever return 0:
```
$ gcloud compute ssh root@REDACTED "exit 1"; echo $?
0
$ gcloud compute ssh root@REDACTED "exit 2"; echo $?
0
```
Unless the return value of the command was 255, which is special-cased in the gcloud SDK to mean 'error':
```
$ gcloud compute ssh root@REDACTED "exit 255"; echo $?
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255]. See
1
```
This is a critical flaw in the implementation of 'gcloud compute ssh'. Please let exit code pass through from ssh, stop trying to interpret or block it.
zj...@google.com <zj...@google.com> #4
Thanks for bringing this back to our attention. This should be fixed in the 0.9.85 release of the Cloud SDK.
[Deleted User] <[Deleted User]> #5
I am currently having this problem. Here's the error:
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255]. Seehttps://cloud.google.com/compute/docs/troubleshooting#ssherrors for troubleshooting hints.
Using gcloud ssh in cloud console.
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255]. See
Using gcloud ssh in cloud console.
[Deleted User] <[Deleted User]> #6
faddat@hazel-strand-116609:~/Apollo$ gcloud info
Google Cloud SDK [91.0.1]
Platform: [Linux, x86_64]
Python Version: [2.7.9 (default, Mar 1 2015, 12:57:24) [GCC 4.9.2]]
Python Location: [/usr/bin/python2]
Site Packages: [Disabled]
Installation Root: [/google/google-cloud-sdk]
Installed Components:
kubectl: []
app-engine-python: [1.9.30]
core-nix: [2015.11.24]
core: [2015.12.16]
app-engine-java: [1.9.30]
gcloud: []
gsutil-nix: [4.15]
app-engine-php: [ ]
beta: [2015.10.08]
gsutil: [4.16]
bq: [2.0.18]
alpha: [2015.10.08]
kubectl-linux-x86_64: [1.1.2]
bq-nix: [2.0.18]
System PATH: [/google/google-cloud-sdk/bin:/usr/local/nvm/versions/node/v0.12.7/bin:/home/faddat/gopath/bin:/google/gopath/bin:/usr/local/go/bin:/gradle-2.3/bin:/apache-maven-3.2.2/bin:/google/google-cloud-sdk/bin:/usr/local
/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/google/workspace-sync:/google/go_appengine:/google/google_appengine:/home/faddat/bin]
Cloud SDK on PATH: [True]
WARNING: There are old versions of the Google Cloud Platform tools on your system PATH.
/google/go_appengine/dev_appserver.py
/google/google_appengine/dev_appserver.py
Installation Properties: [/google/google-cloud-sdk/properties]
User Config Directory: [/tmp/tmp.OUPBI5R9wB]
User Properties: [/tmp/tmp.OUPBI5R9wB/properties]
Current Workspace: [None]
Workspace Config Directory: [None]
Workspace Properties: [None]
Account: [faddat@gmail.com]
Project: [hazel-strand-116609]
Current Properties:
[metrics]
environment: [devshell]
[core]
project: [hazel-strand-116609]
check_gce_metadata: [False]
account: [faddat@gmail.com]
disable_usage_reporting: [False]
[app]
docker_build: [local]
suppress_change_warning: [True]
[component_manager]
disable_update_check: [True]
Logs Directory: [/tmp/tmp.OUPBI5R9wB/logs]
Last Log File: [/tmp/tmp.OUPBI5R9wB/logs/2015.12.27/05.36.10.441187.log]
Google Cloud SDK [91.0.1]
Platform: [Linux, x86_64]
Python Version: [2.7.9 (default, Mar 1 2015, 12:57:24) [GCC 4.9.2]]
Python Location: [/usr/bin/python2]
Site Packages: [Disabled]
Installation Root: [/google/google-cloud-sdk]
Installed Components:
kubectl: []
app-engine-python: [1.9.30]
core-nix: [2015.11.24]
core: [2015.12.16]
app-engine-java: [1.9.30]
gcloud: []
gsutil-nix: [4.15]
app-engine-php: [ ]
beta: [2015.10.08]
gsutil: [4.16]
bq: [2.0.18]
alpha: [2015.10.08]
kubectl-linux-x86_64: [1.1.2]
bq-nix: [2.0.18]
System PATH: [/google/google-cloud-sdk/bin:/usr/local/nvm/versions/node/v0.12.7/bin:/home/faddat/gopath/bin:/google/gopath/bin:/usr/local/go/bin:/gradle-2.3/bin:/apache-maven-3.2.2/bin:/google/google-cloud-sdk/bin:/usr/local
/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/google/workspace-sync:/google/go_appengine:/google/google_appengine:/home/faddat/bin]
Cloud SDK on PATH: [True]
WARNING: There are old versions of the Google Cloud Platform tools on your system PATH.
/google/go_appengine/dev_appserver.py
/google/google_appengine/dev_appserver.py
Installation Properties: [/google/google-cloud-sdk/properties]
User Config Directory: [/tmp/tmp.OUPBI5R9wB]
User Properties: [/tmp/tmp.OUPBI5R9wB/properties]
Current Workspace: [None]
Workspace Config Directory: [None]
Workspace Properties: [None]
Account: [faddat@gmail.com]
Project: [hazel-strand-116609]
Current Properties:
[metrics]
environment: [devshell]
[core]
project: [hazel-strand-116609]
check_gce_metadata: [False]
account: [faddat@gmail.com]
disable_usage_reporting: [False]
[app]
docker_build: [local]
suppress_change_warning: [True]
[component_manager]
disable_update_check: [True]
Logs Directory: [/tmp/tmp.OUPBI5R9wB/logs]
Last Log File: [/tmp/tmp.OUPBI5R9wB/logs/2015.12.27/05.36.10.441187.log]
sc...@gmail.com <sc...@gmail.com> #7
@fab: This bug is about return codes of remote processes not making it back to the calling process.
Your report doesn't seem to say anything about that (because you didn't include your command line).
In gcloud versions > 0.9.85, the 255 return code simply means that your ssh didn't connect. Which can happen if the node wasn't running, if the node has a firewall in place blocking ssh, if the node's ssh daemon isn't running, or any of the innumerable other reasons a connection can fail.
If your problem isn't about return code values being properly passed, then this isn't your bug.
Your report doesn't seem to say anything about that (because you didn't include your command line).
In gcloud versions > 0.9.85, the 255 return code simply means that your ssh didn't connect. Which can happen if the node wasn't running, if the node has a firewall in place blocking ssh, if the node's ssh daemon isn't running, or any of the innumerable other reasons a connection can fail.
If your problem isn't about return code values being properly passed, then this isn't your bug.
Description
Running any command that returns a non-zero exit code via gcloud compute ssh:
gcloud compute ssh my-gce-instance --command="exit 3"; echo $?
What is the expected output? What do you see instead?
In this particular case, $? was 1. An equivalent ssh command sets $? to 3. The output of the gcloud command itself is actually
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [3].
In fact, all nonzero return values are translated to an exit code of 1 from gcloud. This makes scripting that depends on exit code fail.
What is the output of 'gcloud info'?
Google Cloud SDK [0.9.61]
Platform: [Linux, x86_64]
Python Version: [2.7.3 (default, Dec 18 2014, 19:10:20) [GCC 4.6.3]]
Site Packages: [Disabled]
Installation Root: [/home/scole/google-cloud-sdk]
Installed Components:
kubectl: []
app-engine-python: [1.9.20]
core-nix: [2015.05.26]
gcutil: [1.16.5]
gae-go: [2015.05.26]
gae-python: [2014.05.06]
core: [2015.05.19]
app-engine-go-linux-x86_64: [1.9.20]
gae-go-nix: [2015.05.26]
gcloud: [2015.05.19]
gsutil-nix: [4.12]
app-engine-python-extras: [1.9.21]
gsutil: [4.12]
bq: [2.0.18]
dns: [2015.05.26]
sql: [2015.05.26]
compute: [2015.05.19]
kubectl-linux-x86_64: [0.17.0]
gcutil-nix: [1.16.5]
bq-nix: [2.0.18]
System PATH: [/home/scole/google-cloud-sdk/bin:/home/scole/bin:/home/scole/google-cloud-sdk/bin:/home/scole/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/scole/.rvm/bin:/home/scole/fleet/bin:/home/scole/.rvm/bin]
Cloud SDK on PATH: [True]
Installation Properties: [/home/scole/google-cloud-sdk/properties]
User Config Directory: [/home/scole/.config/gcloud]
User Properties: [/home/scole/.config/gcloud/properties]
Current Workspace: [None]
Workspace Config Directory: [None]
Workspace Properties: [None]
Account: [steven_cole@playstation.sony.com]
Project: [XXXXX]
Current Properties:
[core]
project: [XXXXX]
account: [steven_cole@playstation.sony.com]
disable_usage_reporting: [False]
Logs Directory: [/home/scole/.config/gcloud/logs]
Last Log File: [/home/scole/.config/gcloud/logs/2015.06.03/15.27.04.652760.log]
Please provide any additional information below.