summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/jobs/components/table/graphql/queries/get_jobs.query.graphql4
-rw-r--r--app/controllers/clusters/clusters_controller.rb1
-rw-r--r--app/finders/groups/user_groups_finder.rb8
-rw-r--r--app/graphql/types/permission_types/group_enum.rb2
-rw-r--r--app/helpers/environments_helper.rb1
-rw-r--r--app/models/clusters/applications/elastic_stack.rb113
-rw-r--r--app/models/clusters/cluster.rb21
-rw-r--r--app/models/clusters/concerns/elasticsearch_client.rb38
-rw-r--r--app/models/clusters/integrations/elastic_stack.rb40
-rw-r--r--app/models/environment.rb4
-rw-r--r--app/models/project_import_state.rb9
-rw-r--r--app/presenters/clusters/integration_presenter.rb2
-rw-r--r--app/services/clusters/integrations/create_service.rb2
-rw-r--r--app/views/admin/application_settings/_grafana.html.haml2
-rw-r--r--app/workers/concerns/gitlab/github_import/object_importer.rb6
-rw-r--r--app/workers/concerns/gitlab/github_import/stage_methods.rb6
16 files changed, 32 insertions, 227 deletions
diff --git a/app/assets/javascripts/jobs/components/table/graphql/queries/get_jobs.query.graphql b/app/assets/javascripts/jobs/components/table/graphql/queries/get_jobs.query.graphql
index f3ca958b3ca..5b1032c6448 100644
--- a/app/assets/javascripts/jobs/components/table/graphql/queries/get_jobs.query.graphql
+++ b/app/assets/javascripts/jobs/components/table/graphql/queries/get_jobs.query.graphql
@@ -1,8 +1,8 @@
-query getJobs($fullPath: ID!, $after: String, $statuses: [CiJobStatus!]) {
+query getJobs($fullPath: ID!, $after: String, $first: Int = 30, $statuses: [CiJobStatus!]) {
project(fullPath: $fullPath) {
id
__typename
- jobs(after: $after, first: 30, statuses: $statuses) {
+ jobs(after: $after, first: $first, statuses: $statuses) {
count
pageInfo {
endCursor
diff --git a/app/controllers/clusters/clusters_controller.rb b/app/controllers/clusters/clusters_controller.rb
index a04fd09aa22..51150700860 100644
--- a/app/controllers/clusters/clusters_controller.rb
+++ b/app/controllers/clusters/clusters_controller.rb
@@ -50,7 +50,6 @@ class Clusters::ClustersController < Clusters::BaseController
def show
if params[:tab] == 'integrations'
@prometheus_integration = Clusters::IntegrationPresenter.new(@cluster.find_or_build_integration_prometheus)
- @elastic_stack_integration = Clusters::IntegrationPresenter.new(@cluster.find_or_build_integration_elastic_stack)
end
end
diff --git a/app/finders/groups/user_groups_finder.rb b/app/finders/groups/user_groups_finder.rb
index f4aed413867..90367638dcf 100644
--- a/app/finders/groups/user_groups_finder.rb
+++ b/app/finders/groups/user_groups_finder.rb
@@ -35,7 +35,7 @@ module Groups
attr_reader :current_user, :target_user, :params
def sort(items)
- items.order(path: :asc, id: :asc) # rubocop: disable CodeReuse/ActiveRecord
+ items.order(Group.arel_table[:path].asc, Group.arel_table[:id].asc) # rubocop: disable CodeReuse/ActiveRecord
end
def by_search(items)
@@ -47,6 +47,8 @@ module Groups
def by_permission_scope
if permission_scope_create_projects?
target_user.manageable_groups(include_groups_with_developer_maintainer_access: true)
+ elsif permission_scope_transfer_projects?
+ target_user.manageable_groups(include_groups_with_developer_maintainer_access: false)
else
target_user.groups
end
@@ -55,5 +57,9 @@ module Groups
def permission_scope_create_projects?
params[:permission_scope] == :create_projects
end
+
+ def permission_scope_transfer_projects?
+ params[:permission_scope] == :transfer_projects
+ end
end
end
diff --git a/app/graphql/types/permission_types/group_enum.rb b/app/graphql/types/permission_types/group_enum.rb
index cc4f5e9f1f0..8b0fee8898c 100644
--- a/app/graphql/types/permission_types/group_enum.rb
+++ b/app/graphql/types/permission_types/group_enum.rb
@@ -7,6 +7,8 @@ module Types
description 'User permission on groups'
value 'CREATE_PROJECTS', value: :create_projects, description: 'Groups where the user can create projects.'
+ value 'TRANSFER_PROJECTS', value: :transfer_projects,
+ description: 'Groups where the user can transfer projects to.'
end
end
end
diff --git a/app/helpers/environments_helper.rb b/app/helpers/environments_helper.rb
index 59d43c51db2..2623e32dbc8 100644
--- a/app/helpers/environments_helper.rb
+++ b/app/helpers/environments_helper.rb
@@ -36,7 +36,6 @@ module EnvironmentsHelper
"environment_name": environment.name,
"environments_path": api_v4_projects_environments_path(id: project.id),
"environment_id": environment.id,
- "cluster_applications_documentation_path" => help_page_path('user/clusters/integrations.md', anchor: 'elastic-stack-cluster-integration'),
"clusters_path": project_clusters_path(project, format: :json)
}
end
diff --git a/app/models/clusters/applications/elastic_stack.rb b/app/models/clusters/applications/elastic_stack.rb
deleted file mode 100644
index 73c731aab1a..00000000000
--- a/app/models/clusters/applications/elastic_stack.rb
+++ /dev/null
@@ -1,113 +0,0 @@
-# frozen_string_literal: true
-
-module Clusters
- module Applications
- class ElasticStack < ApplicationRecord
- include ::Clusters::Concerns::ElasticsearchClient
-
- VERSION = '3.0.0'
-
- self.table_name = 'clusters_applications_elastic_stacks'
-
- include ::Clusters::Concerns::ApplicationCore
- include ::Clusters::Concerns::ApplicationStatus
- include ::Clusters::Concerns::ApplicationVersion
- include ::Clusters::Concerns::ApplicationData
-
- default_value_for :version, VERSION
-
- after_destroy do
- cluster&.find_or_build_integration_elastic_stack&.update(enabled: false, chart_version: nil)
- end
-
- state_machine :status do
- after_transition any => [:installed] do |application|
- application.cluster&.find_or_build_integration_elastic_stack&.update(enabled: true, chart_version: application.version)
- end
-
- after_transition any => [:uninstalled] do |application|
- application.cluster&.find_or_build_integration_elastic_stack&.update(enabled: false, chart_version: nil)
- end
- end
-
- def chart
- 'elastic-stack/elastic-stack'
- end
-
- def repository
- 'https://charts.gitlab.io'
- end
-
- def install_command
- helm_command_module::InstallCommand.new(
- name: 'elastic-stack',
- version: VERSION,
- rbac: cluster.platform_kubernetes_rbac?,
- chart: chart,
- repository: repository,
- files: files,
- preinstall: migrate_to_3_script,
- postinstall: post_install_script
- )
- end
-
- def uninstall_command
- helm_command_module::DeleteCommand.new(
- name: 'elastic-stack',
- rbac: cluster.platform_kubernetes_rbac?,
- files: files,
- postdelete: post_delete_script
- )
- end
-
- def files
- super.merge('wait-for-elasticsearch.sh': File.read("#{Rails.root}/vendor/elastic_stack/wait-for-elasticsearch.sh"))
- end
-
- def chart_above_v2?
- Gem::Version.new(version) >= Gem::Version.new('2.0.0')
- end
-
- def chart_above_v3?
- Gem::Version.new(version) >= Gem::Version.new('3.0.0')
- end
-
- private
-
- def service_name
- chart_above_v3? ? 'elastic-stack-elasticsearch-master' : 'elastic-stack-elasticsearch-client'
- end
-
- def pvc_selector
- chart_above_v3? ? "app=elastic-stack-elasticsearch-master" : "release=elastic-stack"
- end
-
- def post_install_script
- [
- "timeout 60 sh /data/helm/elastic-stack/config/wait-for-elasticsearch.sh http://elastic-stack-elasticsearch-master:9200"
- ]
- end
-
- def post_delete_script
- [
- Gitlab::Kubernetes::KubectlCmd.delete("pvc", "--selector", pvc_selector, "--namespace", Gitlab::Kubernetes::Helm::NAMESPACE)
- ]
- end
-
- def migrate_to_3_script
- return [] if !updating? || chart_above_v3?
-
- # Chart version 3.0.0 moves to our own chart at https://gitlab.com/gitlab-org/charts/elastic-stack
- # and is not compatible with pre-existing resources. We first remove them.
- [
- helm_command_module::DeleteCommand.new(
- name: 'elastic-stack',
- rbac: cluster.platform_kubernetes_rbac?,
- files: files
- ).delete_command,
- Gitlab::Kubernetes::KubectlCmd.delete("pvc", "--selector", "release=elastic-stack", "--namespace", Gitlab::Kubernetes::Helm::NAMESPACE)
- ]
- end
- end
- end
-end
diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb
index 014f7530357..ad1e7dc305f 100644
--- a/app/models/clusters/cluster.rb
+++ b/app/models/clusters/cluster.rb
@@ -20,7 +20,6 @@ module Clusters
Clusters::Applications::Runner.application_name => Clusters::Applications::Runner,
Clusters::Applications::Jupyter.application_name => Clusters::Applications::Jupyter,
Clusters::Applications::Knative.application_name => Clusters::Applications::Knative,
- Clusters::Applications::ElasticStack.application_name => Clusters::Applications::ElasticStack,
Clusters::Applications::Cilium.application_name => Clusters::Applications::Cilium
}.freeze
DEFAULT_ENVIRONMENT = '*'
@@ -51,7 +50,6 @@ module Clusters
has_one :platform_kubernetes, class_name: 'Clusters::Platforms::Kubernetes', inverse_of: :cluster, autosave: true
has_one :integration_prometheus, class_name: 'Clusters::Integrations::Prometheus', inverse_of: :cluster
- has_one :integration_elastic_stack, class_name: 'Clusters::Integrations::ElasticStack', inverse_of: :cluster
def self.has_one_cluster_application(name) # rubocop:disable Naming/PredicateName
application = APPLICATIONS[name.to_s]
@@ -66,7 +64,6 @@ module Clusters
has_one_cluster_application :runner
has_one_cluster_application :jupyter
has_one_cluster_application :knative
- has_one_cluster_application :elastic_stack
has_one_cluster_application :cilium
has_many :kubernetes_namespaces
@@ -102,7 +99,6 @@ module Clusters
delegate :available?, to: :application_helm, prefix: true, allow_nil: true
delegate :available?, to: :application_ingress, prefix: true, allow_nil: true
delegate :available?, to: :application_knative, prefix: true, allow_nil: true
- delegate :available?, to: :integration_elastic_stack, prefix: true, allow_nil: true
delegate :available?, to: :integration_prometheus, prefix: true, allow_nil: true
delegate :external_ip, to: :application_ingress, prefix: true, allow_nil: true
delegate :external_hostname, to: :application_ingress, prefix: true, allow_nil: true
@@ -136,7 +132,6 @@ module Clusters
scope :gcp_installed, -> { gcp_provided.joins(:provider_gcp).merge(Clusters::Providers::Gcp.with_status(:created)) }
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 :distinct_with_deployed_environments, -> { joins(:environments).merge(::Deployment.success).distinct }
scope :managed, -> { where(managed: true) }
@@ -271,10 +266,6 @@ module Clusters
integration_prometheus || build_integration_prometheus
end
- def find_or_build_integration_elastic_stack
- integration_elastic_stack || build_integration_elastic_stack
- end
-
def provider
if gcp?
provider_gcp
@@ -309,18 +300,6 @@ module Clusters
platform_kubernetes&.kubeclient if kubernetes?
end
- def elastic_stack_adapter
- integration_elastic_stack
- end
-
- def elasticsearch_client
- elastic_stack_adapter&.elasticsearch_client
- end
-
- def elastic_stack_available?
- !!integration_elastic_stack_available?
- end
-
def kubernetes_namespace_for(environment, deployable: environment.last_deployable)
if deployable && environment.project_id != deployable.project_id
raise ArgumentError, 'environment.project_id must match deployable.project_id'
diff --git a/app/models/clusters/concerns/elasticsearch_client.rb b/app/models/clusters/concerns/elasticsearch_client.rb
deleted file mode 100644
index e9aab7897a8..00000000000
--- a/app/models/clusters/concerns/elasticsearch_client.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: true
-
-module Clusters
- module Concerns
- module ElasticsearchClient
- include ::Gitlab::Utils::StrongMemoize
-
- ELASTICSEARCH_PORT = 9200
- ELASTICSEARCH_NAMESPACE = 'gitlab-managed-apps'
-
- def elasticsearch_client(timeout: nil)
- strong_memoize(:elasticsearch_client) do
- kube_client = cluster&.kubeclient&.core_client
- next unless kube_client
-
- proxy_url = kube_client.proxy_url('service', service_name, ELASTICSEARCH_PORT, ELASTICSEARCH_NAMESPACE)
-
- Elasticsearch::Client.new(url: proxy_url, adapter: :net_http) do |faraday|
- # ensures headers containing auth data are appended to original client options
- faraday.headers.merge!(kube_client.headers)
- # ensure TLS certs are properly verified
- faraday.ssl[:verify] = kube_client.ssl_options[:verify_ssl]
- faraday.ssl[:cert_store] = kube_client.ssl_options[:cert_store]
- faraday.options.timeout = timeout unless timeout.nil?
- end
-
- rescue Kubeclient::HttpError => error
- # If users have mistakenly set parameters or removed the depended clusters,
- # `proxy_url` could raise an exception because gitlab can not communicate with the cluster.
- # We check for a nil client in downstream use and behaviour is equivalent to an empty state
- log_exception(error, :failed_to_create_elasticsearch_client)
-
- nil
- end
- end
- end
- end
-end
diff --git a/app/models/clusters/integrations/elastic_stack.rb b/app/models/clusters/integrations/elastic_stack.rb
deleted file mode 100644
index 97d73d252b9..00000000000
--- a/app/models/clusters/integrations/elastic_stack.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-# frozen_string_literal: true
-
-module Clusters
- module Integrations
- class ElasticStack < ApplicationRecord
- include ::Clusters::Concerns::ElasticsearchClient
- include ::Clusters::Concerns::KubernetesLogger
-
- self.table_name = 'clusters_integration_elasticstack'
- self.primary_key = :cluster_id
-
- belongs_to :cluster, class_name: 'Clusters::Cluster', foreign_key: :cluster_id
-
- validates :cluster, presence: true
- validates :enabled, inclusion: { in: [true, false] }
-
- scope :enabled, -> { where(enabled: true) }
-
- def available?
- enabled
- end
-
- def service_name
- chart_above_v3? ? 'elastic-stack-elasticsearch-master' : 'elastic-stack-elasticsearch-client'
- end
-
- def chart_above_v2?
- return true if chart_version.nil?
-
- Gem::Version.new(chart_version) >= Gem::Version.new('2.0.0')
- end
-
- def chart_above_v3?
- return true if chart_version.nil?
-
- Gem::Version.new(chart_version) >= Gem::Version.new('3.0.0')
- end
- end
- end
-end
diff --git a/app/models/environment.rb b/app/models/environment.rb
index da6ab5ed077..031a7f2fb83 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -456,10 +456,6 @@ class Environment < ApplicationRecord
self.auto_stop_at = parsed_result.seconds.from_now
end
- def elastic_stack_available?
- !!deployment_platform&.cluster&.elastic_stack_available?
- end
-
def rollout_status
return unless rollout_status_available?
diff --git a/app/models/project_import_state.rb b/app/models/project_import_state.rb
index b1c1a5b6697..7711c6d604a 100644
--- a/app/models/project_import_state.rb
+++ b/app/models/project_import_state.rb
@@ -31,6 +31,10 @@ class ProjectImportState < ApplicationRecord
transition started: :finished
end
+ event :cancel do
+ transition [:none, :scheduled, :started] => :canceled
+ end
+
event :fail_op do
transition [:scheduled, :started] => :failed
end
@@ -39,6 +43,7 @@ class ProjectImportState < ApplicationRecord
state :started
state :finished
state :failed
+ state :canceled
after_transition [:none, :finished, :failed] => :scheduled do |state, _|
state.run_after_commit do
@@ -51,7 +56,7 @@ class ProjectImportState < ApplicationRecord
end
end
- after_transition any => :finished do |state, _|
+ after_transition any => [:canceled, :finished] do |state, _|
if state.jid.present?
Gitlab::SidekiqStatus.unset(state.jid)
@@ -59,7 +64,7 @@ class ProjectImportState < ApplicationRecord
end
end
- after_transition any => :failed do |state, _|
+ after_transition any => [:canceled, :failed] do |state, _|
state.project.remove_import_data
end
diff --git a/app/presenters/clusters/integration_presenter.rb b/app/presenters/clusters/integration_presenter.rb
index f7be59f00f3..af735e1c18b 100644
--- a/app/presenters/clusters/integration_presenter.rb
+++ b/app/presenters/clusters/integration_presenter.rb
@@ -2,7 +2,7 @@
module Clusters
class IntegrationPresenter < Gitlab::View::Presenter::Delegated
- presents ::Clusters::Integrations::Prometheus, ::Clusters::Integrations::ElasticStack, as: :integration
+ presents ::Clusters::Integrations::Prometheus, as: :integration
def application_type
integration.class.name.demodulize.underscore
diff --git a/app/services/clusters/integrations/create_service.rb b/app/services/clusters/integrations/create_service.rb
index 142f731a7d3..555df52d177 100644
--- a/app/services/clusters/integrations/create_service.rb
+++ b/app/services/clusters/integrations/create_service.rb
@@ -31,8 +31,6 @@ module Clusters
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
diff --git a/app/views/admin/application_settings/_grafana.html.haml b/app/views/admin/application_settings/_grafana.html.haml
index 7f305b9ad9c..f17f63c7df7 100644
--- a/app/views/admin/application_settings/_grafana.html.haml
+++ b/app/views/admin/application_settings/_grafana.html.haml
@@ -1,5 +1,5 @@
= gitlab_ui_form_for @application_setting, url: metrics_and_profiling_admin_application_settings_path(anchor: 'js-grafana-settings'), html: { class: 'fieldset-form' } do |f|
- = form_errors(@application_setting)
+ = form_errors(@application_setting, pajamas_alert: true)
%fieldset
.form-group
diff --git a/app/workers/concerns/gitlab/github_import/object_importer.rb b/app/workers/concerns/gitlab/github_import/object_importer.rb
index e1f404b250d..c2cd50d8c21 100644
--- a/app/workers/concerns/gitlab/github_import/object_importer.rb
+++ b/app/workers/concerns/gitlab/github_import/object_importer.rb
@@ -23,6 +23,12 @@ module Gitlab
# client - An instance of `Gitlab::GithubImport::Client`
# hash - A Hash containing the details of the object to import.
def import(project, client, hash)
+ if project.import_state&.canceled?
+ info(project.id, message: 'project import canceled')
+
+ return
+ end
+
object = representation_class.from_json_hash(hash)
# To better express in the logs what object is being imported.
diff --git a/app/workers/concerns/gitlab/github_import/stage_methods.rb b/app/workers/concerns/gitlab/github_import/stage_methods.rb
index 225716f6bf3..b12c2311ea8 100644
--- a/app/workers/concerns/gitlab/github_import/stage_methods.rb
+++ b/app/workers/concerns/gitlab/github_import/stage_methods.rb
@@ -9,6 +9,12 @@ module Gitlab
return unless (project = find_project(project_id))
+ if project.import_state&.canceled?
+ info(project_id, message: 'project import canceled')
+
+ return
+ end
+
client = GithubImport.new_client_for(project)
try_import(client, project)