Skip to content

Draft: Pass ServerAddress into s3 client initialization for IAM

John Cai requested to merge jc-set-serverurl-iam into main

What does this MR do?

Currently, when a customer is using the s3 cache, the ServerAddress is not honored if IAM is being used. This MR fixes that by passing in the ServerAddress to the initialization call that creates the S3 Client.

Why was this MR needed?

Certain customers need to specify a custom S3 server address.

What's the best way to test this MR?

  1. Create a job with cache enabled. Put in a value for the ServerAddress that is invalid. Do not include values for SecretKey and AccessKey.
config.toml
[[runners]]
  name = "my-runner"
  url = "https://gitlab.com/"
  token = "j8y53CNvsxHCsi9R_jOuq"
  executor = "shell"
  [runners.custom_build_dir]
  [runners.cache]
    Type = "s3"
    [runners.cache.s3]
      ServerName = "s3.my-custom-url.com"
      BucketName = "mybucket"
      BucketLocation = "cn-north-1"
.gitlab-ci.yaml
cache:
  key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
  paths:
    - cached_file

job:
  script:
    - echo "generating file to be cached if it isn't cached."
    - if [ ! -f cached_file ]; then echo 'some important data' > cached_file; else echo "Reusing cached_file."; fi;

When you run the job, you should see an error message with the custom url in the logs:

What are the relevant issue numbers?

Merge request reports