Bug 1388237 - oc observe is not validating the existence of a file
Summary: oc observe is not validating the existence of a file
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: OKD
Classification: Red Hat
Component: oc
Version: 3.x
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Clayton Coleman
QA Contact: Xingxing Xia
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-10-24 19:38 UTC by Chris Ryan
Modified: 2016-11-01 02:10 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-10-31 11:28:21 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Chris Ryan 2016-10-24 19:38:42 UTC
Description of problem:
oc observe is not validating the existence of file and leaves the process open.

Version-Release number of selected component (if applicable):
oc v1.4.0-alpha.0+2016d68-dirty
kubernetes v1.4.0+776c994
features: Basic-Auth

How reproducible:
Intermittent

Steps to Reproduce:

1. Create a series of files to use for oc observe:

$ cat add_to_inventory.sh # For --, called CMD .sh below
#!/bin/sh
echo "--CMD:    `date --rfc-3339=ns` \$1=$1, \$2=$2, \$3=$3" >> log
echo "$1/$2 $3" >> inventory
sort -u inventory -o inventory

$ cat remove_from_inventory.sh # For --delete
#!/bin/sh
echo "--delete: `date --rfc-3339=ns` Processing resource after deletion (\$1:$1 \$2:$2 \$3:$3) ..." >> log
# Other processing ...
grep -vE "^$1/$2 " inventory > newinventory
mv -f newinventory inventory

2. Run the oc observe command with a false value for --names, to generate an error:
oc observe pods --names ./not-exist.sh --delete ./remove_from_inventory.sh -- ./add_to_inventory.sh

Actual results:
F1024 14:03:11.545700   21969 observe.go:422] Unable to listen on ":11251": listen tcp :11251: bind: address already in use

Expected results:
error: unable to list known keys: fork/exec ./not-exist.sh: no such file or directory

Additional info:

Comment 1 Chris Ryan 2016-10-24 19:44:18 UTC
Upon further inspection, it seems that the client command is still running in the background, this could be the culprit:

$ ps aux |grep 'oc observe'
cryan    24088  0.0  0.5 369436 60892 pts/4    Sl   14:28   0:00 oc observe svc --delete=./remove_from_inventory.sh -- echo print

Comment 2 Paul Weil 2016-10-28 12:30:49 UTC
Chris, I was not able to reproduce the behavior or leaving a running process and always received the "no such file or directory" message which seems correct.

If I started another instance of the command I could see the "unable to listen" message. 

I notice that your ps command is showing a running command without the --names argument on it which would run correctly and is not what the reproduce steps are showing.  Can you confirm that you can still reproduce this?

Comment 3 Xingxing Xia 2016-10-31 02:38:28 UTC
> If I started another instance of the command I could see the "unable to
> listen" message. 

Hi, Chris, Paul said correctly.
`oc observe -h` shows a flag "--listen-addr=':11251': The name of an interface to listen on ...".
If there was a precious `oc observe ...` not stopped, new `oc observe ...` will show the error 'Unable to listen on ":11251"', unless it specifies different "--listen-addr'.
So the issues you saw works by design :)
 
(Similar to other oc cmd that binds port, like `oc proxy -h` shows '--port=8001')


Note You need to log in before you can comment on or make changes to this bug.