diff options
-rw-r--r-- | changelogs/unreleased/sh-cache-feature-flag-names.yml | 5 | ||||
-rw-r--r-- | config/database.yml.example | 0 | ||||
-rw-r--r-- | doc/ci/pipelines.md | 2 | ||||
-rw-r--r-- | doc/user/project/deploy_boards.md | 3 | ||||
-rw-r--r-- | lib/feature.rb | 7 | ||||
-rw-r--r-- | lib/gitlab/kubernetes.rb | 7 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb | 3 | ||||
-rw-r--r-- | spec/lib/feature_spec.rb | 9 | ||||
-rw-r--r-- | spec/lib/gitlab/kubernetes_spec.rb | 10 |
9 files changed, 23 insertions, 23 deletions
diff --git a/changelogs/unreleased/sh-cache-feature-flag-names.yml b/changelogs/unreleased/sh-cache-feature-flag-names.yml new file mode 100644 index 00000000000..6120c4870f8 --- /dev/null +++ b/changelogs/unreleased/sh-cache-feature-flag-names.yml @@ -0,0 +1,5 @@ +--- +title: Cache feature flag names in Redis for a minute +merge_request: 29816 +author: +type: performance diff --git a/config/database.yml.example b/config/database.yml.example deleted file mode 100644 index e69de29bb2d..00000000000 --- a/config/database.yml.example +++ /dev/null diff --git a/doc/ci/pipelines.md b/doc/ci/pipelines.md index 5d54fbe519c..4a07aa31f8a 100644 --- a/doc/ci/pipelines.md +++ b/doc/ci/pipelines.md @@ -139,7 +139,7 @@ The union of A, B, and C is (1, 4) and (6, 7). Therefore, the total running time (4 - 1) + (7 - 6) => 4 ``` -## Expanding and collapsing job log sections +### Expanding and collapsing job log sections > [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/14664) in GitLab > 12.0. diff --git a/doc/user/project/deploy_boards.md b/doc/user/project/deploy_boards.md index 0994c51abb2..b7f6a855cb6 100644 --- a/doc/user/project/deploy_boards.md +++ b/doc/user/project/deploy_boards.md @@ -86,8 +86,7 @@ To display the Deploy Boards for a specific [environment] you should: Kubernetes. NOTE: **Note:** - The Kubernetes label of `app` is deprecated and may be removed in next major - release, GitLab 12.0. + Matching based on the Kubernetes `app` label was removed in [GitLab 12.1](https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/14020) ![Deploy Boards Kubernetes Label](img/deploy_boards_kubernetes_label.png) diff --git a/lib/feature.rb b/lib/feature.rb index 749c861d740..cc9c9d44005 100644 --- a/lib/feature.rb +++ b/lib/feature.rb @@ -30,7 +30,12 @@ class Feature end def persisted_names - Gitlab::SafeRequestStore[:flipper_persisted_names] ||= FlipperFeature.feature_names + Gitlab::SafeRequestStore[:flipper_persisted_names] ||= + begin + # We saw on GitLab.com, this database request was called 2300 + # times/s. Let's cache it for a minute to avoid that load. + Rails.cache.fetch('flipper:persisted_names', expires_in: 1.minute) { FlipperFeature.feature_names } + end end def persisted?(feature) diff --git a/lib/gitlab/kubernetes.rb b/lib/gitlab/kubernetes.rb index d46b5e3aee3..1103a4eed1d 100644 --- a/lib/gitlab/kubernetes.rb +++ b/lib/gitlab/kubernetes.rb @@ -37,15 +37,10 @@ module Gitlab # Filters an array of pods (as returned by the kubernetes API) by their project and environment def filter_by_project_environment(items, app, env) - pods = filter_by_annotation(items, { + filter_by_annotation(items, { 'app.gitlab.com/app' => app, 'app.gitlab.com/env' => env }) - return pods unless pods.empty? - - filter_by_label(items, { - 'app' => env, # deprecated: replaced by app.gitlab.com/env - }) end # Converts a pod (as returned by the kubernetes API) into a terminal diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb index 15cd59f041b..a118176eb8a 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true module QA - # https://gitlab.com/gitlab-org/quality/nightly/issues/100 - context 'Manage', :orchestrated, :oauth, :quarantine do + context 'Manage', :orchestrated, :oauth do describe 'OAuth login' do it 'User logs in to GitLab with GitHub OAuth' do Runtime::Browser.visit(:gitlab, Page::Main::Login) diff --git a/spec/lib/feature_spec.rb b/spec/lib/feature_spec.rb index a7163048370..6f05914f915 100644 --- a/spec/lib/feature_spec.rb +++ b/spec/lib/feature_spec.rb @@ -31,7 +31,8 @@ describe Feature do expect(described_class.persisted_names).to be_empty end - it 'caches the feature names when request store is active', :request_store do + it 'caches the feature names when request store is active', + :request_store, :use_clean_rails_memory_store_caching do Feature::FlipperFeature.create!(key: 'foo') expect(Feature::FlipperFeature) @@ -39,6 +40,12 @@ describe Feature do .once .and_call_original + expect(Rails.cache) + .to receive(:fetch) + .once + .with('flipper:persisted_names', expires_in: 1.minute) + .and_call_original + 2.times do expect(described_class.persisted_names).to eq(%w[foo]) end diff --git a/spec/lib/gitlab/kubernetes_spec.rb b/spec/lib/gitlab/kubernetes_spec.rb index 57b570a9166..45369b91ed6 100644 --- a/spec/lib/gitlab/kubernetes_spec.rb +++ b/spec/lib/gitlab/kubernetes_spec.rb @@ -59,16 +59,6 @@ describe Gitlab::Kubernetes do describe '#filter_by_project_environment' do let(:matching_pod) { kube_pod(environment_slug: 'production', project_slug: 'my-cool-app') } - it 'returns matching legacy env label' do - matching_pod['metadata']['annotations'].delete('app.gitlab.com/app') - matching_pod['metadata']['annotations'].delete('app.gitlab.com/env') - matching_pod['metadata']['labels']['app'] = 'production' - matching_items = [matching_pod] - items = matching_items + [kube_pod] - - expect(filter_by_project_environment(items, 'my-cool-app', 'production')).to eq(matching_items) - end - it 'returns matching env label' do matching_items = [matching_pod] items = matching_items + [kube_pod] |