Repository navigation
[CLI] runner-all command is bugged #593
Copy link
Copy link
Closed
Description
Description of the problem, including code/CLI snippet
There are 2 problems with runner all command in CLI; I'm not sure if they're related to each other or completely independent.
The --id argument is required - while it shouldn't be - and its value seems to be ignored.
With a workaround (added a dummy --id foobar I get the output in the "legacy" format - which is slightly better - but when trying to retrieve it in JSON, it fails again with an exception. Attaching examples below.
Expected Behavior
$ gitlab runner all --scope active
Expected: successful list of all runners in "legacy" format (whatever it might be)
$ gitlab -o json runner all --scope active
Expected: successful list of all runners in JSON.
Actual Behavior
a) CLI usage failure:
$ gitlab runner all --scope active
usage: gitlab runner all [-h] --id ID [--scope SCOPE]
gitlab runner all: error: the following arguments are required: --idb) with a workaround but in JSON or YAML output format:
$ gitlab -o yaml runner all --scope active --id foobar
Traceback (most recent call last):
File "/Users/weakcamel/git/gitlab/scripts/venv/bin/gitlab", line 12, in <module>
sys.exit(main())
File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/cli.py", line 179, in main
cli_module.run(gl, what, action, args, verbose, output, fields)
File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/v4/cli.py", line 386, in run
printer.display_list(data, fields, verbose=verbose)
File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/v4/cli.py", line 311, in display_list
[get_dict(obj, fields) for obj in data],
File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/v4/cli.py", line 311, in <listcomp>
[get_dict(obj, fields) for obj in data],
File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/v4/cli.py", line 290, in get_dict
return obj.attributes
AttributeError: 'dict' object has no attribute 'attributes'
$ gitlab -o json runner all --scope active --id foobar
Traceback (most recent call last):
File "/Users/weakcamel/git/gitlab/scripts/venv/bin/gitlab", line 12, in <module>
sys.exit(main())
File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/cli.py", line 179, in main
cli_module.run(gl, what, action, args, verbose, output, fields)
File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/v4/cli.py", line 386, in run
printer.display_list(data, fields, verbose=verbose)
File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/v4/cli.py", line 300, in display_list
print(json.dumps([get_dict(obj, fields) for obj in data]))
File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/v4/cli.py", line 300, in <listcomp>
print(json.dumps([get_dict(obj, fields) for obj in data]))
File "/Users/weakcamel/git/gitlab/scripts/venv/lib/python3.7/site-packages/gitlab/v4/cli.py", line 290, in get_dict
return obj.attributes
AttributeError: 'dict' object has no attribute 'attributes'
Specifications
- python-gitlab version: 1.6.0
- API version you are using (v3/v4): v4
- Gitlab server version (or gitlab.com): 10.8.5
Reactions are currently unavailable
Activity
weakcamel commentedon Sep 21, 2018
A bit similar to #191
pvdissel commentedon Aug 27, 2019
Issue still exists :(
chrisoldwood commentedon Jan 29, 2020
I was trying to work out why I couldn't see shared runners and assumed it was a permissions thing but now I've had that sorted I've discovered another issue:
gitlab runner list --allis not the same asgitlab runner all🙂 . The spurious--idargument made no sense so I never really gave it a chance.The clue for me that I'd misunderstood was in #850 (Runner List does not support pagination options) but I think it would be nice if this could made clearer somewhere in the documentation or command line help.
FWIW this is still broken with python-gitlab version 1.15.0.
chrisoldwood commentedon Jan 29, 2020
I'm no Python expert but I've managed to fix the crash and get JSON output working by looking at the code for the
allcustom action on theGroupMemberManagerclass.Hence in
v4/objects.pyinside theRunnerManagerclassallmethod (around line4881in1.15.0), replace:with
It still asks for the
--idargument but you can just pass--id 0on the command line as it's ignored.chrisoldwood commentedon Jan 29, 2020
An alternative workaround, if you're looking for the paging behaviour (which is also broken) and want to avoid the spurious
--idargument is to add a new type, called sayall-runners, that behaves likerunner list, e.g.This is the snippet of code I added to support that:
I looked in
v4/cli.pyand I think the code for handlingcustom_actionsassumes that if the object type has anidthen that must be a mandatory argument. But that's clearly all just conjecture though.