Commit cb650598 authored by Vijay Hawoldar's avatar Vijay Hawoldar

Stop caching WebIDE terminal pipeline status

To fix a bug whereby cached terminal pipeline
status breaks project dashboard
parent f13fb32a
......@@ -187,7 +187,7 @@ module Ci
pipeline.run_after_commit do
PipelineHooksWorker.perform_async(pipeline.id)
ExpirePipelineCacheWorker.perform_async(pipeline.id)
ExpirePipelineCacheWorker.perform_async(pipeline.id) if pipeline.cacheable?
end
end
......@@ -904,6 +904,11 @@ module Ci
statuses.latest.success.where(name: names).pluck(:id)
end
def cacheable?
source_enum = Ci::PipelineEnums.config_sources[config_source.to_sym]
Ci::PipelineEnums.ci_config_sources_values.include?(source_enum)
end
private
def pipeline_data
......
......@@ -32,7 +32,7 @@ class BuildFinishedWorker
# We execute these async as these are independent operations.
BuildHooksWorker.perform_async(build.id)
ArchiveTraceWorker.perform_async(build.id)
ExpirePipelineCacheWorker.perform_async(build.pipeline_id)
ExpirePipelineCacheWorker.perform_async(build.pipeline_id) if build.pipeline.cacheable?
ChatNotificationWorker.perform_async(build.id) if build.pipeline.chat?
end
end
......
......@@ -11,7 +11,7 @@ class ExpirePipelineCacheWorker
# rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id)
pipeline = Ci::Pipeline.find_by(id: pipeline_id)
return unless pipeline
return unless pipeline&.cacheable?
Ci::ExpirePipelineCacheService.new.execute(pipeline)
end
......
......@@ -373,6 +373,18 @@ describe Ci::Pipeline do
end
end
end
context 'when pipeline is web terminal triggered' do
before do
pipeline.config_source = 'webide_source'
end
it 'does not schedule the pipeline cache worker' do
expect(ExpirePipelineCacheWorker).not_to receive(:perform_async)
pipeline.cancel!
end
end
end
describe '#latest_merge_request_pipeline?' do
......
......@@ -3,10 +3,7 @@
module QA
# This test was quarantined because relative URL isn't supported
# See https://gitlab.com/gitlab-org/gitlab/issues/13833
# It's now skipped because another bug breaks the projects list and
# causes subsequent tests to fail
# See https://gitlab.com/gitlab-org/gitlab/issues/197130
context 'Create' do
context 'Create', :quarantine do
describe 'Web IDE web terminal', :docker do
before do
project = Resource::Project.fabricate_via_api! do |project|
......
......@@ -1142,6 +1142,10 @@ describe Ci::Pipeline, :mailer do
end
describe 'pipeline caching' do
before do
pipeline.config_source = 'repository_source'
end
it 'performs ExpirePipelinesCacheWorker' do
expect(ExpirePipelineCacheWorker).to receive(:perform_async).with(pipeline.id)
......
......@@ -3,9 +3,9 @@
require 'spec_helper'
describe ExpirePipelineCacheWorker do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:pipeline) { create(:ci_pipeline, project: project) }
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
subject { described_class.new }
......@@ -22,5 +22,14 @@ describe ExpirePipelineCacheWorker do
subject.perform(617748)
end
it "doesn't do anything if the pipeline cannot be cached" do
allow_any_instance_of(Ci::Pipeline).to receive(:cacheable?).and_return(false)
expect_any_instance_of(Ci::ExpirePipelineCacheService).not_to receive(:execute)
expect_any_instance_of(Gitlab::EtagCaching::Store).not_to receive(:touch)
subject.perform(pipeline.id)
end
end
end
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