Commit c58c97cc authored by Robert Speicher's avatar Robert Speicher

Merge branch...

Merge branch '197130-using-the-web-ide-web-terminal-leads-to-error-500-when-accessing-the-dashboard-projects-list' into 'master'

Resolve "Using the Web IDE Web Terminal leads to error 500 when accessing the dashboard/projects list"

Closes #197130

See merge request gitlab-org/gitlab!24443
parents a644e7d0 bfb09b56
...@@ -185,7 +185,7 @@ module Ci ...@@ -185,7 +185,7 @@ module Ci
pipeline.run_after_commit do pipeline.run_after_commit do
PipelineHooksWorker.perform_async(pipeline.id) PipelineHooksWorker.perform_async(pipeline.id)
ExpirePipelineCacheWorker.perform_async(pipeline.id) ExpirePipelineCacheWorker.perform_async(pipeline.id) if pipeline.cacheable?
end end
end end
...@@ -902,6 +902,10 @@ module Ci ...@@ -902,6 +902,10 @@ module Ci
statuses.latest.success.where(name: names).pluck(:id) statuses.latest.success.where(name: names).pluck(:id)
end end
def cacheable?
Ci::PipelineEnums.ci_config_sources.key?(config_source.to_sym)
end
private private
def pipeline_data def pipeline_data
......
...@@ -46,13 +46,18 @@ module Ci ...@@ -46,13 +46,18 @@ module Ci
} }
end end
def self.ci_config_sources_values def self.ci_config_sources
config_sources.values_at( config_sources.slice(
:unknown_source, :unknown_source,
:repository_source, :repository_source,
:auto_devops_source, :auto_devops_source,
:remote_source, :remote_source,
:external_project_source) :external_project_source
)
end
def self.ci_config_sources_values
ci_config_sources.values
end end
end end
end end
......
...@@ -32,7 +32,7 @@ class BuildFinishedWorker ...@@ -32,7 +32,7 @@ class BuildFinishedWorker
# We execute these async as these are independent operations. # We execute these async as these are independent operations.
BuildHooksWorker.perform_async(build.id) BuildHooksWorker.perform_async(build.id)
ArchiveTraceWorker.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? ChatNotificationWorker.perform_async(build.id) if build.pipeline.chat?
end end
end end
......
...@@ -11,7 +11,7 @@ class ExpirePipelineCacheWorker ...@@ -11,7 +11,7 @@ class ExpirePipelineCacheWorker
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id) def perform(pipeline_id)
pipeline = Ci::Pipeline.find_by(id: pipeline_id) pipeline = Ci::Pipeline.find_by(id: pipeline_id)
return unless pipeline return unless pipeline&.cacheable?
Ci::ExpirePipelineCacheService.new.execute(pipeline) Ci::ExpirePipelineCacheService.new.execute(pipeline)
end end
......
---
title: Resolve 500 error after Web IDE terminal use
merge_request: 24443
author:
type: fixed
...@@ -373,6 +373,18 @@ describe Ci::Pipeline do ...@@ -373,6 +373,18 @@ describe Ci::Pipeline do
end end
end 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 end
describe '#latest_merge_request_pipeline?' do describe '#latest_merge_request_pipeline?' do
......
...@@ -3,10 +3,7 @@ ...@@ -3,10 +3,7 @@
module QA module QA
# This test was quarantined because relative URL isn't supported # This test was quarantined because relative URL isn't supported
# See https://gitlab.com/gitlab-org/gitlab/issues/13833 # See https://gitlab.com/gitlab-org/gitlab/issues/13833
# It's now skipped because another bug breaks the projects list and context 'Create', :quarantine do
# causes subsequent tests to fail
# See https://gitlab.com/gitlab-org/gitlab/issues/197130
context 'Create', :skip do
describe 'Web IDE web terminal', :docker do describe 'Web IDE web terminal', :docker do
before do before do
project = Resource::Project.fabricate_via_api! do |project| project = Resource::Project.fabricate_via_api! do |project|
......
...@@ -1117,6 +1117,10 @@ describe Ci::Pipeline, :mailer do ...@@ -1117,6 +1117,10 @@ describe Ci::Pipeline, :mailer do
end end
describe 'pipeline caching' do describe 'pipeline caching' do
before do
pipeline.config_source = 'repository_source'
end
it 'performs ExpirePipelinesCacheWorker' do it 'performs ExpirePipelinesCacheWorker' do
expect(ExpirePipelineCacheWorker).to receive(:perform_async).with(pipeline.id) expect(ExpirePipelineCacheWorker).to receive(:perform_async).with(pipeline.id)
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
require 'spec_helper' require 'spec_helper'
describe ExpirePipelineCacheWorker do describe ExpirePipelineCacheWorker do
let(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:project) { create(:project) } let_it_be(:project) { create(:project) }
let(:pipeline) { create(:ci_pipeline, project: project) } let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
subject { described_class.new } subject { described_class.new }
...@@ -22,5 +22,14 @@ describe ExpirePipelineCacheWorker do ...@@ -22,5 +22,14 @@ describe ExpirePipelineCacheWorker do
subject.perform(617748) subject.perform(617748)
end 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
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