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
e010e5cd
Commit
e010e5cd
authored
Nov 15, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor some error logging, added last_repository_sync_failure to project registry and spec
parent
dcfc2491
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
22 deletions
+32
-22
app/services/geo/base_sync_service.rb
app/services/geo/base_sync_service.rb
+6
-0
app/services/geo/repository_sync_service.rb
app/services/geo/repository_sync_service.rb
+14
-17
db/geo/schema.rb
db/geo/schema.rb
+2
-1
lib/gitlab/geo/jwt_request_decoder.rb
lib/gitlab/geo/jwt_request_decoder.rb
+4
-2
lib/gitlab/import_export/merge_request_parser.rb
lib/gitlab/import_export/merge_request_parser.rb
+1
-1
spec/services/geo/repository_sync_service_spec.rb
spec/services/geo/repository_sync_service_spec.rb
+5
-1
No files found.
app/services/geo/base_sync_service.rb
View file @
e010e5cd
...
...
@@ -150,6 +150,12 @@ module Geo
registry
.
update!
(
attrs
)
end
def
fail_registry
(
message
,
error
)
log_error
(
message
,
error
)
registry
.
update!
(
last_repository_sync_failure:
"
#{
message
}
:
#{
error
.
message
}
"
)
end
def
type
self
.
class
.
type
end
...
...
app/services/geo/repository_sync_service.rb
View file @
e010e5cd
...
...
@@ -20,25 +20,22 @@ module Geo
else
project
.
ensure_repository
fetch_geo_mirror
(
project
.
repository
)
end
update_registry
(
finished_at:
DateTime
.
now
)
log_info
(
'Finished repository sync'
,
update_delay_s:
update_delay_in_seconds
,
download_time_s:
download_time_in_seconds
)
rescue
Gitlab
::
Shell
::
Error
,
Gitlab
::
Git
::
RepositoryMirroring
::
RemoteError
,
Geo
::
EmptyCloneUrlPrefixError
=>
e
log_error
(
'Error syncing repository'
,
e
)
registry
.
increment!
(
:repository_retry_count
)
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
=>
e
log_error
(
'Invalid repository'
,
e
)
end
update_registry
(
finished_at:
DateTime
.
now
)
log_info
(
'Finished repository sync'
,
update_delay_s:
update_delay_in_seconds
,
download_time_s:
download_time_in_seconds
)
rescue
Gitlab
::
Shell
::
Error
,
Gitlab
::
Git
::
RepositoryMirroring
::
RemoteError
,
Geo
::
EmptyCloneUrlPrefixError
=>
e
fail_registry
(
'Error syncing repository'
,
e
)
registry
.
increment!
(
:repository_retry_count
)
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
=>
e
fail_registry
(
'Invalid repository'
,
e
)
log_info
(
'Setting force_to_redownload flag'
)
registry
.
update
(
force_to_redownload_repository:
true
,
repository_retry_count:
retry_count
+
1
)
log_info
(
'Expiring caches'
)
project
.
repository
.
after_create
ensure
repository_retry_count:
retry_count
+
1
)
log_info
(
'Expiring caches'
)
project
.
repository
.
after_create
ensure
clean_up_temporary_repository
if
redownload
end
...
...
db/geo/schema.rb
View file @
e010e5cd
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201711
01105200
)
do
ActiveRecord
::
Schema
.
define
(
version:
201711
15143841
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -50,6 +50,7 @@ ActiveRecord::Schema.define(version: 20171101105200) do
t
.
integer
"wiki_retry_count"
t
.
datetime
"wiki_retry_at"
t
.
boolean
"force_to_redownload_wiki"
t
.
string
"last_repository_sync_failure"
end
add_index
"project_registry"
,
[
"last_repository_successful_sync_at"
],
name:
"index_project_registry_on_last_repository_successful_sync_at"
,
using: :btree
...
...
lib/gitlab/geo/jwt_request_decoder.rb
View file @
e010e5cd
module
Gitlab
module
Geo
include
LogHelpers
InvalidDecryptionKeyError
=
Class
.
new
(
StandardError
)
class
JwtRequestDecoder
...
...
@@ -33,7 +35,7 @@ module Gitlab
data
=
decode_auth_header
rescue
OpenSSL
::
Cipher
::
CipherError
message
=
'Error decrypting the Geo secret from the database. Check that the primary and secondary have the same db_key_base.'
Rails
.
logger
.
error
(
message
)
log_
error
(
message
)
raise
InvalidDecryptionKeyError
.
new
(
message
)
end
...
...
@@ -54,7 +56,7 @@ module Gitlab
data
&
.
deep_symbolize_keys!
data
rescue
JWT
::
DecodeError
=>
e
Rails
.
logger
.
error
(
"Error decoding Geo request:
#{
e
}
"
)
log_
error
(
"Error decoding Geo request:
#{
e
}
"
)
return
end
end
...
...
lib/gitlab/import_export/merge_request_parser.rb
View file @
e010e5cd
...
...
@@ -26,7 +26,7 @@ module Gitlab
end
def
fetch_ref
@project
.
repository
.
fetch_ref
(
@project
.
repository
,
source_ref:
@diff_head_sha
,
target_ref:
@merge_request
.
source_branch
)
@project
.
repository
.
fetc
e
h_ref
(
@project
.
repository
,
source_ref:
@diff_head_sha
,
target_ref:
@merge_request
.
source_branch
)
end
def
branch_exists?
(
branch_name
)
...
...
spec/services/geo/repository_sync_service_spec.rb
View file @
e010e5cd
...
...
@@ -145,7 +145,7 @@ describe Geo::RepositorySyncService do
let
(
:registry
)
{
Geo
::
ProjectRegistry
.
find_by
(
project_id:
project
.
id
)
}
before
do
allow
(
repository
).
to
receive
(
:fetch_as_mirror
).
with
(
url_to_repo
,
forced:
true
)
{
raise
Gitlab
::
Shell
::
Error
}
allow
(
repository
).
to
receive
(
:fetch_as_mirror
).
with
(
url_to_repo
,
forced:
true
)
{
raise
Gitlab
::
Shell
::
Error
,
'shell error'
}
subject
.
execute
end
...
...
@@ -223,6 +223,10 @@ describe Geo::RepositorySyncService do
# of range" in the first update to the project registry.
registry
.
reload
expect
(
registry
.
repository_retry_at
).
to
be_nil
it
'sets last_repository_sync_failure'
do
expect
(
registry
.
last_repository_sync_failure
).
to
eq
(
'Error syncing repository: shell error'
)
end
end
end
...
...
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