iver-wharf / wharf-provider-gitlab

Import Wharf projects from GitLab repositories
MIT License
2 stars 0 forks source link

Invalid imported build definition on GitLab 13.7.9 #12

Closed applejag closed 2 years ago

applejag commented 3 years ago

We're used to GitLab v12.9.3, but just recently we've tested this provider with GitLab v13.7.9. It's not the most recent, but enough to break our importer.

Screenshot_2021-06-10_11-46-03

While the actual .wharf-ci.yml file looks like this:

run:
  run:
    container:
      image: ubuntu:latest
      cmds:
        - |
          echo "Hello world from ${REPO_GROUP}/${REPO_NAME} on branch ${REPO_BRANCH}"

Looking at the code,

https://github.com/iver-wharf/wharf-provider-gitlab/blob/d9b6f1646c8bedf7b5ad6bd05a22629396188967/gitlab.go#L97

it seems like we're using the following endpoint:

A manual test however on the endpoint in question does respond as expected (in contrast to what the refreshed project showed, with the git-blob:... string):

$ curl --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "https://gitlab.*redacted.com*/api/v4/projects/60/repository/files/.wharf-ci.yml/raw?ref=master"
run:
  run:
    container:
      image: ubuntu:latest
      cmds:
        - |
          echo "Hello world from ${REPO_GROUP}/${REPO_NAME} on branch ${REPO_BRANCH}"

Unclear what's actually going on here. Needs further investigation.

applejag commented 2 years ago

This was found to be a bug in the way we imported the project. In some way, it's probably a bug in GitLab, but we sadly really don't have the energy to escalate it their dev teams.

The cause was that we registered the provider in Wharf via an internal URL constructed by Kubernetes DNS for services. We imported the project into Wharf with the provider URL of something like http://gitlab-web.gitlab.svc.cluster.local, while its configured "public" hostname is something like gitlab.example.com.

No clue what caused this mix, but we changed the provider in Wharf to use https://gitlab.example.com (leading to less efficient network traffic as the traffic has to exit the Kubernetes cluster and then ingress again, instead of going directly to the GitLab pod via the internal Kubernetes network), and that resolved it. Now it imports the project's .wharf-ci.yml file correctly.