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
273c1336
Commit
273c1336
authored
Nov 01, 2018
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix cluster metrics override for EE
parent
dd8a715b
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
48 additions
and
48 deletions
+48
-48
app/controllers/projects/clusters_controller.rb
app/controllers/projects/clusters_controller.rb
+2
-0
config/routes.rb
config/routes.rb
+1
-1
ee/app/assets/javascripts/pages/projects/clusters/show/cluster_health.js
...avascripts/pages/projects/clusters/show/cluster_health.js
+0
-0
ee/app/assets/javascripts/pages/projects/clusters/show/index.js
.../assets/javascripts/pages/projects/clusters/show/index.js
+1
-1
ee/app/controllers/clusters/cluster_metrics_controller.rb
ee/app/controllers/clusters/cluster_metrics_controller.rb
+0
-35
ee/app/controllers/ee/projects/clusters_controller.rb
ee/app/controllers/ee/projects/clusters_controller.rb
+31
-0
ee/app/views/projects/clusters/_health.html.haml
ee/app/views/projects/clusters/_health.html.haml
+1
-1
ee/spec/controllers/projects/clusters_controller_spec.rb
ee/spec/controllers/projects/clusters_controller_spec.rb
+6
-7
ee/spec/features/projects/clusters/gcp_spec.rb
ee/spec/features/projects/clusters/gcp_spec.rb
+1
-1
ee/spec/features/projects/clusters_spec.rb
ee/spec/features/projects/clusters_spec.rb
+5
-2
No files found.
app/controllers/projects/clusters_controller.rb
View file @
273c1336
# frozen_string_literal: true
class
Projects::ClustersController
<
Clusters
::
ClustersController
prepend
EE
::
Projects
::
ClustersController
include
ProjectUnauthorized
prepend_before_action
:project
...
...
config/routes.rb
View file @
273c1336
...
...
@@ -100,7 +100,7 @@ Rails.application.routes.draw do
member
do
# EE specific
get
:metrics
,
to:
'clusters/cluster_metrics#show'
,
as: :metrics
get
:metrics
,
format: :json
scope
:applications
do
post
'/:application'
,
to:
'clusters/applications#create'
,
as: :install_applications
...
...
ee/app/assets/javascripts/pages/clusters/show/cluster_health.js
→
ee/app/assets/javascripts/pages/
projects/
clusters/show/cluster_health.js
View file @
273c1336
File moved
ee/app/assets/javascripts/pages/clusters/show/index.js
→
ee/app/assets/javascripts/pages/
projects/
clusters/show/index.js
View file @
273c1336
import
'
~/pages/clusters/show
'
;
import
'
~/pages/
projects/
clusters/show
'
;
import
initClusterHealth
from
'
./cluster_health
'
;
document
.
addEventListener
(
'
DOMContentLoaded
'
,
initClusterHealth
);
ee/app/controllers/clusters/cluster_metrics_controller.rb
deleted
100644 → 0
View file @
dd8a715b
# frozen_string_literal: true
class
Clusters::ClusterMetricsController
<
Clusters
::
BaseController
before_action
:cluster
,
only: :metrics
before_action
:authorize_read_cluster!
def
show
return
render_404
unless
prometheus_adapter
&
.
can_query?
respond_to
do
|
format
|
format
.
json
do
metrics
=
prometheus_adapter
.
query
(
:cluster
)
||
{}
if
metrics
.
any?
render
json:
metrics
else
head
:no_content
end
end
end
end
private
def
cluster
@cluster
||=
clusterable
.
clusters
.
find
(
params
[
:id
])
.
present
(
current_user:
current_user
)
end
def
prometheus_adapter
return
unless
cluster
&
.
application_prometheus_available?
cluster
.
application_prometheus
end
end
ee/app/controllers/ee/projects/clusters_controller.rb
0 → 100644
View file @
273c1336
module
EE
module
Projects
module
ClustersController
extend
ActiveSupport
::
Concern
def
metrics
return
render_404
unless
prometheus_adapter
&
.
can_query?
respond_to
do
|
format
|
format
.
json
do
metrics
=
prometheus_adapter
.
query
(
:cluster
)
||
{}
if
metrics
.
any?
render
json:
metrics
else
head
:no_content
end
end
end
end
private
def
prometheus_adapter
return
unless
cluster
&
.
application_prometheus_available?
cluster
.
application_prometheus
end
end
end
end
ee/app/views/clusters/_health.html.haml
→
ee/app/views/
projects/
clusters/_health.html.haml
View file @
273c1336
...
...
@@ -10,7 +10,7 @@
"empty-loading-svg-path"
:
image_path
(
'illustrations/monitoring/loading.svg'
),
"empty-no-data-svg-path"
:
image_path
(
'illustrations/monitoring/no_data.svg'
),
"empty-unable-to-connect-svg-path"
:
image_path
(
'illustrations/monitoring/unable_to_connect.svg'
),
"metrics-endpoint"
:
metrics_
cluster_path
(
clusterable_params
.
merge
(
format: :json
)
),
"metrics-endpoint"
:
metrics_
namespace_project_cluster_path
(
format: :json
),
"project-path"
:
project_path
(
@project
),
"tags-path"
:
project_tags_path
(
@project
)
}
}
...
...
ee/spec/controllers/
clusters/cluster_metric
s_controller_spec.rb
→
ee/spec/controllers/
projects/cluster
s_controller_spec.rb
View file @
273c1336
require
'spec_helper'
describe
Clusters
::
ClusterMetric
sController
do
describe
Projects
::
Cluster
sController
do
include
AccessMatchersForController
set
(
:project
)
{
create
(
:project
)
}
describe
'GET
show
'
do
describe
'GET
metrics
'
do
let
(
:cluster
)
{
create
(
:cluster
,
:provided_by_gcp
,
projects:
[
project
])
}
describe
'functionality'
do
...
...
@@ -69,11 +69,10 @@ describe Clusters::ClusterMetricsController do
end
def
go
get
:show
,
format: :json
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
cluster
get
:metrics
,
format: :json
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
cluster
end
describe
'security'
do
...
...
ee/spec/features/projects/clusters/gcp_spec.rb
View file @
273c1336
...
...
@@ -9,7 +9,7 @@ describe 'Gcp Cluster', :js do
before
do
project
.
add_maintainer
(
user
)
gitlab_sign_in
(
user
)
allow
(
ClustersController
).
to
receive
(
:STATUS_POLLING_INTERVAL
)
{
100
}
allow
(
Projects
::
ClustersController
).
to
receive
(
:STATUS_POLLING_INTERVAL
)
{
100
}
end
context
'when a user has a licence to use multiple clusers'
do
...
...
ee/spec/features/projects/clusters_spec.rb
View file @
273c1336
...
...
@@ -75,11 +75,14 @@ describe 'EE Clusters', :js do
context
'when user adds an Google Kubernetes Engine cluster'
do
before
do
allow_any_instance_of
(
ClustersController
)
allow_any_instance_of
(
Projects
::
ClustersController
)
.
to
receive
(
:token_in_session
).
and_return
(
'token'
)
allow_any_instance_of
(
ClustersController
)
allow_any_instance_of
(
Projects
::
ClustersController
)
.
to
receive
(
:expires_at_in_session
).
and_return
(
1
.
hour
.
since
.
to_i
.
to_s
)
allow_any_instance_of
(
Projects
::
ClustersController
).
to
receive
(
:authorize_google_project_billing
)
allow_any_instance_of
(
Projects
::
ClustersController
).
to
receive
(
:google_project_billing_status
).
and_return
(
true
)
allow_any_instance_of
(
GoogleApi
::
CloudPlatform
::
Client
)
.
to
receive
(
:projects_zones_clusters_create
)
do
OpenStruct
.
new
(
...
...
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