Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
60ff0a7e
Commit
60ff0a7e
authored
Dec 22, 2021
by
Michael Kozono
Committed by
Douglas Barbosa Alexandre
Dec 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Geo: Improve missing on primary failure reason
parent
0dc65764
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
4 deletions
+27
-4
ee/lib/gitlab/geo/replication/blob_downloader.rb
ee/lib/gitlab/geo/replication/blob_downloader.rb
+20
-1
ee/spec/lib/gitlab/geo/replication/blob_downloader_spec.rb
ee/spec/lib/gitlab/geo/replication/blob_downloader_spec.rb
+7
-3
No files found.
ee/lib/gitlab/geo/replication/blob_downloader.rb
View file @
60ff0a7e
...
...
@@ -162,7 +162,7 @@ module Gitlab
# Check for failures
unless
response
.
status
.
success?
return
failure_result
(
primary_missing_file:
primary_missing_file?
(
response
),
reason:
"Non-success HTTP response status code
#{
response
.
status
.
code
}
"
,
extra_details:
{
status_code:
response
.
status
.
code
,
reason:
response
.
status
.
reason
,
url:
url
}
)
return
non_success_response_result
(
response
,
url
)
end
# Stream to temporary file on disk
...
...
@@ -237,6 +237,25 @@ module Gitlab
def
actual_checksum
(
file_path
)
@actual_checksum
=
Digest
::
SHA256
.
file
(
file_path
).
hexdigest
end
def
non_success_response_result
(
response
,
url
)
primary_missing_file
=
primary_missing_file?
(
response
)
reason
=
if
primary_missing_file
"The file is missing on the Geo primary site"
else
"Non-success HTTP response status code
#{
response
.
status
.
code
}
"
end
failure_result
(
primary_missing_file:
primary_missing_file
,
reason:
reason
,
extra_details:
{
status_code:
response
.
status
.
code
,
reason:
response
.
status
.
reason
,
url:
url
}
)
end
end
end
end
...
...
ee/spec/lib/gitlab/geo/replication/blob_downloader_spec.rb
View file @
60ff0a7e
...
...
@@ -170,7 +170,7 @@ RSpec.describe Gitlab::Geo::Replication::BlobDownloader do
result
=
subject
.
execute
expect_blob_downloader_result
(
result
,
success:
false
,
bytes_downloaded:
0
,
primary_missing_file:
true
)
expect_blob_downloader_result
(
result
,
success:
false
,
bytes_downloaded:
0
,
primary_missing_file:
true
,
reason:
'The file is missing on the Geo primary site'
)
end
end
...
...
@@ -183,7 +183,7 @@ RSpec.describe Gitlab::Geo::Replication::BlobDownloader do
result
=
subject
.
execute
expect_blob_downloader_result
(
result
,
success:
false
,
bytes_downloaded:
0
,
primary_missing_file:
false
)
expect_blob_downloader_result
(
result
,
success:
false
,
bytes_downloaded:
0
,
primary_missing_file:
false
,
reason:
'Non-success HTTP response status code 404'
)
end
end
end
...
...
@@ -232,11 +232,15 @@ RSpec.describe Gitlab::Geo::Replication::BlobDownloader do
end
end
def
expect_blob_downloader_result
(
result
,
success
:,
bytes_downloaded
:,
primary_missing_file
:,
extra_details
:
nil
)
def
expect_blob_downloader_result
(
result
,
success
:,
bytes_downloaded
:,
primary_missing_file
:,
reason
:
nil
)
expect
(
result
.
success
).
to
eq
(
success
)
expect
(
result
.
bytes_downloaded
).
to
eq
(
bytes_downloaded
)
expect
(
result
.
primary_missing_file
).
to
eq
(
primary_missing_file
)
if
reason
expect
(
result
.
reason
).
to
eq
(
reason
)
end
# Sanity check to help ensure a valid test
expect
(
success
).
not_to
be_nil
expect
(
primary_missing_file
).
not_to
be_nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment