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
b62ef094
Commit
b62ef094
authored
Feb 01, 2018
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Report the correct version and revision for Geo node status requests
parent
3280c094
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
46 additions
and
14 deletions
+46
-14
changelogs/unreleased-ee/4782-fix-geo-node-status-version-and-revision.yml
...ased-ee/4782-fix-geo-node-status-version-and-revision.yml
+5
-0
db/schema.rb
db/schema.rb
+2
-0
ee/app/models/geo_node_status.rb
ee/app/models/geo_node_status.rb
+15
-4
ee/db/migrate/20180201192230_store_version_and_revision_in_geo_node_status.rb
...01192230_store_version_and_revision_in_geo_node_status.rb
+8
-0
lib/api/entities.rb
lib/api/entities.rb
+0
-8
spec/ee/spec/models/geo_node_status_spec.rb
spec/ee/spec/models/geo_node_status_spec.rb
+9
-1
spec/factories/geo_node_statuses.rb
spec/factories/geo_node_statuses.rb
+2
-0
spec/requests/api/geo_nodes_spec.rb
spec/requests/api/geo_nodes_spec.rb
+5
-1
No files found.
changelogs/unreleased-ee/4782-fix-geo-node-status-version-and-revision.yml
0 → 100644
View file @
b62ef094
---
title
:
Report the correct version and revision for Geo node status requests
merge_request
:
4353
author
:
type
:
fixed
db/schema.rb
View file @
b62ef094
...
@@ -999,6 +999,8 @@ ActiveRecord::Schema.define(version: 20180202111106) do
...
@@ -999,6 +999,8 @@ ActiveRecord::Schema.define(version: 20180202111106) do
t
.
integer
"job_artifacts_count"
t
.
integer
"job_artifacts_count"
t
.
integer
"job_artifacts_synced_count"
t
.
integer
"job_artifacts_synced_count"
t
.
integer
"job_artifacts_failed_count"
t
.
integer
"job_artifacts_failed_count"
t
.
string
"version"
t
.
string
"revision"
end
end
add_index
"geo_node_statuses"
,
[
"geo_node_id"
],
name:
"index_geo_node_statuses_on_geo_node_id"
,
unique:
true
,
using: :btree
add_index
"geo_node_statuses"
,
[
"geo_node_id"
],
name:
"index_geo_node_statuses_on_geo_node_id"
,
unique:
true
,
using: :btree
...
...
ee/app/models/geo_node_status.rb
View file @
b62ef094
...
@@ -4,7 +4,7 @@ class GeoNodeStatus < ActiveRecord::Base
...
@@ -4,7 +4,7 @@ class GeoNodeStatus < ActiveRecord::Base
delegate
:selective_sync_type
,
to: :geo_node
delegate
:selective_sync_type
,
to: :geo_node
# Whether we were successful in reaching this node
# Whether we were successful in reaching this node
attr_accessor
:success
,
:version
,
:revision
attr_accessor
:success
attr_writer
:health_status
attr_writer
:health_status
attr_accessor
:storage_shards
attr_accessor
:storage_shards
...
@@ -58,10 +58,18 @@ class GeoNodeStatus < ActiveRecord::Base
...
@@ -58,10 +58,18 @@ class GeoNodeStatus < ActiveRecord::Base
GeoNodeStatus
.
new
(
HashWithIndifferentAccess
.
new
(
json_data
))
GeoNodeStatus
.
new
(
HashWithIndifferentAccess
.
new
(
json_data
))
end
end
EXCLUDED_PARAMS
=
%w[id created_at]
.
freeze
EXTRA_PARAMS
=
%w[
success
health
health_status
last_event_timestamp
cursor_last_event_timestamp
storage_shards
]
.
freeze
def
self
.
allowed_params
def
self
.
allowed_params
excluded_params
=
%w(id created_at updated_at)
.
freeze
self
.
column_names
-
EXCLUDED_PARAMS
+
EXTRA_PARAMS
extra_params
=
%w(success health health_status last_event_timestamp cursor_last_event_timestamp version revision storage_shards updated_at)
.
freeze
self
.
column_names
-
excluded_params
+
extra_params
end
end
def
load_data_from_current_node
def
load_data_from_current_node
...
@@ -83,6 +91,9 @@ class GeoNodeStatus < ActiveRecord::Base
...
@@ -83,6 +91,9 @@ class GeoNodeStatus < ActiveRecord::Base
self
.
last_successful_status_check_at
=
Time
.
now
self
.
last_successful_status_check_at
=
Time
.
now
self
.
storage_shards
=
StorageShard
.
all
self
.
storage_shards
=
StorageShard
.
all
self
.
version
=
Gitlab
::
VERSION
self
.
revision
=
Gitlab
::
REVISION
load_primary_data
load_primary_data
load_secondary_data
load_secondary_data
...
...
ee/db/migrate/20180201192230_store_version_and_revision_in_geo_node_status.rb
0 → 100644
View file @
b62ef094
class
StoreVersionAndRevisionInGeoNodeStatus
<
ActiveRecord
::
Migration
DOWNTIME
=
false
def
change
add_column
:geo_node_statuses
,
:version
,
:string
add_column
:geo_node_statuses
,
:revision
,
:string
end
end
lib/api/entities.rb
View file @
b62ef094
...
@@ -1267,14 +1267,6 @@ module API
...
@@ -1267,14 +1267,6 @@ module API
def
missing_oauth_application
def
missing_oauth_application
object
.
geo_node
.
missing_oauth_application?
object
.
geo_node
.
missing_oauth_application?
end
end
def
version
Gitlab
::
VERSION
end
def
revision
Gitlab
::
REVISION
end
end
end
class
PersonalAccessToken
<
Grape
::
Entity
class
PersonalAccessToken
<
Grape
::
Entity
...
...
spec/ee/spec/models/geo_node_status_spec.rb
View file @
b62ef094
...
@@ -12,7 +12,7 @@ describe GeoNodeStatus, :geo do
...
@@ -12,7 +12,7 @@ describe GeoNodeStatus, :geo do
let!
(
:project_3
)
{
create
(
:project
)
}
let!
(
:project_3
)
{
create
(
:project
)
}
let!
(
:project_4
)
{
create
(
:project
)
}
let!
(
:project_4
)
{
create
(
:project
)
}
subject
{
described_class
.
current_node_status
}
subject
(
:status
)
{
described_class
.
current_node_status
}
before
do
before
do
stub_current_geo_node
(
secondary
)
stub_current_geo_node
(
secondary
)
...
@@ -425,6 +425,14 @@ describe GeoNodeStatus, :geo do
...
@@ -425,6 +425,14 @@ describe GeoNodeStatus, :geo do
end
end
end
end
describe
'#version'
do
it
{
expect
(
status
.
version
).
to
eq
(
Gitlab
::
VERSION
)
}
end
describe
'#revision'
do
it
{
expect
(
status
.
revision
).
to
eq
(
Gitlab
::
REVISION
)
}
end
describe
'#[]'
do
describe
'#[]'
do
it
'returns values for each attribute'
do
it
'returns values for each attribute'
do
expect
(
subject
[
:repositories_count
]).
to
eq
(
4
)
expect
(
subject
[
:repositories_count
]).
to
eq
(
4
)
...
...
spec/factories/geo_node_statuses.rb
View file @
b62ef094
...
@@ -25,6 +25,8 @@ FactoryBot.define do
...
@@ -25,6 +25,8 @@ FactoryBot.define do
cursor_last_event_id
1
cursor_last_event_id
1
cursor_last_event_timestamp
{
Time
.
now
.
to_i
}
cursor_last_event_timestamp
{
Time
.
now
.
to_i
}
last_successful_status_check_timestamp
{
Time
.
now
.
beginning_of_day
}
last_successful_status_check_timestamp
{
Time
.
now
.
beginning_of_day
}
version
{
Gitlab
::
VERSION
}
revision
{
Gitlab
::
REVISION
}
end
end
trait
:unhealthy
do
trait
:unhealthy
do
...
...
spec/requests/api/geo_nodes_spec.rb
View file @
b62ef094
...
@@ -69,6 +69,7 @@ describe API::GeoNodes, :geo, api: true do
...
@@ -69,6 +69,7 @@ describe API::GeoNodes, :geo, api: true do
describe
'GET /geo_nodes/:id/status'
do
describe
'GET /geo_nodes/:id/status'
do
it
'retrieves the Geo nodes status if admin is logged in'
do
it
'retrieves the Geo nodes status if admin is logged in'
do
stub_current_geo_node
(
primary
)
stub_current_geo_node
(
primary
)
secondary_status
.
update!
(
version:
'secondary-version'
,
revision:
'secondary-revision'
)
expect
(
GeoNodeStatus
).
not_to
receive
(
:current_node_status
)
expect
(
GeoNodeStatus
).
not_to
receive
(
:current_node_status
)
...
@@ -77,14 +78,17 @@ describe API::GeoNodes, :geo, api: true do
...
@@ -77,14 +78,17 @@ describe API::GeoNodes, :geo, api: true do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/geo_node_status'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/geo_node_status'
,
dir:
'ee'
)
expect
(
json_response
[
'version'
]).
to
eq
(
'secondary-version'
)
expect
(
json_response
[
'revision'
]).
to
eq
(
'secondary-revision'
)
links
=
json_response
[
'_links'
]
links
=
json_response
[
'_links'
]
expect
(
links
[
'self'
]).
to
end_with
(
"/api/v4/geo_nodes/
#{
secondary
.
id
}
/status"
)
expect
(
links
[
'self'
]).
to
end_with
(
"/api/v4/geo_nodes/
#{
secondary
.
id
}
/status"
)
expect
(
links
[
'node'
]).
to
end_with
(
"/api/v4/geo_nodes/
#{
secondary
.
id
}
"
)
expect
(
links
[
'node'
]).
to
end_with
(
"/api/v4/geo_nodes/
#{
secondary
.
id
}
"
)
end
end
it
'fetches the current node status'
do
it
'fetches the current node status'
do
stub_current_geo_node
(
secondary
)
stub_current_geo_node
(
secondary
)
expect
(
GeoNode
).
to
receive
(
:find
).
and_return
(
secondary
)
expect
(
GeoNode
).
to
receive
(
:find
).
and_return
(
secondary
)
expect
(
GeoNodeStatus
).
to
receive
(
:current_node_status
).
and_call_original
expect
(
GeoNodeStatus
).
to
receive
(
:current_node_status
).
and_call_original
...
...
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