alces-software / adminware

A sandbox CLI for running commands remotely across nodes
1 stars 0 forks source link

Investigate odd argument passing #134

Closed WilliamMcCumstie closed 5 years ago

WilliamMcCumstie commented 5 years ago

When I try and run my top command, it doesn't seem to work if it start with -? The cli structure has changed on my branch a bit, but the issue should be unrelated.

(env) # cat $(pwd)/top/config.yaml 
command: top
interactive: true
(env) # echo $(pwd)/top/config.yaml                                        
/var/lib/adminware/tools/top/config.yaml

(venv) # bin/run-cli run tool top -n slave1 'd1'                
top - 21:51:39 up 3 days,  6:21,  1 user,  load average: 0.00, 0.01, 0.05
Tasks:  95 total,   2 running,  93 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  3.1 sy,  0.0 ni, 96.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1882632 total,  1598744 free,   102068 used,   181820 buff/cache
KiB Swap:  1257468 total,  1257468 free,        0 used.  1581760 avail Mem 
.... BLAH ....

(venv) # bin/run-cli run tool top -n slave1 '-d1'
Error: no such option: -d

(venv) # top d1                
top - 21:51:39 up 3 days,  6:21,  1 user,  load average: 0.00, 0.01, 0.05
Tasks:  95 total,   2 running,  93 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  3.1 sy,  0.0 ni, 96.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1882632 total,  1598744 free,   102068 used,   181820 buff/cache
KiB Swap:  1257468 total,  1257468 free,        0 used.  1581760 avail Mem 
.... BLAH ....

(venv) # top -d1                
top - 21:51:39 up 3 days,  6:21,  1 user,  load average: 0.00, 0.01, 0.05
Tasks:  95 total,   2 running,  93 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  3.1 sy,  0.0 ni, 96.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1882632 total,  1598744 free,   102068 used,   181820 buff/cache
KiB Swap:  1257468 total,  1257468 free,        0 used.  1581760 avail Mem 
.... BLAH ....

Can we work out why run tool top -d doesn't work?

WilliamMcCumstie commented 5 years ago

This maybe a click issue:

(venv) [root@master(unconfigured) adminware]# bin/run-cli run tool top -n slave1 '--missing'
Error: no such option: --missing
(venv) [root@master(unconfigured) adminware]# bin/run-cli run --here tool top -n slave1 '--missing'  
Error: no such option: --here
WilliamMcCumstie commented 5 years ago

If this is indeed a click issue, then some mechanism to escape the string is required

WilliamMcCumstie commented 5 years ago

After adding some basic escaping to the argument input, strings starting with a hyphen may now be passed as arguments. There appears still be an issue in the option passing:

(venv) # bin/run-cli run tool top -n slave1 '\d1'                
top - 21:51:39 up 3 days,  6:21,  1 user,  load average: 0.00, 0.01, 0.05
Tasks:  95 total,   2 running,  93 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  3.1 sy,  0.0 ni, 96.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1882632 total,  1598744 free,   102068 used,   181820 buff/cache
KiB Swap:  1257468 total,  1257468 free,        0 used.  1581760 avail Mem 
.... BLAH ....

(venv) [root@master(unconfigured) adminware]# bin/run-cli run tool top -n slave1 '\-d1'
Internal Print: Stripped Arg String: "-d1"
top: unknown option ' '
Usage:
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]

(venv) [root@master(unconfigured) adminware]# bin/run-cli run tool top -n slave1 '\\-d1'
Internal Print: Stripped Arg String: "\-d1"
top: unknown option '\'
Usage:
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]

This new issue needs to be resolved before the next release

WilliamMcCumstie commented 5 years ago

More click weirdness:

(venv) # bin/run-cli run tool top -n slave1 -
top: inappropriate '-'
Usage:
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
(venv) # bin/run-cli run tool top -n slave1 \-
top: inappropriate '-'
Usage:
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
WilliamMcCumstie commented 5 years ago

I think this might be the result of the shell escaping?

(venv) [root@master(unconfigured) adminware]# bin/run-cli run tool top -n slave1 d0.1
top: bad delay interval ' 0 . 1'