Commit c5b98228 authored by Shinya Maeda's avatar Shinya Maeda

Fix Canary Ingress weight is not reflected on UI immediately

This commit fixes the caching issue that the cached rollout status
is being used even after the entity is updated.
parent e049419a
......@@ -405,6 +405,11 @@ class Environment < ApplicationRecord
deployment_platform.patch_ingress(deployment_namespace, ingress, data)
end
def clear_all_caches
expire_etag_cache
clear_reactive_cache!
end
private
def rollout_status_available?
......
......@@ -24,6 +24,7 @@ module Environments
end
if environment.patch_ingress(canary_ingress, patch_data)
environment.clear_all_caches
success
else
error(_('Failed to update the Canary Ingress.'), :bad_request)
......
---
title: Fix Canary Ingress weight is not reflected on UI immediately
merge_request: 50246
author:
type: fixed
......@@ -1547,4 +1547,18 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do
end
end
end
describe '#clear_all_caches' do
subject { environment.clear_all_caches }
it 'clears all caches on the environment' do
expect_next_instance_of(Gitlab::EtagCaching::Store) do |store|
expect(store).to receive(:touch).with(environment.etag_cache_key)
end
expect(environment).to receive(:clear_reactive_cache!)
subject
end
end
end
......@@ -117,6 +117,12 @@ RSpec.describe Environments::CanaryIngress::UpdateService, :clean_gitlab_redis_c
expect(subject[:status]).to eq(:success)
expect(subject[:message]).to be_nil
end
it 'clears all caches' do
expect(environment).to receive(:clear_all_caches)
subject
end
end
context 'when patch request does not succeed' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment