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
3a8d1ddc
Commit
3a8d1ddc
authored
Dec 25, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address review feedback for StorageShard implementation
parent
8baf165b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
24 additions
and
23 deletions
+24
-23
app/assets/javascripts/geo_nodes.js
app/assets/javascripts/geo_nodes.js
+2
-12
app/models/storage_shard.rb
app/models/storage_shard.rb
+7
-3
ee/app/controllers/admin/geo_nodes_controller.rb
ee/app/controllers/admin/geo_nodes_controller.rb
+1
-1
ee/app/models/geo_node_status.rb
ee/app/models/geo_node_status.rb
+7
-1
ee/app/serializers/geo_node_status_entity.rb
ee/app/serializers/geo_node_status_entity.rb
+4
-0
ee/app/views/admin/geo_nodes/index.html.haml
ee/app/views/admin/geo_nodes/index.html.haml
+1
-4
spec/ee/spec/models/geo_node_status_spec.rb
spec/ee/spec/models/geo_node_status_spec.rb
+1
-1
spec/factories/geo_node_statuses.rb
spec/factories/geo_node_statuses.rb
+1
-1
No files found.
app/assets/javascripts/geo_nodes.js
View file @
3a8d1ddc
...
@@ -78,15 +78,6 @@ class GeoNodeStatus {
...
@@ -78,15 +78,6 @@ class GeoNodeStatus {
};
};
}
}
static
sortByStorageName
(
config
)
{
return
config
.
sort
((
a
,
b
)
=>
a
.
name
.
localeCompare
(
b
.
name
));
}
static
storageConfigEquals
(
first
,
second
)
{
return
_
.
isEqual
(
GeoNodeStatus
.
sortByStorageName
(
first
),
GeoNodeStatus
.
sortByStorageName
(
second
));
}
static
renderSyncGraph
(
$itemEl
,
syncStats
)
{
static
renderSyncGraph
(
$itemEl
,
syncStats
)
{
const
graphItems
=
[
const
graphItems
=
[
{
{
...
@@ -224,10 +215,9 @@ class GeoNodeStatus {
...
@@ -224,10 +215,9 @@ class GeoNodeStatus {
this
.
$secondaryVersion
.
text
(
`
${
status
.
version
}
(
${
status
.
revision
}
) -
${
versionMismatch
}
`
);
this
.
$secondaryVersion
.
text
(
`
${
status
.
version
}
(
${
status
.
revision
}
) -
${
versionMismatch
}
`
);
}
}
if
(
!
this
.
primaryStorageConfiguration
||
!
status
.
storage_shards
)
{
if
(
!
status
.
storage_shards_match
)
{
this
.
$secondaryStorage
.
text
(
'
UNKNOWN
'
);
this
.
$secondaryStorage
.
text
(
'
UNKNOWN
'
);
}
else
if
(
GeoNodeStatus
.
storageConfigEquals
(
}
else
if
(
status
.
storage_shards_match
)
{
this
.
primaryStorageConfiguration
,
status
.
storage_shards
))
{
this
.
$secondaryStorage
.
removeClass
(
`
${
storageMismatchClass
}
`
);
this
.
$secondaryStorage
.
removeClass
(
`
${
storageMismatchClass
}
`
);
this
.
$secondaryStorage
.
text
(
'
OK
'
);
this
.
$secondaryStorage
.
text
(
'
OK
'
);
}
else
{
}
else
{
...
...
app/models/storage_shard.rb
View file @
3a8d1ddc
...
@@ -5,11 +5,10 @@ class StorageShard
...
@@ -5,11 +5,10 @@ class StorageShard
include
ActiveModel
::
Model
include
ActiveModel
::
Model
attr_accessor
:name
,
:path
,
:gitaly_address
,
:gitaly_token
attr_accessor
:name
,
:path
,
:gitaly_address
,
:gitaly_token
attr_accessor
:failure_count_threshold
,
:failure_reset_time
,
:failure_wait_time
attr_accessor
:storage_timeout
validates
:name
,
presence:
true
validates
:name
,
presence:
true
validates
:path
,
presence:
true
validates
:path
,
presence:
true
validates
:gitaly_address
,
presence:
true
# Generates an array of StorageShard objects from the currrent storage
# Generates an array of StorageShard objects from the currrent storage
# configuration using the gitlab.yml array of key/value pairs:
# configuration using the gitlab.yml array of key/value pairs:
...
@@ -17,10 +16,15 @@ class StorageShard
...
@@ -17,10 +16,15 @@ class StorageShard
# {"default"=>{"path"=>"/home/git/repositories", ...}
# {"default"=>{"path"=>"/home/git/repositories", ...}
#
#
# The key is the shard name, and the values are the parameters for that shard.
# The key is the shard name, and the values are the parameters for that shard.
def
self
.
current_shards
def
self
.
all
Settings
.
repositories
.
storages
.
map
do
|
name
,
params
|
Settings
.
repositories
.
storages
.
map
do
|
name
,
params
|
config
=
params
.
symbolize_keys
.
merge
(
name:
name
)
config
=
params
.
symbolize_keys
.
merge
(
name:
name
)
config
.
slice!
(
allowed_params
)
StorageShard
.
new
(
config
)
StorageShard
.
new
(
config
)
end
end
end
end
def
self
.
allowed_params
return
%w(name path gitaly_address gitaly_token)
.
freeze
end
end
end
ee/app/controllers/admin/geo_nodes_controller.rb
View file @
3a8d1ddc
...
@@ -8,7 +8,7 @@ class Admin::GeoNodesController < Admin::ApplicationController
...
@@ -8,7 +8,7 @@ class Admin::GeoNodesController < Admin::ApplicationController
def
index
def
index
@nodes
=
GeoNode
.
all
.
order
(
:id
)
@nodes
=
GeoNode
.
all
.
order
(
:id
)
@node
=
GeoNode
.
new
@node
=
GeoNode
.
new
@current_storage_shards
=
StorageShardSerializer
.
new
.
represent
(
StorageShard
.
current_shards
)
@current_storage_shards
=
StorageShardSerializer
.
new
.
represent
(
StorageShard
.
all
)
unless
Gitlab
::
Geo
.
license_allows?
unless
Gitlab
::
Geo
.
license_allows?
flash_now
(
:alert
,
'You need a different license to enable Geo replication'
)
flash_now
(
:alert
,
'You need a different license to enable Geo replication'
)
...
...
ee/app/models/geo_node_status.rb
View file @
3a8d1ddc
...
@@ -75,7 +75,7 @@ class GeoNodeStatus < ActiveRecord::Base
...
@@ -75,7 +75,7 @@ class GeoNodeStatus < ActiveRecord::Base
self
.
lfs_objects_count
=
lfs_objects_finder
.
count_lfs_objects
self
.
lfs_objects_count
=
lfs_objects_finder
.
count_lfs_objects
self
.
attachments_count
=
attachments_finder
.
count_attachments
self
.
attachments_count
=
attachments_finder
.
count_attachments
self
.
last_successful_status_check_at
=
Time
.
now
self
.
last_successful_status_check_at
=
Time
.
now
self
.
storage_shards
=
StorageShard
.
current_shards
self
.
storage_shards
=
StorageShard
.
all
if
Gitlab
::
Geo
.
primary?
if
Gitlab
::
Geo
.
primary?
self
.
replication_slots_count
=
geo_node
.
replication_slots_count
self
.
replication_slots_count
=
geo_node
.
replication_slots_count
...
@@ -154,6 +154,12 @@ class GeoNodeStatus < ActiveRecord::Base
...
@@ -154,6 +154,12 @@ class GeoNodeStatus < ActiveRecord::Base
calc_percentage
(
replication_slots_count
,
replication_slots_used_count
)
calc_percentage
(
replication_slots_count
,
replication_slots_used_count
)
end
end
def
storage_shards_match?
return
unless
Gitlab
::
Geo
.
primary?
storage_shards
.
as_json
==
StorageShard
.
all
.
as_json
end
def
[]
(
key
)
def
[]
(
key
)
public_send
(
key
)
# rubocop:disable GitlabSecurity/PublicSend
public_send
(
key
)
# rubocop:disable GitlabSecurity/PublicSend
end
end
...
...
ee/app/serializers/geo_node_status_entity.rb
View file @
3a8d1ddc
...
@@ -69,6 +69,10 @@ class GeoNodeStatusEntity < Grape::Entity
...
@@ -69,6 +69,10 @@ class GeoNodeStatusEntity < Grape::Entity
status
.
storage_shards
.
present?
status
.
storage_shards
.
present?
end
end
expose
:storage_shards_match?
,
as: :storage_shards_match
,
if:
->
(
status
,
options
)
do
Gitlab
::
Geo
.
primary?
&&
status
.
storage_shards
.
present?
end
private
private
def
namespaces
def
namespaces
...
...
ee/app/views/admin/geo_nodes/index.html.haml
View file @
3a8d1ddc
...
@@ -29,10 +29,7 @@
...
@@ -29,10 +29,7 @@
-
if
node
.
current?
-
if
node
.
current?
.node-badge.current-node
Current node
.node-badge.current-node
Current node
-
if
node
.
primary?
-
if
node
.
primary?
-
if
node
.
current?
.node-badge.primary-node
Primary
.node-badge.primary-node
{
data:
{
storage_shards:
@current_storage_shards
.
to_json
}
}
Primary
-
else
.node-badge.primary-node
%p
%p
%span
.help-block
Primary node
%span
.help-block
Primary node
%p
%p
...
...
spec/ee/spec/models/geo_node_status_spec.rb
View file @
3a8d1ddc
...
@@ -398,7 +398,7 @@ describe GeoNodeStatus, :geo do
...
@@ -398,7 +398,7 @@ describe GeoNodeStatus, :geo do
describe
'#storage_shards'
do
describe
'#storage_shards'
do
it
"returns the current node's shard config"
do
it
"returns the current node's shard config"
do
expect
(
subject
[
:storage_shards
].
as_json
).
to
eq
(
StorageShard
.
current_shards
.
as_json
)
expect
(
subject
[
:storage_shards
].
as_json
).
to
eq
(
StorageShard
.
all
.
as_json
)
end
end
end
end
...
...
spec/factories/geo_node_statuses.rb
View file @
3a8d1ddc
...
@@ -2,7 +2,7 @@ FactoryBot.define do
...
@@ -2,7 +2,7 @@ FactoryBot.define do
factory
:geo_node_status
do
factory
:geo_node_status
do
sequence
(
:id
)
sequence
(
:id
)
geo_node
geo_node
storage_shards
{
[{
name:
'default'
,
path:
'/tmp/test'
}]
}
storage_shards
{
StorageShard
.
all
.
as_json
}
trait
:healthy
do
trait
:healthy
do
health
nil
health
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