diff options
Diffstat (limited to 'db')
28 files changed, 104 insertions, 26 deletions
diff --git a/db/docs/agent_activity_events.yml b/db/docs/agent_activity_events.yml index 9fd906d5352..d014ef1f114 100644 --- a/db/docs/agent_activity_events.yml +++ b/db/docs/agent_activity_events.yml @@ -3,7 +3,7 @@ table_name: agent_activity_events classes: - Clusters::Agents::ActivityEvent feature_categories: -- kubernetes_management +- deployment_management description: Historical timeline events belonging to a cluster agent introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74577 milestone: '14.6' diff --git a/db/docs/agent_group_authorizations.yml b/db/docs/agent_group_authorizations.yml index c300ed3ba08..f0d45dbdc3d 100644 --- a/db/docs/agent_group_authorizations.yml +++ b/db/docs/agent_group_authorizations.yml @@ -3,7 +3,7 @@ table_name: agent_group_authorizations classes: - Clusters::Agents::Authorizations::CiAccess::GroupAuthorization feature_categories: -- kubernetes_management +- deployment_management description: Configuration for a group that is authorized to use a particular cluster agent introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68023 milestone: '14.3' diff --git a/db/docs/agent_project_authorizations.yml b/db/docs/agent_project_authorizations.yml index 98a74b9f9b7..77c26571c28 100644 --- a/db/docs/agent_project_authorizations.yml +++ b/db/docs/agent_project_authorizations.yml @@ -3,7 +3,7 @@ table_name: agent_project_authorizations classes: - Clusters::Agents::Authorizations::CiAccess::ProjectAuthorization feature_categories: -- kubernetes_management +- deployment_management description: Configuration for a project that is authorized to use a particular cluster agent introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/67295 milestone: '14.3' diff --git a/db/docs/agent_user_access_group_authorizations.yml b/db/docs/agent_user_access_group_authorizations.yml index 659b36bd61f..cd4df56d5a0 100644 --- a/db/docs/agent_user_access_group_authorizations.yml +++ b/db/docs/agent_user_access_group_authorizations.yml @@ -3,7 +3,7 @@ table_name: agent_user_access_group_authorizations classes: - Clusters::Agents::Authorizations::UserAccess::GroupAuthorization feature_categories: -- kubernetes_management +- deployment_management description: Configuration for a group that is authorized to use a particular cluster agent through user_access keyword introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/116901 milestone: '15.11' diff --git a/db/docs/agent_user_access_project_authorizations.yml b/db/docs/agent_user_access_project_authorizations.yml index 0f0953da630..f0629af6ec2 100644 --- a/db/docs/agent_user_access_project_authorizations.yml +++ b/db/docs/agent_user_access_project_authorizations.yml @@ -3,7 +3,7 @@ table_name: agent_user_access_project_authorizations classes: - Clusters::Agents::Authorizations::UserAccess::ProjectAuthorization feature_categories: -- kubernetes_management +- deployment_management description: Configuration for a project that is authorized to use a particular cluster agent through user_access keyword introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/116901 milestone: '15.11' diff --git a/db/docs/aws_roles.yml b/db/docs/aws_roles.yml index 902d6a97b62..0d5c9a6acb2 100644 --- a/db/docs/aws_roles.yml +++ b/db/docs/aws_roles.yml @@ -3,7 +3,7 @@ table_name: aws_roles classes: - Aws::Role feature_categories: -- kubernetes_management +- deployment_management description: (Deprecated) AWS IAM role for creating EKS clusters via GitLab introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/17057 milestone: '12.4' diff --git a/db/docs/cluster_agent_tokens.yml b/db/docs/cluster_agent_tokens.yml index 24b093c948c..36e843406b0 100644 --- a/db/docs/cluster_agent_tokens.yml +++ b/db/docs/cluster_agent_tokens.yml @@ -3,7 +3,7 @@ table_name: cluster_agent_tokens classes: - Clusters::AgentToken feature_categories: -- kubernetes_management +- deployment_management description: Tokens used by cluster agents to connect to GitLab introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/33228 milestone: '13.3' diff --git a/db/docs/cluster_agents.yml b/db/docs/cluster_agents.yml index 14574fb82f4..237d8d23bfd 100644 --- a/db/docs/cluster_agents.yml +++ b/db/docs/cluster_agents.yml @@ -3,7 +3,7 @@ table_name: cluster_agents classes: - Clusters::Agent feature_categories: -- kubernetes_management +- deployment_management description: Represents a GitLab Agent for Kubernetes installed in a Kubernetes cluster introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/33228 milestone: '13.3' diff --git a/db/docs/cluster_enabled_grants.yml b/db/docs/cluster_enabled_grants.yml index 873bbb4b7b5..4c6bef3db0e 100644 --- a/db/docs/cluster_enabled_grants.yml +++ b/db/docs/cluster_enabled_grants.yml @@ -3,7 +3,7 @@ table_name: cluster_enabled_grants classes: - Clusters::ClusterEnabledGrant feature_categories: -- kubernetes_management +- deployment_management description: Persists information about namespaces which got an extended life for certificate based clusters introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/87149 milestone: '15.1' diff --git a/db/docs/cluster_groups.yml b/db/docs/cluster_groups.yml index ff5c3d890fd..70c11431acf 100644 --- a/db/docs/cluster_groups.yml +++ b/db/docs/cluster_groups.yml @@ -3,7 +3,7 @@ table_name: cluster_groups classes: - Clusters::Group feature_categories: -- kubernetes_management +- deployment_management description: "(Deprecated) Join table between 'clusters' and 'namespaces'" introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/0e15eec86d83cbdfefe17966bf5c02e4d419a34d milestone: '11.5' diff --git a/db/docs/cluster_platforms_kubernetes.yml b/db/docs/cluster_platforms_kubernetes.yml index c92705b7c46..961eb37e366 100644 --- a/db/docs/cluster_platforms_kubernetes.yml +++ b/db/docs/cluster_platforms_kubernetes.yml @@ -3,7 +3,7 @@ table_name: cluster_platforms_kubernetes classes: - Clusters::Platforms::Kubernetes feature_categories: -- kubernetes_management +- deployment_management description: "(Deprecated) Kubernetes specific details for a cluster integration" introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/d0cff7f5855f91b5479f9fdaa39d8d95ec691a9e milestone: '10.2' diff --git a/db/docs/cluster_projects.yml b/db/docs/cluster_projects.yml index 89bcd726e1f..152b60ea87b 100644 --- a/db/docs/cluster_projects.yml +++ b/db/docs/cluster_projects.yml @@ -3,7 +3,7 @@ table_name: cluster_projects classes: - Clusters::Project feature_categories: -- kubernetes_management +- deployment_management description: "(Deprecated) Join table between 'clusters' and 'projects'" introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/d0cff7f5855f91b5479f9fdaa39d8d95ec691a9e milestone: '10.2' diff --git a/db/docs/cluster_providers_aws.yml b/db/docs/cluster_providers_aws.yml index 7c32b9291d1..ed9937b9a66 100644 --- a/db/docs/cluster_providers_aws.yml +++ b/db/docs/cluster_providers_aws.yml @@ -3,7 +3,7 @@ table_name: cluster_providers_aws classes: - Clusters::Providers::Aws feature_categories: -- kubernetes_management +- deployment_management description: "(Deprecated) AWS specific details for an EKS cluster integration" introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/17057 milestone: '12.4' diff --git a/db/docs/cluster_providers_gcp.yml b/db/docs/cluster_providers_gcp.yml index cc89320d346..a16e07d9fd3 100644 --- a/db/docs/cluster_providers_gcp.yml +++ b/db/docs/cluster_providers_gcp.yml @@ -3,7 +3,7 @@ table_name: cluster_providers_gcp classes: - Clusters::Providers::Gcp feature_categories: -- kubernetes_management +- deployment_management description: "(Deprecated) GCP specific details for a GKE cluster integration" introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/d0cff7f5855f91b5479f9fdaa39d8d95ec691a9e milestone: '10.2' diff --git a/db/docs/clusters.yml b/db/docs/clusters.yml index f791c84bfa2..309bdd426b6 100644 --- a/db/docs/clusters.yml +++ b/db/docs/clusters.yml @@ -3,7 +3,7 @@ table_name: clusters classes: - Clusters::Cluster feature_categories: -- kubernetes_management +- deployment_management description: Persists information about GitLab managed clusters introduced_by_url: https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/14879 milestone: '10.1' diff --git a/db/docs/clusters_applications_cert_managers.yml b/db/docs/clusters_applications_cert_managers.yml index 78ef851a2c0..0285b786f9f 100644 --- a/db/docs/clusters_applications_cert_managers.yml +++ b/db/docs/clusters_applications_cert_managers.yml @@ -1,7 +1,7 @@ --- table_name: clusters_applications_cert_managers feature_categories: -- kubernetes_management +- deployment_management description: "(Deprecated) A GitLab managed cert-manager installation in a Kubernetes cluster" introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/8837519445c319a699e0f3ced1c6912c839f3389 milestone: '11.6' diff --git a/db/docs/clusters_applications_crossplane.yml b/db/docs/clusters_applications_crossplane.yml index c440eb2487b..a993468d7b8 100644 --- a/db/docs/clusters_applications_crossplane.yml +++ b/db/docs/clusters_applications_crossplane.yml @@ -1,7 +1,7 @@ --- table_name: clusters_applications_crossplane feature_categories: -- kubernetes_management +- deployment_management description: "(Deprecated) A GitLab managed Crossplane installation in a Kubernetes cluster" introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/18797 milestone: '12.5' diff --git a/db/docs/clusters_applications_helm.yml b/db/docs/clusters_applications_helm.yml index 648557c8494..58dbe04b1d5 100644 --- a/db/docs/clusters_applications_helm.yml +++ b/db/docs/clusters_applications_helm.yml @@ -1,7 +1,7 @@ --- table_name: clusters_applications_helm feature_categories: -- kubernetes_management +- deployment_management description: "(Deprecated) A GitLab managed Helm installation in a Kubernetes cluster" introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/64be8d70ae20928df351e495a3442bb6036bc3e7 milestone: '10.2' diff --git a/db/docs/clusters_applications_ingress.yml b/db/docs/clusters_applications_ingress.yml index 7970448369e..b03d63f1cc6 100644 --- a/db/docs/clusters_applications_ingress.yml +++ b/db/docs/clusters_applications_ingress.yml @@ -1,7 +1,7 @@ --- table_name: clusters_applications_ingress feature_categories: -- kubernetes_management +- deployment_management description: "(Deprecated) A GitLab managed Ingress installation in a Kubernetes cluster" introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/d8223468ae2ae061020cc26336c51dc93cc75571 milestone: '10.2' diff --git a/db/docs/clusters_applications_jupyter.yml b/db/docs/clusters_applications_jupyter.yml index 59a28cd0469..4955e8fe217 100644 --- a/db/docs/clusters_applications_jupyter.yml +++ b/db/docs/clusters_applications_jupyter.yml @@ -1,7 +1,7 @@ --- table_name: clusters_applications_jupyter feature_categories: -- kubernetes_management +- deployment_management description: "(Deprecated) A GitLab managed Jupyter installation in a Kubernetes cluster" introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/db9f765852d9fef464e69c0bf47a382f2ab7219d milestone: '11.0' diff --git a/db/docs/clusters_applications_knative.yml b/db/docs/clusters_applications_knative.yml index fca2493cdcc..5cad3c342b0 100644 --- a/db/docs/clusters_applications_knative.yml +++ b/db/docs/clusters_applications_knative.yml @@ -1,7 +1,7 @@ --- table_name: clusters_applications_knative feature_categories: -- kubernetes_management +- deployment_management description: "(Deprecated) A GitLab managed Knative installation in a Kubernetes cluster" introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/b5155b90ee233e2824c168fbb06b3ce5d3aeb194 milestone: '11.5' diff --git a/db/docs/clusters_applications_prometheus.yml b/db/docs/clusters_applications_prometheus.yml index 3c36d953726..f80b676ae4a 100644 --- a/db/docs/clusters_applications_prometheus.yml +++ b/db/docs/clusters_applications_prometheus.yml @@ -1,7 +1,7 @@ --- table_name: clusters_applications_prometheus feature_categories: -- kubernetes_management +- deployment_management description: Information about installed instance of Prometheus in the cluster introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/0d4548026f3060ca0a8f7aa8d8fc89838bc66130 milestone: '10.4' diff --git a/db/docs/clusters_applications_runners.yml b/db/docs/clusters_applications_runners.yml index 4e1e07db30d..8844c6647cd 100644 --- a/db/docs/clusters_applications_runners.yml +++ b/db/docs/clusters_applications_runners.yml @@ -1,7 +1,7 @@ --- table_name: clusters_applications_runners feature_categories: -- kubernetes_management +- deployment_management description: "(Deprecated) A GitLab managed Runner installation in a Kubernetes cluster" introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/c607008ee55e35465e04a938a341f2f24cb6761f milestone: '10.6' diff --git a/db/docs/clusters_kubernetes_namespaces.yml b/db/docs/clusters_kubernetes_namespaces.yml index 3572cfa4f2c..1c272eea497 100644 --- a/db/docs/clusters_kubernetes_namespaces.yml +++ b/db/docs/clusters_kubernetes_namespaces.yml @@ -3,7 +3,7 @@ table_name: clusters_kubernetes_namespaces classes: - Clusters::KubernetesNamespace feature_categories: -- kubernetes_management +- deployment_management description: "(Deprecated) A Kubernetes namespace in a GitLab managed Kubernetes cluster" introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/e3ca493876ab71ed29817a0af436fc563f564bbe milestone: '11.5' diff --git a/db/docs/deployment_clusters.yml b/db/docs/deployment_clusters.yml index eea538a83d2..011c5252593 100644 --- a/db/docs/deployment_clusters.yml +++ b/db/docs/deployment_clusters.yml @@ -3,7 +3,7 @@ table_name: deployment_clusters classes: - DeploymentCluster feature_categories: -- kubernetes_management +- deployment_management description: "(Deprecated) Join table between `deployments` and `clusters`" introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24235 milestone: '12.8' diff --git a/db/docs/serverless_domain_cluster.yml b/db/docs/serverless_domain_cluster.yml index 72b231171ba..f035c992d37 100644 --- a/db/docs/serverless_domain_cluster.yml +++ b/db/docs/serverless_domain_cluster.yml @@ -1,7 +1,7 @@ --- table_name: serverless_domain_cluster feature_categories: -- kubernetes_management +- deployment_management description: "(Deprecated) A custom domain for a GitLab managed Knative installation" introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/19835 milestone: '12.6' diff --git a/db/post_migrate/20230403221928_resync_scan_result_policies_for_namespaces.rb b/db/post_migrate/20230403221928_resync_scan_result_policies_for_namespaces.rb new file mode 100644 index 00000000000..34ab8ea3873 --- /dev/null +++ b/db/post_migrate/20230403221928_resync_scan_result_policies_for_namespaces.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true + +class ResyncScanResultPoliciesForNamespaces < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + restrict_gitlab_migration gitlab_schema: :gitlab_main + + BATCH_SIZE = 50 + + class Group < MigrationRecord + self.inheritance_column = :_type_disabled + self.table_name = 'namespaces' + + def self.as_ids + select(Arel.sql('namespaces.traversal_ids[array_length(namespaces.traversal_ids, 1)]').as('id')) + end + + def self_and_descendant_ids + self.class.where("traversal_ids @> ('{?}')", id).as_ids + end + end + + class Project < MigrationRecord + self.table_name = 'projects' + end + + class OrchestrationPolicyConfiguration < MigrationRecord + include EachBatch + self.table_name = 'security_orchestration_policy_configurations' + end + + def up + return unless Gitlab.ee? + return unless process_scan_result_policy_worker + + OrchestrationPolicyConfiguration + .where.not(namespace_id: nil) + .each_batch(column: :namespace_id, of: BATCH_SIZE) do |policy_configurations| + policy_configurations.each do |policy_configuration| + for_each_project(policy_configuration) do |project| + process_scan_result_policy_worker.perform_async(project.id, policy_configuration.id) + end + end + end + end + + def down + # no-op + end + + private + + def for_each_project(policy_configuration) + scope = Project.order(:id) + array_scope = Group.find(policy_configuration.namespace_id).self_and_descendant_ids + array_mapping_scope = ->(id_expression) do + Project.where(Project.arel_table[:namespace_id].eq(id_expression)).select(:id) + end + + query_builder = Gitlab::Pagination::Keyset::InOperatorOptimization::QueryBuilder.new( + scope: scope, + array_scope: array_scope, + array_mapping_scope: array_mapping_scope + ) + + query_builder.execute.limit(BATCH_SIZE).each do |project| + yield(project) if block_given? + end + end + + def process_scan_result_policy_worker + unless defined?(@process_scan_result_policy_worker) + @process_scan_result_policy_worker = 'Security::ProcessScanResultPolicyWorker'.safe_constantize + end + + @process_scan_result_policy_worker + end +end diff --git a/db/schema_migrations/20230403221928 b/db/schema_migrations/20230403221928 new file mode 100644 index 00000000000..42fd52b4415 --- /dev/null +++ b/db/schema_migrations/20230403221928 @@ -0,0 +1 @@ +458b23ebbf780535b3eec467bad2edbf3bcca3804569d892572c6e6fac2f2019
\ No newline at end of file |