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
a8e2094c
Commit
a8e2094c
authored
Nov 21, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove logic which glues with KubernetesService, from Platforms::Kubernetes
parent
3cf53cc6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
57 deletions
+3
-57
app/models/clusters/cluster.rb
app/models/clusters/cluster.rb
+1
-8
app/models/clusters/platforms/kubernetes.rb
app/models/clusters/platforms/kubernetes.rb
+2
-49
No files found.
app/models/clusters/cluster.rb
View file @
a8e2094c
...
...
@@ -17,8 +17,7 @@ module Clusters
# we force autosave to happen when we save `Cluster` model
has_one
:provider_gcp
,
class_name:
'Clusters::Providers::Gcp'
,
autosave:
true
# We have to ":destroy" it today to ensure that we clean also the Kubernetes Integration
has_one
:platform_kubernetes
,
class_name:
'Clusters::Platforms::Kubernetes'
,
autosave:
true
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_one
:platform_kubernetes
,
class_name:
'Clusters::Platforms::Kubernetes'
has_one
:application_helm
,
class_name:
'Clusters::Applications::Helm'
has_one
:application_ingress
,
class_name:
'Clusters::Applications::Ingress'
...
...
@@ -29,15 +28,9 @@ module Clusters
validates
:name
,
cluster_name:
true
validate
:restrict_modification
,
on: :update
# TODO: Move back this into Clusters::Platforms::Kubernetes in 10.3
# We need callback here because `enabled` belongs to Clusters::Cluster
# Callbacks in Clusters::Platforms::Kubernetes will not be called after update
after_save
:update_kubernetes_integration!
delegate
:status
,
to: :provider
,
allow_nil:
true
delegate
:status_reason
,
to: :provider
,
allow_nil:
true
delegate
:on_creation?
,
to: :provider
,
allow_nil:
true
delegate
:update_kubernetes_integration!
,
to: :platform
,
allow_nil:
true
delegate
:active?
,
to: :platform_kubernetes
,
prefix:
true
,
allow_nil:
true
delegate
:installed?
,
to: :application_helm
,
prefix:
true
,
allow_nil:
true
...
...
app/models/clusters/platforms/kubernetes.rb
View file @
a8e2094c
...
...
@@ -36,9 +36,6 @@ module Clusters
after_save
:clear_reactive_cache!
# TODO: Glue code till we migrate Kubernetes Integration into Platforms::Kubernetes
after_destroy
:destroy_kubernetes_integration!
alias_attribute
:ca_pem
,
:ca_cert
delegate
:project
,
to: :cluster
,
allow_nil:
true
...
...
@@ -85,33 +82,14 @@ module Clusters
# Caches resources in the namespace so other calls don't need to block on
# network access
def
calculate_reactive_cache
return
unless
active
?
&&
project
&&
!
project
.
pending_delete?
return
unless
enabled
?
&&
project
&&
!
project
.
pending_delete?
# We may want to cache extra things in the future
{
pods:
read_pods
}
end
def
kubeclient
@kubeclient
||=
kubernetes_service
.
kubeclient
if
manages_kubernetes_service?
end
def
update_kubernetes_integration!
raise
'Kubernetes service already configured'
unless
manages_kubernetes_service?
# This is neccesary, otheriwse enabled? returns true even though cluster updated with enabled: false
cluster
.
reload
ensure_kubernetes_service
&
.
update!
(
active:
enabled?
,
api_url:
api_url
,
namespace:
namespace
,
token:
token
,
ca_pem:
ca_cert
)
end
def
active?
manages_kubernetes_service?
@kubeclient
||=
build_kubeclient!
end
private
...
...
@@ -192,31 +170,6 @@ module Clusters
def
enforce_namespace_to_lower_case
self
.
namespace
=
self
.
namespace
&
.
downcase
end
def
enforce_namespace_to_lower_case
self
.
namespace
=
self
.
namespace
&
.
downcase
end
# TODO: glue code till we migrate Kubernetes Service into Platforms::Kubernetes class
def
manages_kubernetes_service?
return
true
unless
kubernetes_service
&
.
active?
kubernetes_service
.
api_url
==
api_url
end
def
destroy_kubernetes_integration!
return
unless
manages_kubernetes_service?
kubernetes_service
&
.
destroy!
end
def
kubernetes_service
@kubernetes_service
||=
project
&
.
kubernetes_service
end
def
ensure_kubernetes_service
@kubernetes_service
||=
kubernetes_service
||
project
&
.
build_kubernetes_service
end
end
end
end
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