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>2021-11-18 16:16:36 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-18 16:16:36 +0300
commit311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch)
tree07e7870bca8aed6d61fdcc810731c50d2c40af47 /app/services/clusters
parent27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff)
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'app/services/clusters')
-rw-r--r--app/services/clusters/agents/refresh_authorization_service.rb2
-rw-r--r--app/services/clusters/cleanup/project_namespace_service.rb6
-rw-r--r--app/services/clusters/cleanup/service_account_service.rb5
-rw-r--r--app/services/clusters/integrations/prometheus_health_check_service.rb (renamed from app/services/clusters/applications/prometheus_health_check_service.rb)32
4 files changed, 32 insertions, 13 deletions
diff --git a/app/services/clusters/agents/refresh_authorization_service.rb b/app/services/clusters/agents/refresh_authorization_service.rb
index 7f401eef720..54b90a7304c 100644
--- a/app/services/clusters/agents/refresh_authorization_service.rb
+++ b/app/services/clusters/agents/refresh_authorization_service.rb
@@ -86,7 +86,7 @@ module Clusters
if group_root_ancestor?
root_ancestor.all_projects
else
- ::Project.none
+ ::Project.id_in(project.id)
end
end
diff --git a/app/services/clusters/cleanup/project_namespace_service.rb b/app/services/clusters/cleanup/project_namespace_service.rb
index 16254041306..0173f93f625 100644
--- a/app/services/clusters/cleanup/project_namespace_service.rb
+++ b/app/services/clusters/cleanup/project_namespace_service.rb
@@ -35,9 +35,11 @@ module Clusters
end
def kubeclient_delete_namespace(kubernetes_namespace)
- cluster.kubeclient.delete_namespace(kubernetes_namespace.namespace)
+ cluster.kubeclient&.delete_namespace(kubernetes_namespace.namespace)
rescue Kubeclient::ResourceNotFoundError
- # no-op: nothing to delete
+ # The resources have already been deleted, possibly on a previous attempt that timed out
+ rescue Gitlab::UrlBlocker::BlockedUrlError
+ # User gave an invalid cluster from the start, or deleted the endpoint before this job ran
end
end
end
diff --git a/app/services/clusters/cleanup/service_account_service.rb b/app/services/clusters/cleanup/service_account_service.rb
index baac9e4a9e7..53f968cd409 100644
--- a/app/services/clusters/cleanup/service_account_service.rb
+++ b/app/services/clusters/cleanup/service_account_service.rb
@@ -16,11 +16,14 @@ module Clusters
def delete_gitlab_service_account
log_event(:deleting_gitlab_service_account)
- cluster.kubeclient.delete_service_account(
+ cluster.kubeclient&.delete_service_account(
::Clusters::Kubernetes::GITLAB_SERVICE_ACCOUNT_NAME,
::Clusters::Kubernetes::GITLAB_SERVICE_ACCOUNT_NAMESPACE
)
rescue Kubeclient::ResourceNotFoundError
+ # The resources have already been deleted, possibly on a previous attempt that timed out
+ rescue Gitlab::UrlBlocker::BlockedUrlError
+ # User gave an invalid cluster from the start, or deleted the endpoint before this job ran
end
end
end
diff --git a/app/services/clusters/applications/prometheus_health_check_service.rb b/app/services/clusters/integrations/prometheus_health_check_service.rb
index eda47f56e72..cd06e59449c 100644
--- a/app/services/clusters/applications/prometheus_health_check_service.rb
+++ b/app/services/clusters/integrations/prometheus_health_check_service.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module Clusters
- module Applications
+ module Integrations
class PrometheusHealthCheckService
include Gitlab::Utils::StrongMemoize
include Gitlab::Routing
@@ -14,7 +14,7 @@ module Clusters
def execute
raise 'Invalid cluster type. Only project types are allowed.' unless @cluster.project_type?
- return unless prometheus_application.installed?
+ return unless prometheus_integration.enabled
project = @cluster.clusterable
@@ -28,32 +28,46 @@ module Clusters
send_notification(project) if became_unhealthy?
- prometheus_application.update_columns(healthy: currently_healthy?) if health_changed?
+ prometheus_integration.update_columns(health_status: current_health_status) if health_changed?
end
private
- def prometheus_application
- strong_memoize(:prometheus_application) do
- @cluster.application_prometheus
+ def prometheus_integration
+ strong_memoize(:prometheus_integration) do
+ @cluster.integration_prometheus
+ end
+ end
+
+ def current_health_status
+ if currently_healthy?
+ :healthy
+ else
+ :unhealthy
end
end
def currently_healthy?
strong_memoize(:currently_healthy) do
- prometheus_application.prometheus_client.healthy?
+ prometheus_integration.prometheus_client.healthy?
end
end
def became_unhealthy?
strong_memoize(:became_unhealthy) do
- (was_healthy? || was_healthy?.nil?) && !currently_healthy?
+ (was_healthy? || was_unknown?) && !currently_healthy?
end
end
def was_healthy?
strong_memoize(:was_healthy) do
- prometheus_application.healthy
+ prometheus_integration.healthy?
+ end
+ end
+
+ def was_unknown?
+ strong_memoize(:was_unknown) do
+ prometheus_integration.unknown?
end
end