diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /app/models/clusters | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'app/models/clusters')
-rw-r--r-- | app/models/clusters/applications/prometheus.rb | 1 | ||||
-rw-r--r-- | app/models/clusters/cluster.rb | 1 | ||||
-rw-r--r-- | app/models/clusters/instance.rb | 6 | ||||
-rw-r--r-- | app/models/clusters/platforms/kubernetes.rb | 46 |
4 files changed, 49 insertions, 5 deletions
diff --git a/app/models/clusters/applications/prometheus.rb b/app/models/clusters/applications/prometheus.rb index 21f7e410843..d1e169a1f78 100644 --- a/app/models/clusters/applications/prometheus.rb +++ b/app/models/clusters/applications/prometheus.rb @@ -18,7 +18,6 @@ module Clusters default_value_for :version, VERSION scope :preload_cluster_platform, -> { preload(cluster: [:platform_kubernetes]) } - scope :with_clusters_with_cilium, -> { joins(:cluster).merge(Clusters::Cluster.with_available_cilium) } attr_encrypted :alert_manager_token, mode: :per_attribute_iv, diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb index 87afa9f9491..014f7530357 100644 --- a/app/models/clusters/cluster.rb +++ b/app/models/clusters/cluster.rb @@ -137,7 +137,6 @@ module Clusters scope :aws_installed, -> { aws_provided.joins(:provider_aws).merge(Clusters::Providers::Aws.with_status(:created)) } scope :with_available_elasticstack, -> { joins(:application_elastic_stack).merge(::Clusters::Applications::ElasticStack.available) } - scope :with_available_cilium, -> { joins(:application_cilium).merge(::Clusters::Applications::Cilium.available) } scope :distinct_with_deployed_environments, -> { joins(:environments).merge(::Deployment.success).distinct } scope :managed, -> { where(managed: true) } diff --git a/app/models/clusters/instance.rb b/app/models/clusters/instance.rb index 2a09ba11564..b5acc6a68f9 100644 --- a/app/models/clusters/instance.rb +++ b/app/models/clusters/instance.rb @@ -9,5 +9,11 @@ module Clusters def flipper_id self.class.to_s end + + def certificate_based_clusters_enabled? + ::Gitlab::SafeRequestStore.fetch("certificate_based_clusters:") do + Feature.enabled?(:certificate_based_clusters, type: :ops) + end + end end end diff --git a/app/models/clusters/platforms/kubernetes.rb b/app/models/clusters/platforms/kubernetes.rb index 1bd8e8b44cb..9d4f0a89403 100644 --- a/app/models/clusters/platforms/kubernetes.rb +++ b/app/models/clusters/platforms/kubernetes.rb @@ -11,6 +11,16 @@ module Clusters RESERVED_NAMESPACES = %w(gitlab-managed-apps).freeze + IGNORED_CONNECTION_EXCEPTIONS = [ + Gitlab::UrlBlocker::BlockedUrlError, + Kubeclient::HttpError, + Errno::ECONNREFUSED, + URI::InvalidURIError, + Errno::EHOSTUNREACH, + OpenSSL::X509::StoreError, + OpenSSL::SSL::SSLError + ].freeze + self.table_name = 'cluster_platforms_kubernetes' self.reactive_cache_work_type = :external_dependency @@ -102,10 +112,23 @@ module Clusters def calculate_reactive_cache_for(environment) return unless enabled? - pods = read_pods(environment.deployment_namespace) - deployments = read_deployments(environment.deployment_namespace) + pods = [] + deployments = [] + ingresses = [] + + begin + pods = read_pods(environment.deployment_namespace) + deployments = read_deployments(environment.deployment_namespace) + + ingresses = read_ingresses(environment.deployment_namespace) + rescue *IGNORED_CONNECTION_EXCEPTIONS => e + log_kube_connection_error(e) - ingresses = read_ingresses(environment.deployment_namespace) + # Return hash with default values so that it is cached. + return { + pods: pods, deployments: deployments, ingresses: ingresses + } + end # extract only the data required for display to avoid unnecessary caching { @@ -292,6 +315,23 @@ module Clusters } end end + + def log_kube_connection_error(error) + logger.error({ + exception: { + class: error.class.name, + message: error.message + }, + status_code: error.try(:error_code), + namespace: self.namespace, + class_name: self.class.name, + event: :kube_connection_error + }) + end + + def logger + @logger ||= Gitlab::Kubernetes::Logger.build + end end end end |