diff options
-rw-r--r-- | app/models/clusters/platforms/kubernetes.rb | 3 | ||||
-rw-r--r-- | db/migrate/20171013094327_create_new_clusters_architectures.rb | 2 | ||||
-rw-r--r-- | db/schema.rb | 2 | ||||
-rw-r--r-- | spec/javascripts/fixtures/clusters.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/import_export/all_models.yml | 12 | ||||
-rw-r--r-- | spec/models/clusters/platforms/kubernetes_spec.rb | 3 |
6 files changed, 16 insertions, 8 deletions
diff --git a/app/models/clusters/platforms/kubernetes.rb b/app/models/clusters/platforms/kubernetes.rb index a33534da8bb..b11701797c2 100644 --- a/app/models/clusters/platforms/kubernetes.rb +++ b/app/models/clusters/platforms/kubernetes.rb @@ -58,6 +58,9 @@ module Clusters 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, diff --git a/db/migrate/20171013094327_create_new_clusters_architectures.rb b/db/migrate/20171013094327_create_new_clusters_architectures.rb index b196aa1949c..dabb3e25e48 100644 --- a/db/migrate/20171013094327_create_new_clusters_architectures.rb +++ b/db/migrate/20171013094327_create_new_clusters_architectures.rb @@ -3,7 +3,7 @@ class CreateNewClustersArchitectures < ActiveRecord::Migration def change create_table :clusters do |t| - t.references :user, null: false, index: true, foreign_key: { on_delete: :nullify } + t.references :user, index: true, foreign_key: { on_delete: :nullify } t.integer :provider_type t.integer :platform_type diff --git a/db/schema.rb b/db/schema.rb index e87afee74ad..f88abaab86e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -507,7 +507,7 @@ ActiveRecord::Schema.define(version: 20171026082505) do add_index "cluster_providers_gcp", ["cluster_id"], name: "index_cluster_providers_gcp_on_cluster_id", unique: true, using: :btree create_table "clusters", force: :cascade do |t| - t.integer "user_id", null: false + t.integer "user_id" t.integer "provider_type" t.integer "platform_type" t.datetime_with_timezone "created_at", null: false diff --git a/spec/javascripts/fixtures/clusters.rb b/spec/javascripts/fixtures/clusters.rb index 5774f36f026..8e74c4f859c 100644 --- a/spec/javascripts/fixtures/clusters.rb +++ b/spec/javascripts/fixtures/clusters.rb @@ -6,7 +6,7 @@ describe Projects::ClustersController, '(JavaScript fixtures)', type: :controlle let(:admin) { create(:admin) } let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:project) { create(:project, :repository, namespace: namespace) } - let(:cluster) { project.create_cluster!(gcp_cluster_name: "gke-test-creation-1", gcp_project_id: 'gitlab-internal-153318', gcp_cluster_zone: 'us-central1-a', gcp_cluster_size: '1', project_namespace: 'aaa', gcp_machine_type: 'n1-standard-1')} + let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) } render_views diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index 6c6b9154a0a..4a59e0207f8 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -147,10 +147,16 @@ deploy_keys: - user - deploy_keys_projects - projects -cluster: -- project +clusters: +- projects - user -- service +cluster_projects: +- projects +- clusters +provider_gcp: +- cluster +platform_kubernetes: +- cluster services: - project - service_hook diff --git a/spec/models/clusters/platforms/kubernetes_spec.rb b/spec/models/clusters/platforms/kubernetes_spec.rb index 71d06a4ae66..e6ebe079ceb 100644 --- a/spec/models/clusters/platforms/kubernetes_spec.rb +++ b/spec/models/clusters/platforms/kubernetes_spec.rb @@ -117,7 +117,6 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching let(:kubernetes_service) { project.kubernetes_service } it 'updates KubernetesService' do - # TODO: This doesn't work as intended because `enabled?` in Clusters::Platforms::Kubernetes is still true without `reload` cluster.update(enabled: enabled) expect(kubernetes_service.active).to eq(enabled) @@ -135,7 +134,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching end it 'raises an error' do - expect{ cluster.save! }.to raise_error('Kubernetes service already configured') + expect { cluster.save! }.to raise_error('Kubernetes service already configured') end end end |