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

Axios proxy via cli options #630

Open
mamyn0va opened this issue Oct 17, 2022 · 30 comments
Open

Axios proxy via cli options #630

mamyn0va opened this issue Oct 17, 2022 · 30 comments
Labels
feature Feature missing according to gitlab ci standard

Comments

@mamyn0va
Copy link

mamyn0va commented Oct 17, 2022

Minimal .gitlab-ci.yml illustrating the issue

include:
  - project: to-be-continuous/golang
    ref: 4.0.0
    file: templates/gitlab-ci-golang.yml
  - project: to-be-continuous/docker
    ref: 3.2.2
    file: /templates/gitlab-ci-docker.yml
  - template: Jobs/SAST.gitlab-ci.yml
  - template: Jobs/Secret-Detection.gitlab-ci.yml
  - template: Jobs/Dependency-Scanning.gitlab-ci.yml
  - template: Jobs/Container-Scanning.gitlab-ci.yml

Expected behavior
It works! :)

Host information
Manjaro
gitlab-ci-local 4.33.1

Additional context
The repo is hosted on a private gitlab instance, and it uses many templates.

Remote include could not be fetched https://gitlab.com/gitlab-org/gitlab/-/raw/HEAD/lib/gitlab/ci/templates/Jobs/SAST.gitlab-ci.yml AxiosError: Request failed with status code 400

I don't know why gitlab-ci-local tries to fetch some templates from gitlab.com instead of my private gitlab instance.
The 400 error may be due to a proxy error (I'm behind a corporate proxy).

@firecow
Copy link
Owner

firecow commented Oct 17, 2022

@mamyn0va Can you provide the the full gitlab-ci-local ouput

gitlab-ci-local > textformjn.txt

and paste it here.

@firecow firecow added the elaborate Further elaboration is needed label Oct 17, 2022
@firecow firecow changed the title Remote include could not be fetched (AxiosError: Request failed with status code 400) Remote include should be fetching from private repo, but use gitlab.com Oct 17, 2022
@mamyn0va
Copy link
Author

There is nothing more :

$ gitlab-ci-local
Remote include could not be fetched https://gitlab.com/gitlab-org/gitlab/-/raw/HEAD/lib/gitlab/ci/templates/Jobs/Secret-Detection.gitlab-ci.yml AxiosError: Request failed with status code 400

Thanks!

@firecow
Copy link
Owner

firecow commented Oct 17, 2022

Nothing about missing remote's or anything ?

@mamyn0va
Copy link
Author

No, and it's easily reproducible with this file:

include:
  - template: Jobs/SAST.gitlab-ci.yml

@firecow
Copy link
Owner

firecow commented Oct 17, 2022

image

image

Not that easy apparently 😃

@firecow firecow changed the title Remote include should be fetching from private repo, but use gitlab.com Problem fetching template includes Oct 17, 2022
@firecow
Copy link
Owner

firecow commented Oct 17, 2022

Why is it that you think templates shouldn't be fetched from gitlab.com?
Isn't this where the template repository is hosted?

@mamyn0va
Copy link
Author

mamyn0va commented Oct 17, 2022 via email

@firecow
Copy link
Owner

firecow commented Oct 18, 2022

And what makes you think that?

@mamyn0va
Copy link
Author

The fact that other templates are fetched from my own instance.

@mamyn0va
Copy link
Author

Do you have any idea why I'm getting 400 errors ?
Is that because I'm behind a corporate proxy ?
Is it possible to configure a proxy in the tool ?

@firecow
Copy link
Owner

firecow commented Oct 18, 2022

No template includes have ever been downloaded from your private gitlab instance, local includes will, but never template includes.

Nah, not really...
Can you do regular curl against gitlab.com?

@mamyn0va
Copy link
Author

Yes, I can do a regular curl to fetch the template from gitlab.com.

@bcouetil
Copy link
Collaborator

Hey 😊

From what I see in the doc, it seems to be fetched... from the same instance, in a specific folder : https://docs.gitlab.com/ee/ci/yaml/#includetemplate

@mamyn0va
Copy link
Author

Thanks, so the question is : why gitlab-ci-local fetches the template from gitlab.com ?

@firecow
Copy link
Owner

firecow commented Oct 18, 2022

Hey 😊

From what I see in the doc, it seems to be fetched... from the same instance, in a specific folder : https://docs.gitlab.com/ee/ci/yaml/#includetemplate

The "templates" link points directly to gitlab.com.
Where do you see that information?

@firecow
Copy link
Owner

firecow commented Oct 18, 2022

I just tried replacing gitlab.com with gitlab.firecow.dk in this https://gitlab.com/gitlab-org/gitlab/-/raw/master/lib/gitlab/ci/templates/Jobs/SAST.gitlab-ci.yml link, and the file is 404 on my private instance.

He is seeing 400... Which indicates, someone is telling the request is "bad" not not found.

@bcouetil
Copy link
Collaborator

It's expected the 404, by default an instance has no template.

This piece of documentation in particular :

Templates are stored in lib/gitlab/ci/templates. Not all templates are designed to be used with include:template, so check template comments before using one.

Uses a relative path, and it must be empty in your instance.

I agree that the 400 error is something else, that we won't tackle together.

@bcouetil
Copy link
Collaborator

Unfortunately I can't test all of this, my current clients are on gitlab.com.

@firecow
Copy link
Owner

firecow commented Oct 18, 2022

I don't get why it must be empty in my instance...
If i push an .gitlab-ci.yml with a template include to gitlab.firecow.dk, the pipeline fetches the file directly from gitlab.com

@bcouetil
Copy link
Collaborator

Because templates are defined by the admin, and you did not put any in your folder ? And on the OP instance, they are defined by the admins...

Just guessing at this stage, I can't test any of my assumptions.

@firecow
Copy link
Owner

firecow commented Oct 18, 2022

You think they are manually added to self hosted instances?

I find that unlikely, since my templates are fetched from gitlab.com, when run on gitlab.firecow.dk...

@greenmaid
Copy link

I think I can confirm this error is caused by proxy :

---
include:
  - remote: "https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/-/raw/master/markdown.gitlab-ci.yml"

job:
  image: alpine
  script:
    - echo 'hello'

this works perfectly without proxy but I got Remote include could not be fetched https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/-/raw/master/markdown.gitlab-ci.yml AxiosError: Request failed with status code 400 as soon I have with a proxy

@mamyn0va
Copy link
Author

mamyn0va commented Oct 18, 2022

Hi @greenmaid, I confirm that it works perfectly without proxy with this file:

---
include:
  - template: Jobs/SAST.gitlab-ci.yml

job:
  image: alpine
  script:
    - echo 'hello'

carbon-1

@firecow
Copy link
Owner

firecow commented Oct 18, 2022

Ok, let's find out how we shall configure axios proxy then...

@greenmaid
Copy link

Looking at tcpdump trace, I can say that requests is send via proxy but without CONNECT (as if it was a http URL)

GET https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/-/raw/master/markdown.gitlab-ci.yml HTTP/1.1
Accept: application/json, text/plain, */*
User-Agent:  axios/0.27.2
Accept-Encoding: gzip, deflate, br
host: gitlab.com
Connection: close

Proxy answers 400

HTTP/1.0 400 Bad Request
Server: BigIP
Connection: close
Content-Length: 6564

<html>
<FONT face="Helvetica"><big><strong></strong></big>
[...]

For me it is exactly this bug at axios side: axios/axios#4531
with open PR: axios/axios#5037

@greenmaid
Copy link

Axios + proxy seems historically... complicated 😵

@firecow
Copy link
Owner

firecow commented Oct 18, 2022

We could switch http client library

@firecow firecow added feature Feature missing according to gitlab ci standard and removed elaborate Further elaboration is needed labels Nov 5, 2022
@firecow
Copy link
Owner

firecow commented Nov 5, 2022

I'm gonna come up with some way to specify axios proxy setting via gitlab ci local options.
I've renamed the issue.

@firecow firecow changed the title Problem fetching template includes Axios proxy via cli options Nov 5, 2022
@mamyn0va
Copy link
Author

mamyn0va commented Oct 5, 2023

Hi @firecow, any update on this ?

@firecow
Copy link
Owner

firecow commented Oct 5, 2023

@mamyn0va Haven't looked seriously into it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature missing according to gitlab ci standard
Projects
None yet
Development

No branches or pull requests

4 participants