diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-13 03:07:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-13 03:07:50 +0300 |
commit | 8dc1e72e2b5cb6112d5468194580edb186de4659 (patch) | |
tree | f77ab94b3a74dcb06c97ce1ea54a6f89eaeb26bf /app | |
parent | 0df696c5f77936ecae5ea3c3f17b3e885d7dea0b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
6 files changed, 49 insertions, 53 deletions
diff --git a/app/assets/javascripts/clusters/components/applications.vue b/app/assets/javascripts/clusters/components/applications.vue index de019593a76..f11502a7dde 100644 --- a/app/assets/javascripts/clusters/components/applications.vue +++ b/app/assets/javascripts/clusters/components/applications.vue @@ -662,7 +662,7 @@ Crossplane runs inside your Kubernetes cluster and supports secure connectivity :uninstall-successful="applications.elastic_stack.uninstallSuccessful" :uninstall-failed="applications.elastic_stack.uninstallFailed" :disabled="!helmInstalled" - title-link="https://github.com/helm/charts/tree/master/stable/elastic-stack" + title-link="https://gitlab.com/gitlab-org/charts/elastic-stack" > <div slot="description"> <p> diff --git a/app/assets/javascripts/static_site_editor/router/routes.js b/app/assets/javascripts/static_site_editor/router/routes.js index 0f5384dc244..6fb9dbe0182 100644 --- a/app/assets/javascripts/static_site_editor/router/routes.js +++ b/app/assets/javascripts/static_site_editor/router/routes.js @@ -14,4 +14,8 @@ export default [ path: '/success', component: Success, }, + { + path: '*', + redirect: HOME_ROUTE, + }, ]; diff --git a/app/models/clusters/applications/elastic_stack.rb b/app/models/clusters/applications/elastic_stack.rb index 3ddb67d8427..0d029aabc3b 100644 --- a/app/models/clusters/applications/elastic_stack.rb +++ b/app/models/clusters/applications/elastic_stack.rb @@ -3,7 +3,7 @@ module Clusters module Applications class ElasticStack < ApplicationRecord - VERSION = '2.0.0' + VERSION = '3.0.0' ELASTICSEARCH_PORT = 9200 @@ -18,7 +18,11 @@ module Clusters default_value_for :version, VERSION def chart - 'stable/elastic-stack' + 'elastic-stack/elastic-stack' + end + + def repository + 'https://charts.gitlab.io' end def install_command @@ -27,8 +31,9 @@ module Clusters version: VERSION, rbac: cluster.platform_kubernetes_rbac?, chart: chart, + repository: repository, files: files, - preinstall: migrate_to_2_script, + preinstall: migrate_to_3_script, postinstall: post_install_script ) end @@ -50,7 +55,7 @@ module Clusters strong_memoize(:elasticsearch_client) do next unless kube_client - proxy_url = kube_client.proxy_url('service', 'elastic-stack-elasticsearch-client', ::Clusters::Applications::ElasticStack::ELASTICSEARCH_PORT, Gitlab::Kubernetes::Helm::NAMESPACE) + proxy_url = kube_client.proxy_url('service', service_name, ::Clusters::Applications::ElasticStack::ELASTICSEARCH_PORT, Gitlab::Kubernetes::Helm::NAMESPACE) Elasticsearch::Client.new(url: proxy_url) do |faraday| # ensures headers containing auth data are appended to original client options @@ -70,21 +75,33 @@ module Clusters end end - def filebeat7? + 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 -t60 sh /data/helm/elastic-stack/config/wait-for-elasticsearch.sh http://elastic-stack-elasticsearch-client:9200" + "timeout -t60 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", "release=elastic-stack") + Gitlab::Kubernetes::KubectlCmd.delete("pvc", "--selector", pvc_selector, "--namespace", Gitlab::Kubernetes::Helm::NAMESPACE) ] end @@ -92,25 +109,19 @@ module Clusters cluster&.kubeclient&.core_client end - def migrate_to_2_script - # Updating the chart to 2.0.0 includes an update of the filebeat chart from 1.7.0 to 3.1.1 https://github.com/helm/charts/pull/21640 - # This includes the following commit that changes labels on the filebeat deployment https://github.com/helm/charts/commit/9b009170686c6f4b202c36ceb1da4bb9ba15ddd0 - # Unfortunately those fields are immutable, and we can't use `helm upgrade` to change them. We first have to delete the associated filebeat resources - # The following pre-install command runs before updating to 2.0.0 and sets filebeat.enable=false so the filebeat deployment is deleted. - # Then the main install command re-creates them properly - if updating? && !filebeat7? - [ - Gitlab::Kubernetes::Helm::InstallCommand.new( - name: 'elastic-stack', - version: version, - rbac: cluster.platform_kubernetes_rbac?, - chart: chart, - files: files - ).install_command + ' --set filebeat.enabled\\=false' - ] - else - [] - 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. + [ + Gitlab::Kubernetes::Helm::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 diff --git a/app/models/plan_limits.rb b/app/models/plan_limits.rb index 7f5c9b8b6b4..575105cfd79 100644 --- a/app/models/plan_limits.rb +++ b/app/models/plan_limits.rb @@ -11,7 +11,7 @@ class PlanLimits < ApplicationRecord else # object.count >= limit value is slower than checking # if a record exists at the limit value - 1 position. - object.limit(1).offset(read_attribute(limit_name) - 1).exists? + object.offset(read_attribute(limit_name) - 1).exists? end end diff --git a/app/services/pod_logs/elasticsearch_service.rb b/app/services/pod_logs/elasticsearch_service.rb index b73ebc4227d..f79562c8ab3 100644 --- a/app/services/pod_logs/elasticsearch_service.rb +++ b/app/services/pod_logs/elasticsearch_service.rb @@ -70,7 +70,7 @@ module PodLogs client = cluster&.application_elastic_stack&.elasticsearch_client return error(_('Unable to connect to Elasticsearch')) unless client - filebeat7 = cluster.application_elastic_stack.filebeat7? + chart_above_v2 = cluster.application_elastic_stack.chart_above_v2? response = ::Gitlab::Elasticsearch::Logs::Lines.new(client).pod_logs( namespace, @@ -80,7 +80,7 @@ module PodLogs start_time: result[:start_time], end_time: result[:end_time], cursor: result[:cursor], - filebeat7: filebeat7 + chart_above_v2: chart_above_v2 ) result.merge!(response) diff --git a/app/services/prometheus/proxy_variable_substitution_service.rb b/app/services/prometheus/proxy_variable_substitution_service.rb index c3d28232c68..aa3a09ba05c 100644 --- a/app/services/prometheus/proxy_variable_substitution_service.rb +++ b/app/services/prometheus/proxy_variable_substitution_service.rb @@ -17,8 +17,7 @@ module Prometheus steps :validate_variables, :add_params_to_result, :substitute_params, - :substitute_ruby_variables, - :substitute_liquid_variables + :substitute_variables def initialize(environment, params = {}) @environment, @params = environment, params.deep_dup @@ -56,7 +55,7 @@ module Prometheus success(result) end - def substitute_liquid_variables(result) + def substitute_variables(result) return success(result) unless query(result) result[:params][:query] = gsub(query(result), full_context) @@ -64,24 +63,6 @@ module Prometheus success(result) end - def substitute_ruby_variables(result) - return success(result) unless query(result) - - # The % operator doesn't replace variables if the hash contains string - # keys. - result[:params][:query] = query(result) % predefined_context.symbolize_keys - - success(result) - rescue TypeError, ArgumentError => exception - log_error(exception.message) - Gitlab::ErrorTracking.track_exception(exception, { - template_string: query(result), - variables: predefined_context - }) - - error(_('Malformed string')) - end - def gsub(string, context) # Search for variables of the form `{{variable}}` in the string and replace # them with their value. @@ -95,11 +76,11 @@ module Prometheus end def predefined_context - @predefined_context ||= Gitlab::Prometheus::QueryVariables.call(@environment) + Gitlab::Prometheus::QueryVariables.call(@environment).stringify_keys end def full_context - @full_context ||= predefined_context.stringify_keys.reverse_merge(variables_hash) + @full_context ||= predefined_context.reverse_merge(variables_hash) end def variables |