kiternetes上的gitlab-ci缓存,minio-service不再工作

时间:2018-02-09 21:34:54

标签: kubernetes gitlab-ci gitlab-ci-runner minio

我使用gitlab-runner 10.4.0运行gitlab 10.4.3作为kubernetes部署,使用kubernetes runner和minio-server进行缓存。我根据gitlab docs安装了它。

在向.gitlab-ci.yml文件中添加适当的设置时,所有内容都按预期使用缓存:

build:
  stage: build
  variables:
    GIT_STRATEGY: fetch
  cache:
    key: "$CI_BUILD_REF_NAME"
    paths:
      - node_modules/
  script:
    - compile-templates.sh
    - yarn install
    - yarn run build

管道输出确实在第一次填充缓存,并且在同一分支上的后续运行正确地拉出并推送缓存:

Running on gitlab/runner-abcdefg-project-123-concurrent-123456 via gitlab-runner-123456-987654...
Cloning repository for feature/gitlab-cache with git depth set to 1...
Cloning into '/group/project'...
Checking out b1348594 as feature/gitlab-cache...
Skipping Git submodules setup
Checking cache for feature/gitlab-cache...
Downloading cache.zip from http://minio-service:9000/runner/runner/abcdefg/project/123/feature/gitlab-cache 
Successfully extracted cache
$ docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
Login Succeeded
[...snip...]
Creating cache feature/gitlab-cache...
node_modules/: found 26281 matching files
Uploading cache.zip to http://minio-service:9000/runner/runner/abcdefg/project/123/feature/gitlab-cache 
Created cache

然而,经过一些运行它突然停止工作 - 我不知道为什么。我也试过一个作业全局缓存定义无济于事 - 似乎gitlab-runner只是忽略了设置而只是跳过了#34;检查缓存部分":

Running on gitlab/runner-abcdefg-project-123-concurrent-123456 via gitlab-runner-123456-987654...
Cloning repository for feature/gitlab-cache with git depth set to 1...
Cloning into '/group/project'...
Checking out b1348594 as feature/gitlab-cache...
Skipping Git submodules setup
$ docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
Login Succeeded
[...snip...]
Job succeeded

我的gitlab-runner config.toml有适当的设置:

[[runners]]
  // ...
  [runners.kubernetes]
  // ...
  [runners.cache]
    Type = "s3"
    // I've also tried http://minio-service:9000 to no avail
    ServerAddress = "minio-service:9000"
    AccessKey = "xxxxxxxxxxxxxxxxxxxxxxxx"
    SecretKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    BucketName = "runner"
    Insecure = true

注意:如果我将设置更改为无效设置,我不会在跑步者日志中收到任何错误消息。

可以从作业窗格来自作业窗格

$ curl -s "http://minio-service:9000"
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied.</Message><Key></Key><BucketName></BucketName><Resource>/</Resource><RequestId>12345</RequestId><HostId>12345</HostId></Error>

minio客户端mc在本地卷中检查了minio中的存储桶。

gitlab-runner或minio-server的pod的日志中没有错误。

就像.gitlab-ci.yml的缓存设置被忽略一样,我想知道要检查的内容。有想法的人吗?

1 个答案:

答案 0 :(得分:1)

因此,问题是无效文档与无效缓存:密钥的无声忽略相结合。如果分支是例如命名为feature/some-new-thing"$CI_BUILD_REF_NAME"的结果键将导致无效缓存:包含“/”字符的键 - 这反过来会使整个缓存部分无效,但会被忽略。

相反,只需使用"${CI_BUILD_REF_SLUG}",它将包含url-safe - 因此cache:key-safe - 版本的分支名称:

cache:
  key: "${CI_BUILD_REF_SLUG}"
  paths:
    - node_modules/

已打开bug report