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
b6883c11
Commit
b6883c11
authored
Jun 27, 2019
by
James Fargher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename KubernetesService to become a proper EE module
Clusters::Platforms::Kubernetes is now the only include
parent
b4993f95
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
44 deletions
+48
-44
app/models/clusters/platforms/kubernetes.rb
app/models/clusters/platforms/kubernetes.rb
+1
-1
ee/app/models/concerns/ee/kubernetes_service.rb
ee/app/models/concerns/ee/kubernetes_service.rb
+0
-41
ee/app/models/ee/clusters/platforms/kubernetes.rb
ee/app/models/ee/clusters/platforms/kubernetes.rb
+45
-0
ee/spec/controllers/projects/environments_controller_spec.rb
ee/spec/controllers/projects/environments_controller_spec.rb
+1
-1
ee/spec/features/projects/environments_pod_logs_spec.rb
ee/spec/features/projects/environments_pod_logs_spec.rb
+1
-1
No files found.
app/models/clusters/platforms/kubernetes.rb
View file @
b6883c11
...
...
@@ -192,4 +192,4 @@ module Clusters
end
end
Clusters
::
Platforms
::
Kubernetes
.
prepend
(
EE
::
KubernetesService
)
Clusters
::
Platforms
::
Kubernetes
.
prepend
(
EE
::
Clusters
::
Platforms
::
Kubernetes
)
ee/app/models/concerns/ee/kubernetes_service.rb
deleted
100644 → 0
View file @
b4993f95
# frozen_string_literal: true
module
EE
module
KubernetesService
extend
ActiveSupport
::
Concern
LOGS_LIMIT
=
500
.
freeze
def
calculate_reactive_cache_for
(
environment
)
result
=
super
result
[
:deployments
]
=
read_deployments
(
environment
.
deployment_namespace
)
if
result
result
end
def
rollout_status
(
environment
,
data
)
project
=
environment
.
project
deployments
=
filter_by_project_environment
(
data
[
:deployments
],
project
.
full_path_slug
,
environment
.
slug
)
pods
=
filter_by_project_environment
(
data
[
:pods
],
project
.
full_path_slug
,
environment
.
slug
)
if
data
[
:pods
]
&
.
any?
legacy_deployments
=
filter_by_legacy_label
(
data
[
:deployments
],
project
.
full_path_slug
,
environment
.
slug
)
::
Gitlab
::
Kubernetes
::
RolloutStatus
.
from_deployments
(
*
deployments
,
pods:
pods
,
legacy_deployments:
legacy_deployments
)
end
def
read_pod_logs
(
pod_name
,
namespace
,
container:
nil
)
kubeclient
.
get_pod_log
(
pod_name
,
namespace
,
container:
container
,
tail_lines:
LOGS_LIMIT
).
as_json
rescue
Kubeclient
::
ResourceNotFoundError
[]
end
private
def
read_deployments
(
namespace
)
kubeclient
.
get_deployments
(
namespace:
namespace
).
as_json
rescue
Kubeclient
::
ResourceNotFoundError
[]
end
end
end
ee/app/models/ee/clusters/platforms/kubernetes.rb
0 → 100644
View file @
b6883c11
# frozen_string_literal: true
module
EE
module
Clusters
module
Platforms
module
Kubernetes
extend
ActiveSupport
::
Concern
LOGS_LIMIT
=
500
.
freeze
def
calculate_reactive_cache_for
(
environment
)
result
=
super
result
[
:deployments
]
=
read_deployments
(
environment
.
deployment_namespace
)
if
result
result
end
def
rollout_status
(
environment
,
data
)
project
=
environment
.
project
deployments
=
filter_by_project_environment
(
data
[
:deployments
],
project
.
full_path_slug
,
environment
.
slug
)
pods
=
filter_by_project_environment
(
data
[
:pods
],
project
.
full_path_slug
,
environment
.
slug
)
if
data
[
:pods
]
&
.
any?
legacy_deployments
=
filter_by_legacy_label
(
data
[
:deployments
],
project
.
full_path_slug
,
environment
.
slug
)
::
Gitlab
::
Kubernetes
::
RolloutStatus
.
from_deployments
(
*
deployments
,
pods:
pods
,
legacy_deployments:
legacy_deployments
)
end
def
read_pod_logs
(
pod_name
,
namespace
,
container:
nil
)
kubeclient
.
get_pod_log
(
pod_name
,
namespace
,
container:
container
,
tail_lines:
LOGS_LIMIT
).
as_json
rescue
Kubeclient
::
ResourceNotFoundError
[]
end
private
def
read_deployments
(
namespace
)
kubeclient
.
get_deployments
(
namespace:
namespace
).
as_json
rescue
Kubeclient
::
ResourceNotFoundError
[]
end
end
end
end
end
ee/spec/controllers/projects/environments_controller_spec.rb
View file @
b6883c11
...
...
@@ -84,7 +84,7 @@ describe Projects::EnvironmentsController do
environment_scope:
'*'
,
projects:
[
project
])
create
(
:deployment
,
:success
,
environment:
environment
)
allow_any_instance_of
(
EE
::
KubernetesService
).
to
receive
(
:read_pod_logs
)
allow_any_instance_of
(
EE
::
Clusters
::
Platforms
::
Kubernetes
).
to
receive
(
:read_pod_logs
)
.
with
(
pod_name
,
environment
.
deployment_namespace
).
and_return
(
kube_logs_body
)
allow_any_instance_of
(
Gitlab
::
Kubernetes
::
RolloutStatus
).
to
receive
(
:instances
)
.
and_return
([{
pod_name:
pod_name
}])
...
...
ee/spec/features/projects/environments_pod_logs_spec.rb
View file @
b6883c11
...
...
@@ -16,7 +16,7 @@ describe 'Environment > Pod Logs', :js do
create
(
:cluster
,
:provided_by_gcp
,
environment_scope:
'*'
,
projects:
[
project
])
create
(
:deployment
,
:success
,
environment:
environment
)
allow_any_instance_of
(
EE
::
KubernetesService
).
to
receive
(
:read_pod_logs
)
allow_any_instance_of
(
EE
::
Clusters
::
Platforms
::
Kubernetes
).
to
receive
(
:read_pod_logs
)
.
with
(
pod_name
,
environment
.
deployment_namespace
).
and_return
(
kube_logs_body
)
allow_any_instance_of
(
EE
::
Environment
).
to
receive
(
:pod_names
).
and_return
(
pod_names
)
...
...
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