Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting 403 errors on OLD projects that do NOT have 'Jobs_enabled' #925

Open
SDDunt opened this issue Oct 15, 2024 · 1 comment
Open

Getting 403 errors on OLD projects that do NOT have 'Jobs_enabled' #925

SDDunt opened this issue Oct 15, 2024 · 1 comment

Comments

@SDDunt
Copy link

SDDunt commented Oct 15, 2024

Running even the latest release, the exporter is logging 403 errors on projects. I suspect this is because you're not checking to see if the projects are ARCHIVED or whether they have "jobs_enabled": false.

I see this on some of our really old projects that were created before there were pipeline. The error being logged is:

Oct 15 12:28:30 ip-10-8-44-150 gitlab-ci-pipelines-exporter[1544264]: time="2024-10-15T12:28:30Z" level=warning msg="pulling ref metrics" error="error fetching project pipelines for firmware/nozzle-control-module: error listing project pipelines for project firmware/nozzle-control-module: GET https://git.xxx.xxx/api/v4/projects/firmware/nozzle-control-module/pipelines: 403 {message: 403 Forbidden}" project-name=firmware/nozzle-control-module ref=2020-GEN3-2017.80.313

and if I dump the JSON for the project, we see jobs_enabled": false,

{ [102/7979]
"id": 627,
"description": "",
"name": "Nozzle Control Module",
"name_with_namespace": "firmware / Nozzle Control Module",
"path": "nozzle-control-module",
"path_with_namespace": "firmware/nozzle-control-module",
"created_at": "2019-07-09T15:08:54.749-05:00",
<<\SNIP>>
"packages_enabled": null,
"empty_repo": false,
"archived": false,
"visibility": "private",
"resolve_outdated_diff_discussions": false,
"repository_object_format": "sha1",
"issues_enabled": true,
"merge_requests_enabled": true,
"wiki_enabled": true,
"jobs_enabled": false,

In my Python 3 pipeline clean up script, which uses the Python - gitlab libraries. this is really easy to work around, just by checking the settings on the project.

if project.archived != True:
if project.jobs_enabled == True:

That would seem to be a pretty easy fix to implement for those cases.

@nudgegoonies
Copy link

nudgegoonies commented Oct 23, 2024

I think we have a similar problem with a project that has pipelines disabled. We get this error (anonymized):

{"error":"error fetching project pipelines for a/b/c: error listing project pipelines for project a/b/c: GET https://gitlab.example.com/api/v4/projects/a/b/c/pipelines: 403 {message: 403 Forbidden}","level":"warning","msg":"pulling ref metrics","project-name":"a/b/c","ref":"main","time":"2024-10-23T12:16:53Z"}

As far as i understand, you cannot use the path in the api but you have to use the project id:
Documentation: https://gitlab.example.com/api/v4/projects/1111/pipelines
Log from pipeline exporter: https://gitlab.example.com/api/v4/projects/a/b/c/pipelines
See https://docs.gitlab.com/ee/api/pipelines.html
I think the gitlab-ci-pipelines-exporter beautifies the log output and replaces ids with human readable paths.
But when clicking on the URL from the log this gives a 404 which can confuse people.

When i call the api via id i can confirm the 403 from the log. So this is an upstream gitlab problem. Instead of an empty list when there are no pipelines or pipelines are disabled it returns a 403 which of course confuses people because they assume this is a permission problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants