Skip to content

Add support for Google Cloud CDN config

Stan Hu requested to merge sh-add-google-cloud-cdn-config into master

What does this MR do?

In gitlab-org/gitlab!96336 (merged) and gitlab-org/gitlab!98010 (merged), we added support for Google CDN in front of CI artifacts to improve performance and reduce costs. This commit adds the necessary configuration support to enable it.

This is similar to the work for the container registry in !2328 (merged).

Related issues

Relates to #3711 (closed)

Testing

I verified this work by using the latest master images.

  1. Configure a GCS bucket with Cloud CDN.
  2. With the settings:
global:
  appConfig:
    object_store:
       enabled: true
       proxy_download: false
       connection:
         secret: gitlab-rails-storage
  artifacts:
    bucket: stanhu-test
    cdn:
      secret: gitlab-rails-storage

Added the cdn key in gitlab-rails-storage secret:

provider: Google
url: "https://stanhu.example.com"
key_name: stanhu-key
key: REDACTED
  1. In bin/rails console, enable the feature flag: Feature.enable(:ci_job_artifacts_cdn)
  2. Run a CI job.
  3. Use the artifacts API (e.g. https://stanhu.example.org/api/v4/projects/2/jobs/4/artifacts) to download the file. Notice the URL has the CDN.
  4. Check that /var/log/gitlab/api_json.log has meta.artifact_used_cdn:
  "meta.feature_category": "build_artifacts",
  "meta.user": "root",
  "meta.project": "root/simple-ci",
  "meta.root_namespace": "root",
  "meta.client_id": "user/1",
  "meta.artifact_size": 209,
  "meta.artifact_used_cdn": true,
  1. If you use a runner within Google Cloud (or localhost), you'll notice meta.artifact_used_cdn is omitted because a CDN is not needed.

Checklist

See Definition of done.

For anything in this list which will not be completed, please provide a reason in the MR discussion.

Required

  • Merge Request Title and Description are up to date, accurate, and descriptive
  • MR targeting the appropriate branch
  • MR has a green pipeline on GitLab.com

Expected (please provide an explanation if not completing)

Edited by Stan Hu

Merge request reports