Cannot list container repository registries and images on Geo secondary
Summary
!41846 (merged) seems to have introduced package tracking, but broke the pages for Geo secondaries as the Package::CreateEventService attempts to write even in readonly databases (i.e. Geo)
Steps to reproduce
- Set up a Geo primary and secondary
- Set up container registry replication for Geo (optional, you can also reproduce just by going to the page, without tags)
- Go to a project's Container Registry page, observe the error:
What is the current bug behavior?
Container registry repositories and images don't work on Geo secondaries.
What is the expected correct behavior?
Container registry repositories and images should be visible
Relevant logs and/or screenshots
ActiveRecord::StatementInvalid (PG::ReadOnlySqlTransaction: ERROR: cannot execute INSERT in a read-only transaction
):
app/services/packages/create_event_service.rb:8:in `execute'
lib/gitlab/metrics/instrumentation.rb:160:in `block in execute'
lib/gitlab/metrics/method_call.rb:27:in `measure'
lib/gitlab/metrics/instrumentation.rb:160:in `execute'
app/helpers/packages_helper.rb:52:in `track_package_event'
app/controllers/projects/registry/repositories_controller.rb:18:in `block (2 levels) in index'
app/controllers/projects/registry/repositories_controller.rb:12:in `index'
Possible fixes
Make the Package::CreateEventService
aware of read-only databases.
Premium Customer ran into this in ZD (internal only)