Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-23 03:06:29 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-23 03:06:29 +0300
commit98dbb0a488d7b0093f352938210d9578b0f7a8a6 (patch)
tree25654204f8de2672556a696199fa209b8f8ff1b3 /app/models/clusters
parent9ce26d3dfdf4194f32c470cd3102b4376a53ef2f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/clusters')
-rw-r--r--app/models/clusters/applications/helm.rb2
-rw-r--r--app/models/clusters/applications/jupyter.rb2
-rw-r--r--app/models/clusters/applications/knative.rb6
-rw-r--r--app/models/clusters/cluster.rb4
-rw-r--r--app/models/clusters/concerns/application_core.rb2
-rw-r--r--app/models/clusters/concerns/application_status.rb19
-rw-r--r--app/models/clusters/providers/gcp.rb7
7 files changed, 37 insertions, 5 deletions
diff --git a/app/models/clusters/applications/helm.rb b/app/models/clusters/applications/helm.rb
index 455cf200fbc..261f6ce8987 100644
--- a/app/models/clusters/applications/helm.rb
+++ b/app/models/clusters/applications/helm.rb
@@ -27,7 +27,7 @@ module Clusters
def set_initial_status
return unless not_installable?
- self.status = 'installable' if cluster&.platform_kubernetes_active?
+ self.status = status_states[:installable] if cluster&.platform_kubernetes_active?
end
# It can only be uninstalled if there are no other applications installed
diff --git a/app/models/clusters/applications/jupyter.rb b/app/models/clusters/applications/jupyter.rb
index ec65482a846..ca93bc15be0 100644
--- a/app/models/clusters/applications/jupyter.rb
+++ b/app/models/clusters/applications/jupyter.rb
@@ -23,7 +23,7 @@ module Clusters
return unless cluster&.application_ingress_available?
ingress = cluster.application_ingress
- self.status = 'installable' if ingress.external_ip_or_hostname?
+ self.status = status_states[:installable] if ingress.external_ip_or_hostname?
end
def chart
diff --git a/app/models/clusters/applications/knative.rb b/app/models/clusters/applications/knative.rb
index a9b9374622d..f2a3695d2eb 100644
--- a/app/models/clusters/applications/knative.rb
+++ b/app/models/clusters/applications/knative.rb
@@ -21,7 +21,7 @@ module Clusters
return unless not_installable?
return unless verify_cluster?
- self.status = 'installable'
+ self.status = status_states[:installable]
end
state_machine :status do
@@ -47,6 +47,10 @@ module Clusters
{ "domain" => hostname }.to_yaml
end
+ def allowed_to_uninstall?
+ !pre_installed?
+ end
+
def install_command
Gitlab::Kubernetes::Helm::InstallCommand.new(
name: name,
diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb
index 231cadfae05..2df30e8ac36 100644
--- a/app/models/clusters/cluster.rb
+++ b/app/models/clusters/cluster.rb
@@ -194,6 +194,10 @@ module Clusters
end
end
+ def knative_pre_installed?
+ provider&.knative_pre_installed?
+ end
+
private
def instance_domain
diff --git a/app/models/clusters/concerns/application_core.rb b/app/models/clusters/concerns/application_core.rb
index d1b57a21a7d..e748c0a855d 100644
--- a/app/models/clusters/concerns/application_core.rb
+++ b/app/models/clusters/concerns/application_core.rb
@@ -15,7 +15,7 @@ module Clusters
def set_initial_status
return unless not_installable?
- self.status = 'installable' if cluster&.application_helm_available?
+ self.status = status_states[:installable] if cluster&.application_helm_available?
end
def can_uninstall?
diff --git a/app/models/clusters/concerns/application_status.rb b/app/models/clusters/concerns/application_status.rb
index 342d766f723..b63a596dfee 100644
--- a/app/models/clusters/concerns/application_status.rb
+++ b/app/models/clusters/concerns/application_status.rb
@@ -28,6 +28,13 @@ module Clusters
state :uninstalling, value: 7
state :uninstall_errored, value: 8
+ # Used for applications that are pre-installed by the cluster,
+ # e.g. Knative in GCP Cloud Run enabled clusters
+ # Because we cannot upgrade or uninstall Knative in these clusters,
+ # we define only one simple state transition to enter the `pre_installed` state,
+ # and no exit transitions.
+ state :pre_installed, value: 9
+
event :make_scheduled do
transition [:installable, :errored, :installed, :updated, :update_errored, :uninstall_errored] => :scheduled
end
@@ -41,6 +48,10 @@ module Clusters
transition [:updating] => :updated
end
+ event :make_pre_installed do
+ transition any => :pre_installed
+ end
+
event :make_errored do
transition any - [:updating, :uninstalling] => :errored
transition [:updating] => :update_errored
@@ -90,12 +101,18 @@ module Clusters
end
end
+ def status_states
+ self.class.state_machines[:status].states.each_with_object({}) do |state, states|
+ states[state.name] = state.value
+ end
+ end
+
def updateable?
installed? || updated? || update_errored?
end
def available?
- installed? || updated?
+ pre_installed? || installed? || updated?
end
def update_in_progress?
diff --git a/app/models/clusters/providers/gcp.rb b/app/models/clusters/providers/gcp.rb
index 390748bf252..043765f79ac 100644
--- a/app/models/clusters/providers/gcp.rb
+++ b/app/models/clusters/providers/gcp.rb
@@ -10,6 +10,9 @@ module Clusters
default_value_for :zone, 'us-central1-a'
default_value_for :num_nodes, 3
default_value_for :machine_type, 'n1-standard-2'
+ default_value_for :cloud_run, false
+
+ scope :cloud_run, -> { where(cloud_run: true) }
attr_encrypted :access_token,
mode: :per_attribute_iv,
@@ -77,6 +80,10 @@ module Clusters
@api_client ||= GoogleApi::CloudPlatform::Client.new(access_token, nil)
end
+
+ def knative_pre_installed?
+ cloud_run?
+ end
end
end
end