Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
50c1832e0f
commit
1b30559a20
|
|
@ -3,6 +3,8 @@
|
|||
module UpdateRepositoryStorageMethods
|
||||
include Gitlab::Utils::StrongMemoize
|
||||
|
||||
MAX_ERROR_LENGTH = 256
|
||||
|
||||
Error = Class.new(StandardError)
|
||||
|
||||
attr_reader :repository_storage_move
|
||||
|
|
@ -44,6 +46,7 @@ module UpdateRepositoryStorageMethods
|
|||
|
||||
ServiceResponse.success
|
||||
rescue StandardError => e
|
||||
repository_storage_move.update_column(:error_message, e.message.truncate(MAX_ERROR_LENGTH))
|
||||
repository_storage_move.do_fail!
|
||||
|
||||
Gitlab::ErrorTracking.track_and_raise_exception(e, container_klass: container.class.to_s, container_path: container.full_path)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddErrorToProjectRepositoryStorageMoves < Gitlab::Database::Migration[2.2]
|
||||
disable_ddl_transaction!
|
||||
milestone '16.7'
|
||||
|
||||
def up
|
||||
with_lock_retries do
|
||||
add_column :project_repository_storage_moves, :error_message, :text, if_not_exists: true
|
||||
end
|
||||
|
||||
add_text_limit :project_repository_storage_moves, :error_message, 256
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
remove_column :project_repository_storage_moves, :error_message, if_exists: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddErrorToGroupRepositoryStorageMoves < Gitlab::Database::Migration[2.2]
|
||||
disable_ddl_transaction!
|
||||
milestone '16.7'
|
||||
|
||||
def up
|
||||
with_lock_retries do
|
||||
add_column :group_repository_storage_moves, :error_message, :text, if_not_exists: true
|
||||
end
|
||||
|
||||
add_text_limit :group_repository_storage_moves, :error_message, 256
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
remove_column :group_repository_storage_moves, :error_message, if_exists: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddErrorToSnippetRepositoryStorageMoves < Gitlab::Database::Migration[2.2]
|
||||
disable_ddl_transaction!
|
||||
milestone '16.7'
|
||||
|
||||
def up
|
||||
with_lock_retries do
|
||||
add_column :snippet_repository_storage_moves, :error_message, :text, if_not_exists: true
|
||||
end
|
||||
|
||||
add_text_limit :snippet_repository_storage_moves, :error_message, 256
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
remove_column :snippet_repository_storage_moves, :error_message, if_exists: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1 @@
|
|||
9e9b1aa72cdee936d054dfd657636d54c505fa9355ebf41c8dcdfd695dc2530b
|
||||
|
|
@ -0,0 +1 @@
|
|||
2a7d37a61d4fc2a0b4a96acbf58508b5d38119540005f546e7d9f247eac3829f
|
||||
|
|
@ -0,0 +1 @@
|
|||
fdd72dc39f9815db8a9c23a6fe5329f8708da91607709a2d822771c7ced8eba5
|
||||
|
|
@ -17336,6 +17336,8 @@ CREATE TABLE group_repository_storage_moves (
|
|||
state smallint DEFAULT 1 NOT NULL,
|
||||
source_storage_name text NOT NULL,
|
||||
destination_storage_name text NOT NULL,
|
||||
error_message text,
|
||||
CONSTRAINT check_266d0cf596 CHECK ((char_length(error_message) <= 256)),
|
||||
CONSTRAINT group_repository_storage_moves_destination_storage_name CHECK ((char_length(destination_storage_name) <= 255)),
|
||||
CONSTRAINT group_repository_storage_moves_source_storage_name CHECK ((char_length(source_storage_name) <= 255))
|
||||
);
|
||||
|
|
@ -22019,6 +22021,8 @@ CREATE TABLE project_repository_storage_moves (
|
|||
state smallint DEFAULT 1 NOT NULL,
|
||||
source_storage_name text NOT NULL,
|
||||
destination_storage_name text NOT NULL,
|
||||
error_message text,
|
||||
CONSTRAINT check_85854380db CHECK ((char_length(error_message) <= 256)),
|
||||
CONSTRAINT project_repository_storage_moves_destination_storage_name CHECK ((char_length(destination_storage_name) <= 255)),
|
||||
CONSTRAINT project_repository_storage_moves_source_storage_name CHECK ((char_length(source_storage_name) <= 255))
|
||||
);
|
||||
|
|
@ -23535,6 +23539,8 @@ CREATE TABLE snippet_repository_storage_moves (
|
|||
state smallint DEFAULT 1 NOT NULL,
|
||||
source_storage_name text NOT NULL,
|
||||
destination_storage_name text NOT NULL,
|
||||
error_message text,
|
||||
CONSTRAINT check_a42ab83060 CHECK ((char_length(error_message) <= 256)),
|
||||
CONSTRAINT snippet_repository_storage_moves_destination_storage_name CHECK ((char_length(destination_storage_name) <= 255)),
|
||||
CONSTRAINT snippet_repository_storage_moves_source_storage_name CHECK ((char_length(source_storage_name) <= 255))
|
||||
);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ module API
|
|||
expose :human_state_name, as: :state, documentation: { type: 'string', example: 'scheduled' }
|
||||
expose :source_storage_name, documentation: { type: 'string', example: 'default' }
|
||||
expose :destination_storage_name, documentation: { type: 'string', example: 'storage1' }
|
||||
expose :error_message, documentation: { type: 'string', example: 'Failed to move repository' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,13 +8,32 @@
|
|||
"destination_storage_name",
|
||||
"project"
|
||||
],
|
||||
"properties" : {
|
||||
"id": { "type": "integer" },
|
||||
"created_at": { "type": "string", "format": "date-time" },
|
||||
"state": { "type": "string" },
|
||||
"source_storage_name": { "type": "string" },
|
||||
"destination_storage_name": { "type": "string" },
|
||||
"project": { "type": "object" }
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"state": {
|
||||
"type": "string"
|
||||
},
|
||||
"source_storage_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"destination_storage_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"error_message": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"project": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,32 @@
|
|||
"destination_storage_name",
|
||||
"snippet"
|
||||
],
|
||||
"properties" : {
|
||||
"id": { "type": "integer" },
|
||||
"created_at": { "type": "string", "format": "date-time" },
|
||||
"state": { "type": "string" },
|
||||
"source_storage_name": { "type": "string" },
|
||||
"destination_storage_name": { "type": "string" },
|
||||
"snippet": { "type": "object" }
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"state": {
|
||||
"type": "string"
|
||||
},
|
||||
"source_storage_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"destination_storage_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"error_message": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"snippet": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ RSpec.describe Projects::UpdateRepositoryStorageService, feature_category: :sour
|
|||
expect(project).not_to be_repository_read_only
|
||||
expect(project.repository_storage).to eq('test_second_storage')
|
||||
expect(project.project_repository.shard_name).to eq('test_second_storage')
|
||||
expect(repository_storage_move.reload).to be_finished
|
||||
expect(repository_storage_move.error_message).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -100,6 +102,7 @@ RSpec.describe Projects::UpdateRepositoryStorageService, feature_category: :sour
|
|||
|
||||
expect(project).not_to be_repository_read_only
|
||||
expect(repository_storage_move.reload).to be_failed
|
||||
expect(repository_storage_move.error_message).to eq('Boom')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -126,7 +129,7 @@ RSpec.describe Projects::UpdateRepositoryStorageService, feature_category: :sour
|
|||
|
||||
expect(project_repository_double).to receive(:replicate)
|
||||
.with(project.repository.raw)
|
||||
.and_raise(Gitlab::Git::CommandError)
|
||||
.and_raise(Gitlab::Git::CommandError, 'Boom')
|
||||
expect(project_repository_double).to receive(:remove)
|
||||
|
||||
expect do
|
||||
|
|
@ -136,6 +139,7 @@ RSpec.describe Projects::UpdateRepositoryStorageService, feature_category: :sour
|
|||
expect(project).not_to be_repository_read_only
|
||||
expect(project.repository_storage).to eq('default')
|
||||
expect(repository_storage_move).to be_failed
|
||||
expect(repository_storage_move.error_message).to eq('Boom')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ RSpec.describe Snippets::UpdateRepositoryStorageService, feature_category: :sour
|
|||
expect(snippet).not_to be_repository_read_only
|
||||
expect(snippet.repository_storage).to eq(destination)
|
||||
expect(snippet.snippet_repository.shard_name).to eq(destination)
|
||||
expect(repository_storage_move.reload).to be_finished
|
||||
expect(repository_storage_move.error_message).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -66,7 +68,7 @@ RSpec.describe Snippets::UpdateRepositoryStorageService, feature_category: :sour
|
|||
it 'unmarks the repository as read-only without updating the repository storage' do
|
||||
expect(snippet_repository_double).to receive(:replicate)
|
||||
.with(snippet.repository.raw)
|
||||
.and_raise(Gitlab::Git::CommandError)
|
||||
.and_raise(Gitlab::Git::CommandError, 'Boom')
|
||||
expect(snippet_repository_double).to receive(:remove)
|
||||
|
||||
expect do
|
||||
|
|
@ -76,6 +78,7 @@ RSpec.describe Snippets::UpdateRepositoryStorageService, feature_category: :sour
|
|||
expect(snippet).not_to be_repository_read_only
|
||||
expect(snippet.repository_storage).to eq('default')
|
||||
expect(repository_storage_move).to be_failed
|
||||
expect(repository_storage_move.error_message).to eq('Boom')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue