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
39a44e03
Commit
39a44e03
authored
Oct 10, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include attachment and LFS object sync failures in Geo node status
parent
98f55734
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
91 additions
and
1 deletion
+91
-1
app/assets/javascripts/geo_nodes.js
app/assets/javascripts/geo_nodes.js
+8
-0
app/models/geo_node_status.rb
app/models/geo_node_status.rb
+17
-1
app/serializers/geo_node_status_entity.rb
app/serializers/geo_node_status_entity.rb
+2
-0
app/views/admin/geo_nodes/index.html.haml
app/views/admin/geo_nodes/index.html.haml
+8
-0
lib/api/entities.rb
lib/api/entities.rb
+2
-0
spec/controllers/admin/geo_nodes_controller_spec.rb
spec/controllers/admin/geo_nodes_controller_spec.rb
+2
-0
spec/fixtures/api/schemas/geo_node_status.json
spec/fixtures/api/schemas/geo_node_status.json
+4
-0
spec/models/geo_node_status_spec.rb
spec/models/geo_node_status_spec.rb
+44
-0
spec/serializers/geo_node_status_entity_spec.rb
spec/serializers/geo_node_status_entity_spec.rb
+4
-0
No files found.
app/assets/javascripts/geo_nodes.js
View file @
39a44e03
...
@@ -20,7 +20,9 @@ class GeoNodeStatus {
...
@@ -20,7 +20,9 @@ class GeoNodeStatus {
this
.
$repositoriesSynced
=
$
(
'
.js-repositories-synced
'
,
this
.
$status
);
this
.
$repositoriesSynced
=
$
(
'
.js-repositories-synced
'
,
this
.
$status
);
this
.
$repositoriesFailed
=
$
(
'
.js-repositories-failed
'
,
this
.
$status
);
this
.
$repositoriesFailed
=
$
(
'
.js-repositories-failed
'
,
this
.
$status
);
this
.
$lfsObjectsSynced
=
$
(
'
.js-lfs-objects-synced
'
,
this
.
$status
);
this
.
$lfsObjectsSynced
=
$
(
'
.js-lfs-objects-synced
'
,
this
.
$status
);
this
.
$lfsObjectsFailed
=
$
(
'
.js-lfs-objects-failed
'
,
this
.
$status
);
this
.
$attachmentsSynced
=
$
(
'
.js-attachments-synced
'
,
this
.
$status
);
this
.
$attachmentsSynced
=
$
(
'
.js-attachments-synced
'
,
this
.
$status
);
this
.
$attachmentsFailed
=
$
(
'
.js-attachments-failed
'
,
this
.
$status
);
this
.
$lastEventSeen
=
$
(
'
.js-last-event-seen
'
,
this
.
$status
);
this
.
$lastEventSeen
=
$
(
'
.js-last-event-seen
'
,
this
.
$status
);
this
.
$lastCursorEvent
=
$
(
'
.js-last-cursor-event
'
,
this
.
$status
);
this
.
$lastCursorEvent
=
$
(
'
.js-last-cursor-event
'
,
this
.
$status
);
this
.
$health
=
$
(
'
.js-health
'
,
this
.
$status
);
this
.
$health
=
$
(
'
.js-health
'
,
this
.
$status
);
...
@@ -78,15 +80,21 @@ class GeoNodeStatus {
...
@@ -78,15 +80,21 @@ class GeoNodeStatus {
status
.
lfs_objects_count
,
status
.
lfs_objects_count
,
status
.
lfs_objects_synced_in_percentage
);
status
.
lfs_objects_synced_in_percentage
);
const
lfsFailedText
=
gl
.
text
.
addDelimiter
(
status
.
lfs_objects_failed_count
);
const
attachmentText
=
GeoNodeStatus
.
formatCountAndPercentage
(
const
attachmentText
=
GeoNodeStatus
.
formatCountAndPercentage
(
status
.
attachments_synced_count
,
status
.
attachments_synced_count
,
status
.
attachments_count
,
status
.
attachments_count
,
status
.
attachments_synced_in_percentage
);
status
.
attachments_synced_in_percentage
);
const
attachmentFailedText
=
gl
.
text
.
addDelimiter
(
status
.
attachments_failed_count
);
this
.
$repositoriesSynced
.
text
(
repoText
);
this
.
$repositoriesSynced
.
text
(
repoText
);
this
.
$repositoriesFailed
.
text
(
repoFailedText
);
this
.
$repositoriesFailed
.
text
(
repoFailedText
);
this
.
$lfsObjectsSynced
.
text
(
lfsText
);
this
.
$lfsObjectsSynced
.
text
(
lfsText
);
this
.
$lfsObjectsFailed
.
text
(
lfsFailedText
);
this
.
$attachmentsSynced
.
text
(
attachmentText
);
this
.
$attachmentsSynced
.
text
(
attachmentText
);
this
.
$attachmentsFailed
.
text
(
attachmentFailedText
);
const
eventDate
=
gl
.
utils
.
formatDate
(
new
Date
(
status
.
last_event_date
));
const
eventDate
=
gl
.
utils
.
formatDate
(
new
Date
(
status
.
last_event_date
));
const
cursorDate
=
gl
.
utils
.
formatDate
(
new
Date
(
status
.
cursor_last_event_date
));
const
cursorDate
=
gl
.
utils
.
formatDate
(
new
Date
(
status
.
cursor_last_event_date
));
...
...
app/models/geo_node_status.rb
View file @
39a44e03
...
@@ -114,6 +114,14 @@ class GeoNodeStatus
...
@@ -114,6 +114,14 @@ class GeoNodeStatus
@lfs_objects_synced_count
=
value
.
to_i
@lfs_objects_synced_count
=
value
.
to_i
end
end
def
lfs_objects_failed_count
@lfs_objects_failed_count
||=
Geo
::
FileRegistry
.
failed
.
where
(
file_type: :lfs
).
count
end
def
lfs_objects_failed_count
=
(
value
)
@lfs_objects_failed_count
=
value
.
to_i
end
def
lfs_objects_synced_in_percentage
def
lfs_objects_synced_in_percentage
sync_percentage
(
lfs_objects_count
,
lfs_objects_synced_count
)
sync_percentage
(
lfs_objects_count
,
lfs_objects_synced_count
)
end
end
...
@@ -129,7 +137,7 @@ class GeoNodeStatus
...
@@ -129,7 +137,7 @@ class GeoNodeStatus
def
attachments_synced_count
def
attachments_synced_count
@attachments_synced_count
||=
begin
@attachments_synced_count
||=
begin
upload_ids
=
attachments
.
pluck
(
:id
)
upload_ids
=
attachments
.
pluck
(
:id
)
synced_ids
=
Geo
::
FileRegistry
.
synced
.
where
(
file_type:
[
:attachment
,
:avatar
,
:file
]
).
pluck
(
:file_id
)
synced_ids
=
Geo
::
FileRegistry
.
synced
.
where
(
file_type:
Geo
::
FileService
::
DEFAULT_OBJECT_TYPES
).
pluck
(
:file_id
)
(
synced_ids
&
upload_ids
).
length
(
synced_ids
&
upload_ids
).
length
end
end
...
@@ -139,6 +147,14 @@ class GeoNodeStatus
...
@@ -139,6 +147,14 @@ class GeoNodeStatus
@attachments_synced_count
=
value
.
to_i
@attachments_synced_count
=
value
.
to_i
end
end
def
attachments_failed_count
@attachments_failed_count
||=
Geo
::
FileRegistry
.
failed
.
where
(
file_type:
Geo
::
FileService
::
DEFAULT_OBJECT_TYPES
).
count
end
def
attachments_failed_count
=
(
value
)
@attachments_failed_count
=
value
.
to_i
end
def
attachments_synced_in_percentage
def
attachments_synced_in_percentage
sync_percentage
(
attachments_count
,
attachments_synced_count
)
sync_percentage
(
attachments_count
,
attachments_synced_count
)
end
end
...
...
app/serializers/geo_node_status_entity.rb
View file @
39a44e03
...
@@ -10,6 +10,7 @@ class GeoNodeStatusEntity < Grape::Entity
...
@@ -10,6 +10,7 @@ class GeoNodeStatusEntity < Grape::Entity
expose
:attachments_count
expose
:attachments_count
expose
:attachments_synced_count
expose
:attachments_synced_count
expose
:attachments_failed_count
expose
:attachments_synced_in_percentage
do
|
node
|
expose
:attachments_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
attachments_synced_in_percentage
,
precision:
2
)
number_to_percentage
(
node
.
attachments_synced_in_percentage
,
precision:
2
)
end
end
...
@@ -18,6 +19,7 @@ class GeoNodeStatusEntity < Grape::Entity
...
@@ -18,6 +19,7 @@ class GeoNodeStatusEntity < Grape::Entity
expose
:lfs_objects_count
expose
:lfs_objects_count
expose
:lfs_objects_synced_count
expose
:lfs_objects_synced_count
expose
:lfs_objects_failed_count
expose
:lfs_objects_synced_in_percentage
do
|
node
|
expose
:lfs_objects_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
lfs_objects_synced_in_percentage
,
precision:
2
)
number_to_percentage
(
node
.
lfs_objects_synced_in_percentage
,
precision:
2
)
end
end
...
...
app/views/admin/geo_nodes/index.html.haml
View file @
39a44e03
...
@@ -62,10 +62,18 @@
...
@@ -62,10 +62,18 @@
%span
.help-block
%span
.help-block
LFS objects synced:
LFS objects synced:
%strong
.node-info.js-lfs-objects-synced
%strong
.node-info.js-lfs-objects-synced
%p
%span
.help-block
LFS objects failed:
%strong
.node-info.js-lfs-objects-failed
%p
%p
%span
.help-block
%span
.help-block
Attachments synced:
Attachments synced:
%strong
.node-info.js-attachments-synced
%strong
.node-info.js-attachments-synced
%p
%span
.help-block
Attachments failed:
%strong
.node-info.js-attachments-failed
%p
%p
.advanced-geo-node-status-container
.advanced-geo-node-status-container
.advanced-status.hidden
.advanced-status.hidden
...
...
lib/api/entities.rb
View file @
39a44e03
...
@@ -1018,8 +1018,10 @@ module API
...
@@ -1018,8 +1018,10 @@ module API
expose
:repositories_failed_count
expose
:repositories_failed_count
expose
:lfs_objects_count
expose
:lfs_objects_count
expose
:lfs_objects_synced_count
expose
:lfs_objects_synced_count
expose
:lfs_objects_failed_count
expose
:attachments_count
expose
:attachments_count
expose
:attachments_synced_count
expose
:attachments_synced_count
expose
:attachments_failed_count
expose
:last_event_id
expose
:last_event_id
expose
:last_event_date
expose
:last_event_date
expose
:cursor_last_event_id
expose
:cursor_last_event_id
...
...
spec/controllers/admin/geo_nodes_controller_spec.rb
View file @
39a44e03
...
@@ -264,8 +264,10 @@ describe Admin::GeoNodesController, :postgresql do
...
@@ -264,8 +264,10 @@ describe Admin::GeoNodesController, :postgresql do
id:
1
,
id:
1
,
health:
nil
,
health:
nil
,
attachments_count:
329
,
attachments_count:
329
,
attachments_failed_count:
13
,
attachments_synced_count:
141
,
attachments_synced_count:
141
,
lfs_objects_count:
256
,
lfs_objects_count:
256
,
lfs_objects_failed_count:
12
,
lfs_objects_synced_count:
123
,
lfs_objects_synced_count:
123
,
repositories_count:
10
,
repositories_count:
10
,
repositories_synced_count:
5
,
repositories_synced_count:
5
,
...
...
spec/fixtures/api/schemas/geo_node_status.json
View file @
39a44e03
...
@@ -5,8 +5,10 @@
...
@@ -5,8 +5,10 @@
"healthy"
,
"healthy"
,
"health"
,
"health"
,
"attachments_count"
,
"attachments_count"
,
"attachments_failed_count"
,
"attachments_synced_count"
,
"attachments_synced_count"
,
"lfs_objects_count"
,
"lfs_objects_count"
,
"lfs_objects_failed_count"
,
"lfs_objects_synced_count"
,
"lfs_objects_synced_count"
,
"db_replication_lag"
,
"db_replication_lag"
,
"repositories_count"
,
"repositories_count"
,
...
@@ -22,10 +24,12 @@
...
@@ -22,10 +24,12 @@
"healthy"
:
{
"type"
:
"boolean"
},
"healthy"
:
{
"type"
:
"boolean"
},
"health"
:
{
"type"
:
"string"
},
"health"
:
{
"type"
:
"string"
},
"attachments_count"
:
{
"type"
:
"integer"
},
"attachments_count"
:
{
"type"
:
"integer"
},
"attachments_failed_count"
:
{
"type"
:
"integer"
},
"attachments_synced_count"
:
{
"type"
:
"integer"
},
"attachments_synced_count"
:
{
"type"
:
"integer"
},
"attachments_synced_in_percentage"
:
{
"type"
:
"string"
},
"attachments_synced_in_percentage"
:
{
"type"
:
"string"
},
"db_replication_lag"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"db_replication_lag"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"lfs_objects_count"
:
{
"type"
:
"integer"
},
"lfs_objects_count"
:
{
"type"
:
"integer"
},
"lfs_objects_failed_count"
:
{
"type"
:
"integer"
},
"lfs_objects_synced_count"
:
{
"type"
:
"integer"
},
"lfs_objects_synced_count"
:
{
"type"
:
"integer"
},
"lfs_objects_synced_in_percentage"
:
{
"type"
:
"string"
},
"lfs_objects_synced_in_percentage"
:
{
"type"
:
"string"
},
"repositories_count"
:
{
"type"
:
"integer"
},
"repositories_count"
:
{
"type"
:
"integer"
},
...
...
spec/models/geo_node_status_spec.rb
View file @
39a44e03
...
@@ -39,6 +39,17 @@ describe GeoNodeStatus do
...
@@ -39,6 +39,17 @@ describe GeoNodeStatus do
end
end
describe
'#attachments_synced_count'
do
describe
'#attachments_synced_count'
do
it
'only counts successful syncs'
do
create_list
(
:user
,
3
,
avatar:
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/png'
))
uploads
=
Upload
.
all
.
pluck
(
:id
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
uploads
[
0
])
create
(
:geo_file_registry
,
:avatar
,
file_id:
uploads
[
1
])
create
(
:geo_file_registry
,
:avatar
,
file_id:
uploads
[
2
],
success:
false
)
expect
(
subject
.
attachments_synced_count
).
to
eq
(
2
)
end
it
'does not count synced files that were replaced'
do
it
'does not count synced files that were replaced'
do
user
=
create
(
:user
,
avatar:
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/png'
))
user
=
create
(
:user
,
avatar:
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/png'
))
...
@@ -68,6 +79,21 @@ describe GeoNodeStatus do
...
@@ -68,6 +79,21 @@ describe GeoNodeStatus do
end
end
end
end
describe
'#attachments_failed_count'
do
it
'counts failed avatars, attachment, personal snippets and files'
do
# These two should be ignored
create
(
:geo_file_registry
,
:lfs
,
success:
false
)
create
(
:geo_file_registry
)
create
(
:geo_file_registry
,
file_type: :personal_file
,
success:
false
)
create
(
:geo_file_registry
,
file_type: :attachment
,
success:
false
)
create
(
:geo_file_registry
,
:avatar
,
success:
false
)
create
(
:geo_file_registry
,
success:
false
)
expect
(
subject
.
attachments_failed_count
).
to
eq
(
4
)
end
end
describe
'#attachments_synced_in_percentage'
do
describe
'#attachments_synced_in_percentage'
do
let
(
:avatar
)
{
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/dk.png'
))
}
let
(
:avatar
)
{
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/dk.png'
))
}
let
(
:upload_1
)
{
create
(
:upload
,
model:
group
,
path:
avatar
)
}
let
(
:upload_1
)
{
create
(
:upload
,
model:
group
,
path:
avatar
)
}
...
@@ -113,6 +139,20 @@ describe GeoNodeStatus do
...
@@ -113,6 +139,20 @@ describe GeoNodeStatus do
end
end
end
end
describe
'#lfs_objects_failed'
do
it
'counts failed LFS objects'
do
# These four should be ignored
create
(
:geo_file_registry
,
success:
false
)
create
(
:geo_file_registry
,
:avatar
,
success:
false
)
create
(
:geo_file_registry
,
file_type: :attachment
,
success:
false
)
create
(
:geo_file_registry
,
:lfs
)
create
(
:geo_file_registry
,
:lfs
,
success:
false
)
expect
(
subject
.
lfs_objects_failed_count
).
to
eq
(
1
)
end
end
describe
'#lfs_objects_synced_in_percentage'
do
describe
'#lfs_objects_synced_in_percentage'
do
let
(
:lfs_object_project
)
{
create
(
:lfs_objects_project
,
project:
project_1
)
}
let
(
:lfs_object_project
)
{
create
(
:lfs_objects_project
,
project:
project_1
)
}
...
@@ -218,8 +258,10 @@ describe GeoNodeStatus do
...
@@ -218,8 +258,10 @@ describe GeoNodeStatus do
allow
(
Gitlab
::
Geo
::
HealthCheck
).
to
receive
(
:db_replication_lag
).
and_return
(
nil
)
allow
(
Gitlab
::
Geo
::
HealthCheck
).
to
receive
(
:db_replication_lag
).
and_return
(
nil
)
subject
.
attachments_count
=
nil
subject
.
attachments_count
=
nil
subject
.
attachments_synced_count
=
nil
subject
.
attachments_synced_count
=
nil
subject
.
attachments_failed_count
=
nil
subject
.
lfs_objects_count
=
nil
subject
.
lfs_objects_count
=
nil
subject
.
lfs_objects_synced_count
=
nil
subject
.
lfs_objects_synced_count
=
nil
subject
.
lfs_objects_failed_count
=
nil
subject
.
repositories_count
=
nil
subject
.
repositories_count
=
nil
subject
.
repositories_synced_count
=
nil
subject
.
repositories_synced_count
=
nil
subject
.
repositories_failed_count
=
nil
subject
.
repositories_failed_count
=
nil
...
@@ -235,9 +277,11 @@ describe GeoNodeStatus do
...
@@ -235,9 +277,11 @@ describe GeoNodeStatus do
expect
(
subject
.
repositories_failed_count
).
to
be_zero
expect
(
subject
.
repositories_failed_count
).
to
be_zero
expect
(
subject
.
lfs_objects_count
).
to
be_zero
expect
(
subject
.
lfs_objects_count
).
to
be_zero
expect
(
subject
.
lfs_objects_synced_count
).
to
be_zero
expect
(
subject
.
lfs_objects_synced_count
).
to
be_zero
expect
(
subject
.
lfs_objects_failed_count
).
to
be_zero
expect
(
subject
.
lfs_objects_synced_in_percentage
).
to
be_zero
expect
(
subject
.
lfs_objects_synced_in_percentage
).
to
be_zero
expect
(
subject
.
attachments_count
).
to
be_zero
expect
(
subject
.
attachments_count
).
to
be_zero
expect
(
subject
.
attachments_synced_count
).
to
be_zero
expect
(
subject
.
attachments_synced_count
).
to
be_zero
expect
(
subject
.
attachments_failed_count
).
to
be_zero
expect
(
subject
.
attachments_synced_in_percentage
).
to
be_zero
expect
(
subject
.
attachments_synced_in_percentage
).
to
be_zero
expect
(
subject
.
last_event_id
).
to
be_nil
expect
(
subject
.
last_event_id
).
to
be_nil
expect
(
subject
.
last_event_date
).
to
be_nil
expect
(
subject
.
last_event_date
).
to
be_nil
...
...
spec/serializers/geo_node_status_entity_spec.rb
View file @
39a44e03
...
@@ -6,8 +6,10 @@ describe GeoNodeStatusEntity, :postgresql do
...
@@ -6,8 +6,10 @@ describe GeoNodeStatusEntity, :postgresql do
id:
1
,
id:
1
,
health:
''
,
health:
''
,
attachments_count:
329
,
attachments_count:
329
,
attachments_failed_count:
25
,
attachments_synced_count:
141
,
attachments_synced_count:
141
,
lfs_objects_count:
256
,
lfs_objects_count:
256
,
lfs_objects_failed_count:
12
,
lfs_objects_synced_count:
123
,
lfs_objects_synced_count:
123
,
repositories_count:
10
,
repositories_count:
10
,
repositories_synced_count:
5
,
repositories_synced_count:
5
,
...
@@ -29,9 +31,11 @@ describe GeoNodeStatusEntity, :postgresql do
...
@@ -29,9 +31,11 @@ describe GeoNodeStatusEntity, :postgresql do
it
{
is_expected
.
to
have_key
(
:healthy
)
}
it
{
is_expected
.
to
have_key
(
:healthy
)
}
it
{
is_expected
.
to
have_key
(
:health
)
}
it
{
is_expected
.
to
have_key
(
:health
)
}
it
{
is_expected
.
to
have_key
(
:attachments_count
)
}
it
{
is_expected
.
to
have_key
(
:attachments_count
)
}
it
{
is_expected
.
to
have_key
(
:attachments_failed_count
)
}
it
{
is_expected
.
to
have_key
(
:attachments_synced_count
)
}
it
{
is_expected
.
to
have_key
(
:attachments_synced_count
)
}
it
{
is_expected
.
to
have_key
(
:attachments_synced_in_percentage
)
}
it
{
is_expected
.
to
have_key
(
:attachments_synced_in_percentage
)
}
it
{
is_expected
.
to
have_key
(
:lfs_objects_count
)
}
it
{
is_expected
.
to
have_key
(
:lfs_objects_count
)
}
it
{
is_expected
.
to
have_key
(
:lfs_objects_failed_count
)
}
it
{
is_expected
.
to
have_key
(
:lfs_objects_synced_count
)
}
it
{
is_expected
.
to
have_key
(
:lfs_objects_synced_count
)
}
it
{
is_expected
.
to
have_key
(
:lfs_objects_synced_in_percentage
)
}
it
{
is_expected
.
to
have_key
(
:lfs_objects_synced_in_percentage
)
}
it
{
is_expected
.
to
have_key
(
:repositories_count
)
}
it
{
is_expected
.
to
have_key
(
:repositories_count
)
}
...
...
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