diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /app/services/clusters | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'app/services/clusters')
8 files changed, 17 insertions, 98 deletions
diff --git a/app/services/clusters/applications/check_installation_progress_service.rb b/app/services/clusters/applications/check_installation_progress_service.rb index 249abd3ff9d..10a12f30956 100644 --- a/app/services/clusters/applications/check_installation_progress_service.rb +++ b/app/services/clusters/applications/check_installation_progress_service.rb @@ -19,9 +19,7 @@ module Clusters def check_timeout if timed_out? - begin - app.make_errored!("Operation timed out. Check pod logs for #{pod_name} for more details.") - end + app.make_errored!("Operation timed out. Check pod logs for #{pod_name} for more details.") else ClusterWaitForAppInstallationWorker.perform_in( ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id) diff --git a/app/services/clusters/applications/check_upgrade_progress_service.rb b/app/services/clusters/applications/check_upgrade_progress_service.rb index bc161218618..c4fd234b302 100644 --- a/app/services/clusters/applications/check_upgrade_progress_service.rb +++ b/app/services/clusters/applications/check_upgrade_progress_service.rb @@ -51,7 +51,7 @@ module Clusters def remove_pod helm_api.delete_pod!(pod_name) - rescue + rescue StandardError # no-op end diff --git a/app/services/clusters/applications/prometheus_config_service.rb b/app/services/clusters/applications/prometheus_config_service.rb index 50c4e26b0d0..d39d63c874f 100644 --- a/app/services/clusters/applications/prometheus_config_service.rb +++ b/app/services/clusters/applications/prometheus_config_service.rb @@ -96,8 +96,6 @@ module Clusters end def alert_manager_token - app.generate_alert_manager_token! - app.alert_manager_token end diff --git a/app/services/clusters/applications/prometheus_update_service.rb b/app/services/clusters/applications/prometheus_update_service.rb index 437f6ab1202..b8b50f06d72 100644 --- a/app/services/clusters/applications/prometheus_update_service.rb +++ b/app/services/clusters/applications/prometheus_update_service.rb @@ -2,6 +2,7 @@ module Clusters module Applications + # Deprecated, to be removed in %14.0 as part of https://gitlab.com/groups/gitlab-org/-/epics/4280 class PrometheusUpdateService < BaseHelmService attr_accessor :project @@ -11,6 +12,8 @@ module Clusters end def execute + raise NotImplementedError, 'Externally installed prometheus should not be modified!' unless app.managed_prometheus? + app.make_updating! helm_api.update(patch_command(values)) diff --git a/app/services/clusters/applications/schedule_update_service.rb b/app/services/clusters/applications/schedule_update_service.rb index 41718df9a98..4f130f76b87 100644 --- a/app/services/clusters/applications/schedule_update_service.rb +++ b/app/services/clusters/applications/schedule_update_service.rb @@ -14,6 +14,7 @@ module Clusters def execute return unless application + return unless application.managed_prometheus? if recently_scheduled? worker_class.perform_in(BACKOFF_DELAY, application.name, application.id, project.id, Time.current) diff --git a/app/services/clusters/aws/fetch_credentials_service.rb b/app/services/clusters/aws/fetch_credentials_service.rb index 497e676f549..e38852c7ec7 100644 --- a/app/services/clusters/aws/fetch_credentials_service.rb +++ b/app/services/clusters/aws/fetch_credentials_service.rb @@ -14,7 +14,7 @@ module Clusters end def execute - raise MissingRoleError.new('AWS provisioning role not configured') unless provision_role.present? + raise MissingRoleError, 'AWS provisioning role not configured' unless provision_role.present? ::Aws::AssumeRoleCredentials.new( client: client, @@ -54,7 +54,7 @@ module Clusters ## # If we haven't created a provider record yet, - # we restrict ourselves to read only access so + # we restrict ourselves to read-only access so # that we can safely expose credentials to the # frontend (to be used when populating the # creation form). diff --git a/app/services/clusters/integrations/create_service.rb b/app/services/clusters/integrations/create_service.rb index f9e9dd3e457..142f731a7d3 100644 --- a/app/services/clusters/integrations/create_service.rb +++ b/app/services/clusters/integrations/create_service.rb @@ -27,12 +27,15 @@ module Clusters private def integration - case params[:application_type] - when 'prometheus' - cluster.find_or_build_integration_prometheus - else - raise ArgumentError, "invalid application_type: #{params[:application_type]}" - end + @integration ||= \ + case params[:application_type] + when 'prometheus' + cluster.find_or_build_integration_prometheus + when 'elastic_stack' + cluster.find_or_build_integration_elastic_stack + else + raise ArgumentError, "invalid application_type: #{params[:application_type]}" + end end def authorized? diff --git a/app/services/clusters/management/create_project_service.rb b/app/services/clusters/management/create_project_service.rb deleted file mode 100644 index 5a0176edd12..00000000000 --- a/app/services/clusters/management/create_project_service.rb +++ /dev/null @@ -1,84 +0,0 @@ -# frozen_string_literal: true - -module Clusters - module Management - class CreateProjectService - CreateError = Class.new(StandardError) - - attr_reader :cluster, :current_user - - def initialize(cluster, current_user:) - @cluster = cluster - @current_user = current_user - end - - def execute - return unless management_project_required? - - project = create_management_project! - update_cluster!(project) - end - - private - - def management_project_required? - Feature.enabled?(:auto_create_cluster_management_project) && cluster.management_project.nil? - end - - def project_params - { - name: project_name, - description: project_description, - namespace_id: namespace.id, - visibility_level: Gitlab::VisibilityLevel::PRIVATE - } - end - - def project_name - "#{cluster.name} Cluster Management" - end - - def project_description - "This project is automatically generated and will be used to manage your Kubernetes cluster. [More information](#{docs_path})" - end - - def docs_path - Rails.application.routes.url_helpers.help_page_path('user/clusters/management_project') - end - - def create_management_project! - ::Projects::CreateService.new(current_user, project_params).execute.tap do |project| - errors = project.errors.full_messages - - if errors.any? - raise CreateError.new("Failed to create project: #{errors}") - end - end - end - - def update_cluster!(project) - unless cluster.update(management_project: project) - raise CreateError.new("Failed to update cluster: #{cluster.errors.full_messages}") - end - end - - def namespace - case cluster.cluster_type - when 'project_type' - cluster.project.namespace - when 'group_type' - cluster.group - when 'instance_type' - instance_administrators_group - else - raise NotImplementedError - end - end - - def instance_administrators_group - Gitlab::CurrentSettings.instance_administrators_group || - raise(CreateError.new('Instance administrators group not found')) - end - end - end -end |