Merge branch 'ce-docker_image_replication-event-generation' into 'master'

Backport of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/14597

See merge request gitlab-org/gitlab-ce!30520
This commit is contained in:
Douglas Barbosa Alexandre 2019-07-24 20:11:49 +00:00
commit feb07ce08e
7 changed files with 83 additions and 0 deletions

View file

@ -86,4 +86,9 @@ class ContainerRepository < ApplicationRecord
def self.build_root_repository(project)
self.new(project: project, name: '')
end
def self.find_by_path!(path)
self.find_by!(project: path.repository_project,
name: path.repository_name)
end
end

View file

@ -400,6 +400,15 @@ production: &base
# path: shared/registry
# issuer: gitlab-issuer
# Add notification settings if you plan to use Geo Replication for the registry
# notifications:
# - name: geo_event
# url: https://example.com/api/v4/container_registry_event/events
# timeout: 2s
# threshold: 5
# backoff: 1s
# headers:
# Authorization: secret_phrase
## Error Reporting and Logging with Sentry
sentry:

View file

@ -259,6 +259,7 @@ Settings.registry['key'] ||= nil
Settings.registry['issuer'] ||= nil
Settings.registry['host_port'] ||= [Settings.registry['host'], Settings.registry['port']].compact.join(':')
Settings.registry['path'] = Settings.absolute(Settings.registry['path'] || File.join(Settings.shared['path'], 'registry'))
Settings.registry['notifications'] ||= []
#
# Error Reporting and Logging with Sentry

View file

@ -0,0 +1,17 @@
# frozen_string_literal: true
class AddGeoContainerRepositoryUpdatedEventsTable < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
create_table :geo_container_repository_updated_events, force: :cascade do |t|
t.integer :container_repository_id, null: false
t.index :container_repository_id, name: :idx_geo_con_rep_updated_events_on_container_repository_id, using: :btree
end
add_column :geo_event_log, :container_repository_updated_event_id, :bigint
end
end

View file

@ -0,0 +1,17 @@
# frozen_string_literal: true
class AddIndexToGeoEventLog < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :geo_event_log, :container_repository_updated_event_id
end
def down
remove_concurrent_index(:geo_event_log, :container_repository_updated_event_id)
end
end

View file

@ -0,0 +1,25 @@
# frozen_string_literal: true
class AddForeignKeysForContainerRepository < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_foreign_key(:geo_container_repository_updated_events, :container_repositories, column: :container_repository_id, on_delete: :cascade)
add_concurrent_foreign_key(:geo_event_log, :geo_container_repository_updated_events, column: :container_repository_updated_event_id, on_delete: :cascade)
end
def down
if foreign_key_exists?(:geo_container_repository_updated_events, :container_repositories)
remove_foreign_key(:geo_container_repository_updated_events, :container_repositories)
end
if foreign_key_exists?(:geo_event_log, :geo_container_repository_updated_events)
remove_foreign_key(:geo_event_log, :geo_container_repository_updated_events)
end
end
end

View file

@ -1277,6 +1277,11 @@ ActiveRecord::Schema.define(version: 2019_07_15_142138) do
t.string "key", null: false
end
create_table "geo_container_repository_updated_events", force: :cascade do |t|
t.integer "container_repository_id", null: false
t.index ["container_repository_id"], name: "idx_geo_con_rep_updated_events_on_container_repository_id"
end
create_table "geo_event_log", force: :cascade do |t|
t.datetime "created_at", null: false
t.bigint "repository_updated_event_id"
@ -1291,7 +1296,9 @@ ActiveRecord::Schema.define(version: 2019_07_15_142138) do
t.bigint "job_artifact_deleted_event_id"
t.bigint "reset_checksum_event_id"
t.bigint "cache_invalidation_event_id"
t.bigint "container_repository_updated_event_id"
t.index ["cache_invalidation_event_id"], name: "index_geo_event_log_on_cache_invalidation_event_id", where: "(cache_invalidation_event_id IS NOT NULL)"
t.index ["container_repository_updated_event_id"], name: "index_geo_event_log_on_container_repository_updated_event_id"
t.index ["hashed_storage_attachments_event_id"], name: "index_geo_event_log_on_hashed_storage_attachments_event_id", where: "(hashed_storage_attachments_event_id IS NOT NULL)"
t.index ["hashed_storage_migrated_event_id"], name: "index_geo_event_log_on_hashed_storage_migrated_event_id", where: "(hashed_storage_migrated_event_id IS NOT NULL)"
t.index ["job_artifact_deleted_event_id"], name: "index_geo_event_log_on_job_artifact_deleted_event_id", where: "(job_artifact_deleted_event_id IS NOT NULL)"
@ -3702,7 +3709,9 @@ ActiveRecord::Schema.define(version: 2019_07_15_142138) do
add_foreign_key "fork_network_members", "projects", on_delete: :cascade
add_foreign_key "fork_networks", "projects", column: "root_project_id", name: "fk_e7b436b2b5", on_delete: :nullify
add_foreign_key "forked_project_links", "projects", column: "forked_to_project_id", name: "fk_434510edb0", on_delete: :cascade
add_foreign_key "geo_container_repository_updated_events", "container_repositories", name: "fk_212c89c706", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_cache_invalidation_events", column: "cache_invalidation_event_id", name: "fk_42c3b54bed", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_container_repository_updated_events", column: "container_repository_updated_event_id", name: "fk_6ada82d42a", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_hashed_storage_migrated_events", column: "hashed_storage_migrated_event_id", name: "fk_27548c6db3", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_job_artifact_deleted_events", column: "job_artifact_deleted_event_id", name: "fk_176d3fbb5d", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_lfs_object_deleted_events", column: "lfs_object_deleted_event_id", name: "fk_d5af95fcd9", on_delete: :cascade