Skip to content

Commit

Permalink
Remove unused cluster configuration logic
Browse files Browse the repository at this point in the history
All cluster resources are now created on demand when
a deployment job starts.
  • Loading branch information
Tiger committed Jul 31, 2019
1 parent dcad4c1 commit 0e6408a
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 85 deletions.
16 changes: 0 additions & 16 deletions app/models/clusters/cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,6 @@ class Cluster < ApplicationRecord

scope :default_environment, -> { where(environment_scope: DEFAULT_ENVIRONMENT) }

scope :missing_kubernetes_namespace, -> (kubernetes_namespaces) do
subquery = kubernetes_namespaces.select('1').where('clusters_kubernetes_namespaces.cluster_id = clusters.id')

where('NOT EXISTS (?)', subquery)
end

scope :with_knative_installed, -> { joins(:application_knative).merge(Clusters::Applications::Knative.available) }

scope :preload_knative, -> {
Expand Down Expand Up @@ -161,16 +155,6 @@ def platform
return platform_kubernetes if kubernetes?
end

def all_projects
if project_type?
projects
elsif group_type?
first_group.all_projects
else
Project.none
end
end

def first_project
strong_memoize(:first_project) do
projects.first
Expand Down
6 changes: 0 additions & 6 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -415,12 +415,6 @@ class Project < ApplicationRecord
.where(project_ci_cd_settings: { group_runners_enabled: true })
end

scope :missing_kubernetes_namespace, -> (kubernetes_namespaces) do
subquery = kubernetes_namespaces.select('1').where('clusters_kubernetes_namespaces.project_id = projects.id')

where('NOT EXISTS (?)', subquery)
end

enum auto_cancel_pending_pipelines: { disabled: 0, enabled: 1 }

chronic_duration_attr :build_timeout_human_readable, :build_timeout,
Expand Down
45 changes: 0 additions & 45 deletions spec/models/clusters/cluster_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,6 @@
end
end

describe '.missing_kubernetes_namespace' do
let!(:cluster) { create(:cluster, :provided_by_gcp, :project) }
let(:project) { cluster.project }
let(:kubernetes_namespaces) { project.kubernetes_namespaces }

subject do
described_class.joins(:projects).where(projects: { id: project.id }).missing_kubernetes_namespace(kubernetes_namespaces)
end

it { is_expected.to contain_exactly(cluster) }

context 'kubernetes namespace exists' do
before do
create(:cluster_kubernetes_namespace, project: project, cluster: cluster)
end

it { is_expected.to be_empty }
end
end

describe 'validations' do
subject { cluster.valid? }

Expand Down Expand Up @@ -423,31 +403,6 @@
end
end

describe '#all_projects' do
let(:project) { create(:project) }
let(:cluster) { create(:cluster, projects: [project]) }

subject { cluster.all_projects }

context 'project cluster' do
it 'returns project' do
is_expected.to eq([project])
end
end

context 'group cluster' do
let(:cluster) { create(:cluster, :group) }
let(:group) { cluster.group }
let(:project) { create(:project, group: group) }
let(:subgroup) { create(:group, parent: group) }
let(:subproject) { create(:project, group: subgroup) }

it 'returns all projects for group' do
is_expected.to contain_exactly(project, subproject)
end
end
end

describe '#first_project' do
subject { cluster.first_project }

Expand Down
18 changes: 0 additions & 18 deletions spec/models/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,24 +173,6 @@
it { is_expected.to include_module(Sortable) }
end

describe '.missing_kubernetes_namespace' do
let!(:project) { create(:project) }
let!(:cluster) { create(:cluster, :provided_by_user, :group) }
let(:kubernetes_namespaces) { project.kubernetes_namespaces }

subject { described_class.missing_kubernetes_namespace(kubernetes_namespaces) }

it { is_expected.to contain_exactly(project) }

context 'kubernetes namespace exists' do
before do
create(:cluster_kubernetes_namespace, project: project, cluster: cluster)
end

it { is_expected.to be_empty }
end
end

describe 'validation' do
let!(:project) { create(:project) }

Expand Down

0 comments on commit 0e6408a

Please sign in to comment.