Dynamically generated pipelines are failing with artifacts in object storage

Summary

When GitLab instance is configured to store artifacts in an object storage, and it has ci_new_artifact_file_reader feature flag enabled, dynamically generated pipelines will fail with Undefined error image

The exception.log will have the following error logged: "exception.message":"Zip end of central directory signature not found"

Steps to reproduce

  1. On an Omnibus instance configure artifacts to be use object storage with S3 AWS bucket as a destination:
gitlab_rails['artifacts_object_store_enabled'] = true
gitlab_rails['artifacts_object_store_remote_directory'] = "BUCKETNAME"
gitlab_rails['artifacts_object_store_connection'] = {
   'provider' => 'AWS',
   'region' => 'REGION',
   'aws_access_key_id' => 'ID',
   'aws_secret_access_key' => 'SECRET'
 }
  1. Make sure to enable ci_new_artifact_file_reader feature flag
  2. Create a project with this .gitlab-ci.yaml file:
stages:
  - generate
  - run

generate-config:
  stage: generate
  script:
    - sh ./generate-configs.sh
    - cat config-a.yml
    - cat config-b.yml
  artifacts:
    paths:
      - config-a.yml
      - config-b.yml

trigger-a:
  stage: run
  trigger:
    include:
      - artifact: config-a.yml
        job: generate-config
    strategy: depend
  needs:
    - generate-config

trigger-b:
  stage: run
  trigger:
    include:
      - artifact: config-b.yml
        job: generate-config
    strategy: depend
  needs:
   - generate-config

Make sure to have ./generate-configs.sh file there:

#!/bin/bash

cat > config-a.yml <<HEREDOC
service-a-1:
  script:
    - echo 'job 1 for service A'
service-a-2:
  script:
    - echo 'job 2 for service A'
HEREDOC

cat > config-b.yml <<HEREDOC
service-b-1:
  script:
    - echo 'job 1 for service B'
service-b-2:
  script:
    - echo 'job 2 for service B'
HEREDOC
  1. Run the pipeline.

What is the current bug behavior?

Both child pipelines fail.

What is the expected correct behavior?

Child pipelines should be successfully run.

Relevant logs and/or screenshots

{"severity":"ERROR","time":"2021-03-09T12:14:51.448Z","correlation_id":"01F0BEJHGF6SSJYR0RG7TGNJJA","extra.sidekiq":{"class":"Ci::CreateCrossProjectPipelineWorker","args":["1229"],"retry":3,"queue":"pipeline_default:ci_create_cross_project_pipeline","version":0,"queue_namespace":"pipeline_default","jid":"b74cad421d54b02e4dce326c","created_at":1615292090.0204432,"meta.user":"kate","meta.project":"kate/196797","meta.root_namespace":"kate","meta.caller_id":"PipelineProcessWorker","meta.remote_ip":"34.91.201.195","meta.feature_category":"continuous_integration","correlation_id":"01F0BEJHGF6SSJYR0RG7TGNJJA","enqueued_at":1615292090.0226216},"extra.project_id":117,"extra.sha":"fb9b54fab6036668b34a692eb80cbf41f8363c62","exception.class":"Zip::Error","exception.message":"Zip end of central directory signature not found","exception.backtrace":["lib/gitlab/ci/artifact_file_reader.rb:57:in `new'","lib/gitlab/ci/artifact_file_reader.rb:57:in `block in read_with_new_artifact_file_reader'","app/uploaders/object_storage.rb:292:in `block in use_open_file'","app/uploaders/object_storage.rb:279:in `use_open_file'","lib/gitlab/ci/artifact_file_reader.rb:56:in `read_with_new_artifact_file_reader'","lib/gitlab/ci/artifact_file_reader.rb:49:in `read_zip_file!'","lib/gitlab/ci/artifact_file_reader.rb:30:in `read'","lib/gitlab/ci/config/external/file/artifact.rb:25:in `block in content'","lib/gitlab/utils/strong_memoize.rb:30:in `strong_memoize'","lib/gitlab/ci/config/external/file/artifact.rb:22:in `content'","lib/gitlab/ci/config/external/file/artifact.rb:45:in `validate_content!'","lib/gitlab/ci/config/external/file/base.rb:72:in `validate!'","lib/gitlab/ci/config/external/file/base.rb:20:in `initialize'","lib/gitlab/ci/config/external/file/artifact.rb:18:in `initialize'","lib/gitlab/ci/config/external/mapper.rb:93:in `new'","lib/gitlab/ci/config/external/mapper.rb:93:in `block in select_first_matching'","lib/gitlab/ci/config/external/mapper.rb:92:in `map'","lib/gitlab/ci/config/external/mapper.rb:92:in `select_first_matching'","lib/gitlab/ci/config/external/mapper.rb:39:in `map'","lib/gitlab/ci/config/external/mapper.rb:39:in `process'","lib/gitlab/ci/config/external/processor.rb:12:in `initialize'","lib/gitlab/ci/config.rb:94:in `new'","lib/gitlab/ci/config.rb:94:in `build_config'","ee/lib/ee/gitlab/ci/config_ee.rb:18:in `build_config'","lib/gitlab/ci/config.rb:81:in `expand_config'","lib/gitlab/ci/config.rb:26:in `initialize'","lib/gitlab/ci/yaml_processor.rb:23:in `new'","lib/gitlab/ci/yaml_processor.rb:23:in `execute'","lib/gitlab/ci/pipeline/chain/config/process.rb:21:in `perform!'","lib/gitlab/ci/pipeline/chain/sequence.rb:19:in `block in build!'","lib/gitlab/ci/pipeline/chain/sequence.rb:16:in `each'","lib/gitlab/ci/pipeline/chain/sequence.rb:16:in `build!'","app/services/ci/create_pipeline_service.rb:83:in `execute'","app/services/ci/create_downstream_pipeline_service.rb:35:in `execute'","app/workers/ci/create_cross_project_pipeline_worker.rb:14:in `block in perform'","app/workers/ci/create_cross_project_pipeline_worker.rb:11:in `perform'","lib/gitlab/sidekiq_middleware/duplicate_jobs/strategies/until_executing.rb:16:in `perform'","lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb:40:in `perform'","lib/gitlab/sidekiq_middleware/duplicate_jobs/server.rb:8:in `call'","lib/gitlab/sidekiq_middleware/worker_context.rb:9:in `wrap_in_optional_context'","lib/gitlab/sidekiq_middleware/worker_context/server.rb:17:in `block in call'","lib/gitlab/application_context.rb:56:in `block in use'","lib/gitlab/application_context.rb:56:in `use'","lib/gitlab/application_context.rb:22:in `with_context'","lib/gitlab/sidekiq_middleware/worker_context/server.rb:15:in `call'","lib/gitlab/sidekiq_status/server_middleware.rb:7:in `call'","lib/gitlab/sidekiq_versioning/middleware.rb:9:in `call'","lib/gitlab/sidekiq_middleware/admin_mode/server.rb:8:in `call'","lib/gitlab/sidekiq_middleware/instrumentation_logger.rb:9:in `call'","lib/gitlab/sidekiq_middleware/batch_loader.rb:7:in `call'","lib/gitlab/sidekiq_middleware/extra_done_log_metadata.rb:7:in `call'","lib/gitlab/sidekiq_middleware/request_store_middleware.rb:10:in `block in call'","lib/gitlab/with_request_store.rb:17:in `enabling_request_store'","lib/gitlab/with_request_store.rb:10:in `with_request_store'","lib/gitlab/sidekiq_middleware/request_store_middleware.rb:9:in `call'","lib/gitlab/sidekiq_middleware/server_metrics.rb:37:in `call'","lib/gitlab/sidekiq_middleware/monitor.rb:8:in `block in call'","lib/gitlab/sidekiq_daemon/monitor.rb:49:in `within_job'","lib/gitlab/sidekiq_middleware/monitor.rb:7:in `call'","lib/gitlab/sidekiq_logging/structured_logger.rb:19:in `call'"]}

image

Output of checks

This bug doesn't happen on GitLab.com

Results of GitLab environment info

Expand for output related to GitLab environment info
[root@kate-inst-1 ~]# sudo gitlab-rake gitlab:env:info
System information
System:		
Proxy:		no
Current User:	git
Using RVM:	no
Ruby Version:	2.7.2p137
Gem Version:	3.1.4
Bundler Version:2.1.4
Rake Version:	13.0.3
Redis Version:	6.0.10
Git Version:	2.29.0
Sidekiq Version:5.2.9
Go Version:	unknown

GitLab information
Version:	13.9.1-ee
Revision:	8ae438629fa
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	PostgreSQL
DB Version:	12.5
URL:		https://cos7ob.kate.gitlab.support
HTTP Clone URL:	https://cos7ob.kate.gitlab.support/some-group/some-project.git
SSH Clone URL:	git@cos7ob.kate.gitlab.support:some-group/some-project.git
Elasticsearch:	yes
Geo:		no
Using LDAP:	no
Using Omniauth:	yes
Omniauth Providers: 

GitLab Shell
Version:	13.16.1
Repository storage paths:
- default: 	/var/opt/gitlab/git-data/repositories
GitLab Shell path:		/opt/gitlab/embedded/service/gitlab-shell
Git:		/opt/gitlab/embedded/bin/git

Results of GitLab application Check

Expand for output related to the GitLab application check
[root@kate-inst-1 ~]# sudo gitlab-rake gitlab:check SANITIZE=true
Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 13.16.1 ? ... OK (13.16.1) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 2/1 ... yes 51/2 ... yes 51/3 ... yes 51/4 ... yes 51/5 ... yes 51/6 ... yes 51/7 ... yes 51/8 ... yes 51/9 ... yes 51/10 ... yes 51/11 ... yes 52/12 ... yes 52/13 ... yes 53/14 ... yes 53/15 ... yes 53/16 ... yes 54/17 ... yes 54/18 ... yes 54/19 ... yes 54/20 ... yes 54/21 ... yes 54/22 ... yes 54/23 ... yes 54/24 ... yes 54/25 ... yes 54/26 ... yes 55/27 ... yes 55/28 ... yes 55/29 ... yes 55/30 ... yes 56/31 ... yes 56/32 ... yes 56/33 ... yes 56/34 ... yes 56/35 ... yes 57/36 ... yes 57/37 ... yes 57/38 ... yes 57/39 ... yes 58/40 ... yes 58/41 ... yes 58/42 ... yes 66/43 ... yes 70/45 ... yes 70/46 ... yes 69/47 ... yes 69/48 ... yes 69/50 ... yes 58/52 ... yes 58/53 ... yes 63/54 ... yes 66/55 ... yes 66/56 ... yes 66/57 ... yes 66/58 ... yes 66/59 ... yes 65/72 ... yes 66/77 ... yes 66/78 ... yes 69/81 ... yes 66/85 ... yes 66/86 ... yes 69/87 ... yes 66/89 ... yes 66/90 ... yes 66/92 ... yes 66/97 ... yes 69/99 ... yes 69/100 ... yes 66/101 ... yes 66/102 ... yes 66/103 ... yes 66/104 ... yes 69/106 ... yes 66/107 ... yes 66/110 ... yes 69/111 ... yes 94/112 ... yes 66/113 ... yes 69/114 ... yes 91/115 ... yes 66/117 ... yes 66/118 ... yes 66/119 ... yes Redis version >= 4.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (2.7.2) Git version >= 2.29.0 ? ... yes (2.29.0) Git user has default SSH configuration? ... yes Active users: ... 54 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes Elasticsearch version 7.x (6.4 - 6.x deprecated to be removed in 13.8)? ... Exception: execution expired

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Possible fixes

Edited by Furkan Ayhan