Skip to content
Snippets Groups Projects
Verified Commit 2ced7f5f authored by Aakriti Gupta's avatar Aakriti Gupta :red_circle: Committed by GitLab
Browse files

Merge branch 'ag-decrease-log-level' into 'master'

Decrease log level of false error when project repo is missing during replication

See merge request !178184



Merged-by: default avatarDmitry Gruzd <dgruzd@gitlab.com>
Approved-by: default avatarScott Murray <smurray@gitlab.com>
Approved-by: default avatarDouglas Barbosa Alexandre <dbalexandre@gmail.com>
Reviewed-by: default avatarScott Murray <smurray@gitlab.com>
Co-authored-by: default avatarAakriti Gupta <agupta@gitlab.com>

(cherry-picked from commit 12379b8f)

c50b8243 Decrease log level of false error when project repo is missing during replication

Co-authored-by: default avatarDmitry Gruzd <dgruzd@gitlab.com>
parent 965b8d1b
No related branches found
No related tags found
1 merge request!180574Backport into 17.7: Decrease log level of false error
......@@ -134,7 +134,7 @@ def update_root_ref(remote_url, authorization)
root_ref = find_remote_root_ref(remote_url, authorization)
change_head(root_ref) if root_ref.present?
rescue ::Gitlab::Git::Repository::NoRepository => e
::Gitlab::AppLogger.error("Error updating root ref for repository #{full_path} (#{container.id}): #{e.message}.")
::Gitlab::AppLogger.info("Error updating root ref for repository #{full_path} (#{container.id}): #{e.message}.")
nil
end
......
......@@ -372,12 +372,28 @@ def create_remote_branch(remote_name, branch_name, target)
.not_to change { project.default_branch }
end
it 'does not raise error when repository does not exist' do
allow(repository).to receive(:find_remote_root_ref)
.with(url, auth)
.and_raise(Gitlab::Git::Repository::NoRepository)
context 'when project repo is missing' do
before do
allow(repository).to receive(:find_remote_root_ref)
.with(url, auth)
.and_raise(Gitlab::Git::Repository::NoRepository)
end
expect { repository.update_root_ref(url, auth) }.not_to raise_error
it 'logs a message' do
expect(Gitlab::AppLogger)
.to receive(:info)
.with(/Error updating root ref for repository/)
repository.update_root_ref(url, auth)
end
it 'returns nil when NoRepository exception is raised' do
expect(repository.update_root_ref(url, auth)).to be_nil
end
it 'does not raise error' do
expect { repository.update_root_ref(url, auth) }.not_to raise_error
end
end
def stub_find_remote_root_ref(repository, ref:)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment