Skip to content

'project-runner get' command should not exist #1608

Closed
@lgatellier

Description

@lgatellier

Description of the problem, including code/CLI snippet

The library allows to query /projects/:projectId/runners/:id URL through gitlab.v4.objects.ProjectRunnerManager class, but the official Gitlab API does not describe this endpoint, which does not exists.

Project's runners list :

$ gitlab -d -o json project-runner list --all --project-id 76644
DEBUG:urllib3.connectionpool:https://gitlab.company.com:443 "GET /api/v4/projects/76644/runners?project_id=76644 HTTP/1.1" 200 None
send: b'GET /api/v4/projects/76644/runners?project_id=76644 HTTP/1.1\r\nHost: gitlab.company.com\r\nUser-Agent: python-gitlab/2.10.1\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nPRIVATE-TOKEN: [hidden content]\r\nContent-type: application/json\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Server: nginx
header: Date: Wed, 22 Sep 2021 18:08:59 GMT
header: Content-Type: application/json
header: Transfer-Encoding: chunked
header: Connection: keep-alive
header: Vary: Accept-Encoding
header: Cache-Control: max-age=0, private, must-revalidate
header: Etag: W/"1ae5eff0bd18cd69fc1aa3325e259422"
header: Link: [hidden content]
header: Vary: Origin
header: X-Content-Type-Options: nosniff
header: X-Frame-Options: SAMEORIGIN
header: X-Gitlab-Feature-Category: continuous_integration
header: X-Next-Page:
header: X-Page: 1
header: X-Per-Page: 20
header: X-Prev-Page:
header: X-Request-Id: 01FG7B4MD17BPMDZXG2XHFFK4Q
header: X-Runtime: 0.072099
header: X-Total: 2
header: X-Total-Pages: 1
header: Strict-Transport-Security: max-age=31536000
header: Referrer-Policy: strict-origin-when-cross-origin
header: Content-Encoding: gzip
[{"id": 7723, "description": "<description>", "ip_address": "<ip address>", "active": true, "is_shared": false, "name": "gitlab-runner", "online": false, "status": "offline"}, {"id": 11737, "description": "shared-gitlab-runner-77d49f579-zpr98", "ip_address": "<ip address>", "active": true, "is_shared": true, "name": "gitlab-runner", "online": true, "status": "online"}]

Invalid query :

$ gitlab -d -o json project-runner get --project-id 76644 --id 7723
DEBUG:urllib3.connectionpool:https://gitlab.company.com:443 "GET /api/v4/projects/76644/runners/7723?project_id=76644 HTTP/1.1" 404 25
Impossible to get object (404: 404 Not Found)
send: b'GET /api/v4/projects/76644/runners/7723?project_id=76644 HTTP/1.1\r\nHost: gitlab.company.com\r\nUser-Agent: python-gitlab/2.10.1\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nPRIVATE-TOKEN: [hidden content]\r\nContent-type: application/json\r\n\r\n'
reply: 'HTTP/1.1 404 Not Found\r\n'
header: Server: nginx
header: Date: Wed, 22 Sep 2021 18:11:44 GMT
header: Content-Type: application/json
header: Content-Length: 25
header: Connection: keep-alive
header: Cache-Control: no-cache
header: Vary: Origin
header: X-Content-Type-Options: nosniff
header: X-Frame-Options: SAMEORIGIN
header: X-Gitlab-Feature-Category: not_owned
header: X-Request-Id: 01FG7B9MZ0K19YPZ4MQJ390PK1
header: X-Runtime: 0.019269

Valid query (which already exists) : GET /runner/7723

$ gitlab -d  -o json runner get --id 7723
DEBUG:urllib3.connectionpool:https://gitlab.company.com:443 "GET /api/v4/runners/7723 HTTP/1.1" 200 None
send: b'GET /api/v4/runners/7723 HTTP/1.1\r\nHost: gitlab.company.com\r\nUser-Agent: python-gitlab/2.10.1\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nPRIVATE-TOKEN: [hidden content]\r\nContent-type: application/json\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Server: nginx
header: Date: Wed, 22 Sep 2021 18:11:34 GMT
header: Content-Type: application/json
header: Transfer-Encoding: chunked
header: Connection: keep-alive
header: Vary: Accept-Encoding
header: Cache-Control: max-age=0, private, must-revalidate
header: Etag: W/"7506c48834a201e1d86531647d32b044"
header: Vary: Origin
header: X-Content-Type-Options: nosniff
header: X-Frame-Options: SAMEORIGIN
header: X-Gitlab-Feature-Category: continuous_integration
header: X-Request-Id: 01FG7B9B43ME9BMFFZTFM8A20H
header: X-Runtime: 0.124597
header: Strict-Transport-Security: max-age=31536000
header: Referrer-Policy: strict-origin-when-cross-origin
header: Content-Encoding: gzip
{"id": 7723, "description": "<description>", "ip_address": "<id address>", "active": true, "is_shared": false, "name": "gitlab-runner", "online": false, "status": "offline", "tag_list": [], "run_untagged": true, "locked": false, "maximum_timeout": null, "access_level": "not_protected", "version": "13.11.0", "revision": "7f7a4bb0", "platform": "linux", "architecture": "amd64", "contacted_at": "2021-04-23T13:03:09.789Z", "projects": [projects list], "groups": []}

If I correctly understand the library, I think that ProjectRunnerManager class should not inherits GetMixin class (which comes through NoUpdateMixin), but only ListMixin, CreateMixin and DeleteMixin classes (and RESTManager class, of course).

The unit tests do not cover the project-runner get command (this could have revelead the bug earlier).

Should I open a PR to fix this issue ?

Expected Behavior

The gitlab projet-runner get command should not exist.

Actual Behavior

The gitlab projet-runner get command exists.

Specifications

  • python-gitlab version: 2.10.1
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): 13.12.1-ee

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions