Error 500 when browsing artifacts on object storage that are not cached yet

Summary

When the artifacts are stored on object storage, and you try to browse them, the first time you'll get a 500.

Steps to reproduce

  1. Enable object storage for the artifacts
  2. But disable the object store background uploader: gitlab_rails['artifacts_object_store_background_upload'] = false in gitlab.rb
  3. Trigger a pipeline
  4. Run gitlab-rake gitlab:artifacts:migrate
  5. Visit the artifact browse page of the job: /<group>/<project>/-/jobs/<job_id>/artifacts/browse

When you have the background uploader active, it might happen that the browse page is visited before the artifacts are uploaded to object storage. In this situation the metadata is correctly cached, and all the consecutive requests will be successful, even if in meanwhile the background worker uploaded them to object storage.

What is the current bug behavior?

Error 500.

What is the expected correct behavior?

It should show the content of the artifacts.

Relevant logs and/or screenshots

Started GET "/testme/test-ci/-/jobs/21/artifacts/browse" for 81.83.195.177 at 2018-02-01 14:35:18 +0000
Processing by Projects::ArtifactsController#browse as HTML
  Parameters: {"namespace_id"=>"testme", "project_id"=>"test-ci", "job_id"=>"21"}
Completed 500 Internal Server Error in 20ms (ActiveRecord: 3.2ms | Elasticsearch: 0.0ms)

Excon::Error::Socket (end of file reached (EOFError)):
  app/models/ci/build.rb:373:in `artifacts_metadata_entry'
  app/controllers/projects/artifacts_controller.rb:20:in `browse'
  lib/gitlab/i18n.rb:47:in `with_locale'
  lib/gitlab/i18n.rb:53:in `with_user_locale'
  app/controllers/application_controller.rb:334:in `set_locale'
  lib/gitlab/middleware/multipart.rb:95:in `call'
  lib/gitlab/request_profiler/middleware.rb:14:in `call'
  lib/gitlab/jira/middleware.rb:15:in `call'
  lib/gitlab/middleware/go.rb:18:in `call'
  lib/gitlab/etag_caching/middleware.rb:11:in `call'
  lib/gitlab/middleware/read_only.rb:31:in `call'
  lib/gitlab/request_context.rb:18:in `call'
  lib/gitlab/metrics/requests_rack_middleware.rb:27:in `call'

Possible fixes

The metadata.gz should be cached to /var/opt/gitlab/gitlab-rails/shared/artifacts/tmp/cache before the browse page is shown.

Assignee Loading
Time tracking Loading