openshift / openshift/origin

"oc debug" should exit non-zero when the executed command returns non-zero

Open
#15,854 9 comments 2 reactions 1 assignee View on GitHub

@juanvallejo is already working on this.

Since Feb 2, 2018.

component/cli lifecycle/frozen
Dominant language
Go
Stars
8.7k
Forks
4.8k
Avg merge
4d 10h
Merged PRs (30d)
53

Description

The oc debug command seems to always exit with a shell status code of 0 even when the executed command exits non-zero. This is counter intuitive and makes using oc debug in a set -e shell script difficult.

There should a new flag to tell oc debug to exit non-zero when the executed command exits non-zero, or even better, to make oc debug exit the same exit code as the executed command.

Version
[root@xxx-master ~]# oc version
oc v1.5.1
kubernetes v1.5.2+43a9be4
features: Basic-Auth GSSAPI Kerberos SPNEGO

Server https://openshift.example.com:8443
openshift v1.5.1
kubernetes v1.5.2+43a9be4
Steps To Reproduce
oc run busybox --image=busybox:ubuntu --replicas=0 # creates a sample DC with no replicas
oc debug dc/busybox -- /bin/true                   # run a successful command
echo $?                                            # => 0 (as expected)
oc debug dc/busybox -- /bin/false                  # run an unsuccessful command
echo $?                                            # => 0 (expected: 1)
oc debug dc/busybox -- /bin/non-existent           # run a non-existent command
echo $?                                            # => 0 (expected: 127)
Current Result

All 3 oc debug commands above exit with status 0.

Expected Result

The above oc debug commands should set the same exit status as if they were run through /bin/bash -ce instead of oc debug:

  • the first oc debug command should exit with status 0;
  • the second oc debug command should exit with status 1;
  • the third oc debug command should exit with status 127.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.