Commit 955c4b53 authored by Thong Kuah's avatar Thong Kuah

Merge branch '22392-add-eks-clusters-to-usage-data' into 'master'

Add EKS cluster counts to usage data

See merge request gitlab-org/gitlab!17059
parents 80a1b7ab 55f4119e
---
title: Add EKS cluster count to usage data
merge_request: 17059
author:
type: other
...@@ -192,6 +192,7 @@ module EE ...@@ -192,6 +192,7 @@ module EE
clusters_disabled: ::Clusters::Cluster.disabled.distinct_count_by(:user_id), clusters_disabled: ::Clusters::Cluster.disabled.distinct_count_by(:user_id),
clusters_enabled: ::Clusters::Cluster.enabled.distinct_count_by(:user_id), clusters_enabled: ::Clusters::Cluster.enabled.distinct_count_by(:user_id),
clusters_platforms_gke: ::Clusters::Cluster.gcp_installed.enabled.distinct_count_by(:user_id), clusters_platforms_gke: ::Clusters::Cluster.gcp_installed.enabled.distinct_count_by(:user_id),
clusters_platforms_eks: ::Clusters::Cluster.aws_installed.enabled.distinct_count_by(:user_id),
clusters_platforms_user: ::Clusters::Cluster.user_provided.enabled.distinct_count_by(:user_id), clusters_platforms_user: ::Clusters::Cluster.user_provided.enabled.distinct_count_by(:user_id),
group_clusters_disabled: ::Clusters::Cluster.disabled.group_type.distinct_count_by(:user_id), group_clusters_disabled: ::Clusters::Cluster.disabled.group_type.distinct_count_by(:user_id),
group_clusters_enabled: ::Clusters::Cluster.enabled.group_type.distinct_count_by(:user_id), group_clusters_enabled: ::Clusters::Cluster.enabled.group_type.distinct_count_by(:user_id),
......
...@@ -49,8 +49,9 @@ describe Gitlab::UsageData do ...@@ -49,8 +49,9 @@ describe Gitlab::UsageData do
create(:clusters_applications_ingress, :installed, cluster: cluster) create(:clusters_applications_ingress, :installed, cluster: cluster)
create(:clusters_applications_knative, :installed, cluster: cluster) create(:clusters_applications_knative, :installed, cluster: cluster)
create(:cluster, :disabled, user: user) create(:cluster, :disabled, user: user)
create(:cluster, :provided_by_gcp, user: user) create(:cluster_provider_gcp, :created)
create(:cluster, :provided_by_user, user: user) create(:cluster_provider_aws, :created)
create(:cluster_platform_kubernetes)
create(:cluster, :group, :disabled, user: user) create(:cluster, :group, :disabled, user: user)
create(:cluster, :group, user: user) create(:cluster, :group, user: user)
create(:slack_service, project: project) create(:slack_service, project: project)
...@@ -65,6 +66,7 @@ describe Gitlab::UsageData do ...@@ -65,6 +66,7 @@ describe Gitlab::UsageData do
clusters_disabled: 1, clusters_disabled: 1,
clusters_enabled: 4, clusters_enabled: 4,
clusters_platforms_gke: 1, clusters_platforms_gke: 1,
clusters_platforms_eks: 1,
clusters_platforms_user: 1, clusters_platforms_user: 1,
group_clusters_disabled: 1, group_clusters_disabled: 1,
group_clusters_enabled: 1, group_clusters_enabled: 1,
......
...@@ -66,6 +66,7 @@ module Gitlab ...@@ -66,6 +66,7 @@ module Gitlab
clusters_disabled: count(::Clusters::Cluster.disabled), clusters_disabled: count(::Clusters::Cluster.disabled),
project_clusters_disabled: count(::Clusters::Cluster.disabled.project_type), project_clusters_disabled: count(::Clusters::Cluster.disabled.project_type),
group_clusters_disabled: count(::Clusters::Cluster.disabled.group_type), group_clusters_disabled: count(::Clusters::Cluster.disabled.group_type),
clusters_platforms_eks: count(::Clusters::Cluster.aws_installed.enabled),
clusters_platforms_gke: count(::Clusters::Cluster.gcp_installed.enabled), clusters_platforms_gke: count(::Clusters::Cluster.gcp_installed.enabled),
clusters_platforms_user: count(::Clusters::Cluster.user_provided.enabled), clusters_platforms_user: count(::Clusters::Cluster.user_provided.enabled),
clusters_applications_helm: count(::Clusters::Applications::Helm.available), clusters_applications_helm: count(::Clusters::Applications::Helm.available),
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
FactoryBot.define do FactoryBot.define do
factory :cluster_platform_kubernetes, class: Clusters::Platforms::Kubernetes do factory :cluster_platform_kubernetes, class: Clusters::Platforms::Kubernetes do
cluster association :cluster, platform_type: :kubernetes, provider_type: :user
namespace { nil } namespace { nil }
api_url { 'https://kubernetes.example.com' } api_url { 'https://kubernetes.example.com' }
token { 'a' * 40 } token { 'a' * 40 }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
FactoryBot.define do FactoryBot.define do
factory :cluster_provider_aws, class: Clusters::Providers::Aws do factory :cluster_provider_aws, class: Clusters::Providers::Aws do
cluster association :cluster, platform_type: :kubernetes, provider_type: :aws
created_by_user factory: :user created_by_user factory: :user
role_arn { 'arn:aws:iam::123456789012:role/role-name' } role_arn { 'arn:aws:iam::123456789012:role/role-name' }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
FactoryBot.define do FactoryBot.define do
factory :cluster_provider_gcp, class: Clusters::Providers::Gcp do factory :cluster_provider_gcp, class: Clusters::Providers::Gcp do
cluster association :cluster, platform_type: :kubernetes, provider_type: :gcp
gcp_project_id { 'test-gcp-project' } gcp_project_id { 'test-gcp-project' }
trait :scheduled do trait :scheduled do
......
...@@ -24,12 +24,19 @@ describe Gitlab::UsageData do ...@@ -24,12 +24,19 @@ describe Gitlab::UsageData do
create_list(:zoom_meeting, 2, project: projects[0], issue: projects[0].issues[1], issue_status: :removed) create_list(:zoom_meeting, 2, project: projects[0], issue: projects[0].issues[1], issue_status: :removed)
create(:zoom_meeting, project: projects[0], issue: projects[0].issues[2], issue_status: :added) create(:zoom_meeting, project: projects[0], issue: projects[0].issues[2], issue_status: :added)
create_list(:zoom_meeting, 2, project: projects[0], issue: projects[0].issues[2], issue_status: :removed) create_list(:zoom_meeting, 2, project: projects[0], issue: projects[0].issues[2], issue_status: :removed)
gcp_cluster = create(:cluster, :provided_by_gcp)
create(:cluster, :provided_by_user) # Enabled clusters
create(:cluster, :provided_by_user, :disabled) gcp_cluster = create(:cluster_provider_gcp, :created).cluster
create(:cluster_provider_aws, :created)
create(:cluster_platform_kubernetes)
create(:cluster, :group) create(:cluster, :group)
# Disabled clusters
create(:cluster, :disabled)
create(:cluster, :group, :disabled) create(:cluster, :group, :disabled)
create(:cluster, :group, :disabled) create(:cluster, :group, :disabled)
# Applications
create(:clusters_applications_helm, :installed, cluster: gcp_cluster) create(:clusters_applications_helm, :installed, cluster: gcp_cluster)
create(:clusters_applications_ingress, :installed, cluster: gcp_cluster) create(:clusters_applications_ingress, :installed, cluster: gcp_cluster)
create(:clusters_applications_cert_manager, :installed, cluster: gcp_cluster) create(:clusters_applications_cert_manager, :installed, cluster: gcp_cluster)
...@@ -117,6 +124,7 @@ describe Gitlab::UsageData do ...@@ -117,6 +124,7 @@ describe Gitlab::UsageData do
clusters_disabled clusters_disabled
project_clusters_disabled project_clusters_disabled
group_clusters_disabled group_clusters_disabled
clusters_platforms_eks
clusters_platforms_gke clusters_platforms_gke
clusters_platforms_user clusters_platforms_user
clusters_applications_helm clusters_applications_helm
...@@ -185,13 +193,14 @@ describe Gitlab::UsageData do ...@@ -185,13 +193,14 @@ describe Gitlab::UsageData do
expect(count_data[:issues_with_associated_zoom_link]).to eq(2) expect(count_data[:issues_with_associated_zoom_link]).to eq(2)
expect(count_data[:issues_using_zoom_quick_actions]).to eq(3) expect(count_data[:issues_using_zoom_quick_actions]).to eq(3)
expect(count_data[:clusters_enabled]).to eq(7) expect(count_data[:clusters_enabled]).to eq(4)
expect(count_data[:project_clusters_enabled]).to eq(6) expect(count_data[:project_clusters_enabled]).to eq(3)
expect(count_data[:group_clusters_enabled]).to eq(1) expect(count_data[:group_clusters_enabled]).to eq(1)
expect(count_data[:clusters_disabled]).to eq(3) expect(count_data[:clusters_disabled]).to eq(3)
expect(count_data[:project_clusters_disabled]).to eq(1) expect(count_data[:project_clusters_disabled]).to eq(1)
expect(count_data[:group_clusters_disabled]).to eq(2) expect(count_data[:group_clusters_disabled]).to eq(2)
expect(count_data[:group_clusters_enabled]).to eq(1) expect(count_data[:group_clusters_enabled]).to eq(1)
expect(count_data[:clusters_platforms_eks]).to eq(1)
expect(count_data[:clusters_platforms_gke]).to eq(1) expect(count_data[:clusters_platforms_gke]).to eq(1)
expect(count_data[:clusters_platforms_user]).to eq(1) expect(count_data[:clusters_platforms_user]).to eq(1)
expect(count_data[:clusters_applications_helm]).to eq(1) expect(count_data[:clusters_applications_helm]).to eq(1)
......
...@@ -55,7 +55,7 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do ...@@ -55,7 +55,7 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
let!(:cluster) { create(:cluster, enabled: true) } let!(:cluster) { create(:cluster, enabled: true) }
before do before do
create(:cluster, enabled: false) create(:cluster, :disabled)
end end
it { is_expected.to contain_exactly(cluster) } it { is_expected.to contain_exactly(cluster) }
...@@ -64,7 +64,7 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do ...@@ -64,7 +64,7 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
describe '.disabled' do describe '.disabled' do
subject { described_class.disabled } subject { described_class.disabled }
let!(:cluster) { create(:cluster, enabled: false) } let!(:cluster) { create(:cluster, :disabled) }
before do before do
create(:cluster, enabled: true) create(:cluster, enabled: true)
...@@ -76,10 +76,10 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do ...@@ -76,10 +76,10 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
describe '.user_provided' do describe '.user_provided' do
subject { described_class.user_provided } subject { described_class.user_provided }
let!(:cluster) { create(:cluster, :provided_by_user) } let!(:cluster) { create(:cluster_platform_kubernetes).cluster }
before do before do
create(:cluster, :provided_by_gcp) create(:cluster_provider_gcp, :created)
end end
it { is_expected.to contain_exactly(cluster) } it { is_expected.to contain_exactly(cluster) }
...@@ -88,7 +88,7 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do ...@@ -88,7 +88,7 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
describe '.gcp_provided' do describe '.gcp_provided' do
subject { described_class.gcp_provided } subject { described_class.gcp_provided }
let!(:cluster) { create(:cluster, :provided_by_gcp) } let!(:cluster) { create(:cluster_provider_gcp, :created).cluster }
before do before do
create(:cluster, :provided_by_user) create(:cluster, :provided_by_user)
...@@ -100,7 +100,7 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do ...@@ -100,7 +100,7 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
describe '.gcp_installed' do describe '.gcp_installed' do
subject { described_class.gcp_installed } subject { described_class.gcp_installed }
let!(:cluster) { create(:cluster, :provided_by_gcp) } let!(:cluster) { create(:cluster_provider_gcp, :created).cluster }
before do before do
create(:cluster, :providing_by_gcp) create(:cluster, :providing_by_gcp)
...@@ -112,7 +112,7 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do ...@@ -112,7 +112,7 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
describe '.aws_provided' do describe '.aws_provided' do
subject { described_class.aws_provided } subject { described_class.aws_provided }
let!(:cluster) { create(:cluster, :provided_by_aws) } let!(:cluster) { create(:cluster_provider_aws, :created).cluster }
before do before do
create(:cluster, :provided_by_user) create(:cluster, :provided_by_user)
...@@ -124,11 +124,11 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do ...@@ -124,11 +124,11 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
describe '.aws_installed' do describe '.aws_installed' do
subject { described_class.aws_installed } subject { described_class.aws_installed }
let!(:cluster) { create(:cluster, :provided_by_aws) } let!(:cluster) { create(:cluster_provider_aws, :created).cluster }
before do before do
errored_cluster = create(:cluster, :provided_by_aws) errored_provider = create(:cluster_provider_aws)
errored_cluster.provider.make_errored!("Error message") errored_provider.make_errored!("Error message")
end end
it { is_expected.to contain_exactly(cluster) } it { is_expected.to contain_exactly(cluster) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment