Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
324c544c
Commit
324c544c
authored
Jul 27, 2020
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix mail worker error in versioning middleware
Only assign version for ApplicationWorker
parent
280598e1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
69 additions
and
11 deletions
+69
-11
config/feature_flags/development/sidekiq_versioning.yml
config/feature_flags/development/sidekiq_versioning.yml
+7
-0
lib/gitlab/sidekiq_middleware.rb
lib/gitlab/sidekiq_middleware.rb
+1
-0
lib/gitlab/sidekiq_versioning.rb
lib/gitlab/sidekiq_versioning.rb
+0
-4
lib/gitlab/sidekiq_versioning/middleware.rb
lib/gitlab/sidekiq_versioning/middleware.rb
+1
-1
spec/lib/gitlab/sidekiq_middleware_spec.rb
spec/lib/gitlab/sidekiq_middleware_spec.rb
+38
-0
spec/lib/gitlab/sidekiq_versioning/middleware_spec.rb
spec/lib/gitlab/sidekiq_versioning/middleware_spec.rb
+22
-0
spec/lib/gitlab/sidekiq_versioning_spec.rb
spec/lib/gitlab/sidekiq_versioning_spec.rb
+0
-6
No files found.
config/feature_flags/development/sidekiq_versioning.yml
0 → 100644
View file @
324c544c
---
name
:
sidekiq_versioning
introduced_by_url
:
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/232934
group
:
group::fulfillment
type
:
development
default_enabled
:
false
\ No newline at end of file
lib/gitlab/sidekiq_middleware.rb
View file @
324c544c
...
...
@@ -19,6 +19,7 @@ module Gitlab
chain
.
add
::
Labkit
::
Middleware
::
Sidekiq
::
Server
chain
.
add
::
Gitlab
::
SidekiqMiddleware
::
InstrumentationLogger
chain
.
add
::
Gitlab
::
SidekiqMiddleware
::
AdminMode
::
Server
chain
.
add
::
Gitlab
::
SidekiqVersioning
::
Middleware
chain
.
add
::
Gitlab
::
SidekiqStatus
::
ServerMiddleware
chain
.
add
::
Gitlab
::
SidekiqMiddleware
::
WorkerContext
::
Server
chain
.
add
::
Gitlab
::
SidekiqMiddleware
::
DuplicateJobs
::
Server
...
...
lib/gitlab/sidekiq_versioning.rb
View file @
324c544c
...
...
@@ -5,10 +5,6 @@ module Gitlab
def
self
.
install!
Sidekiq
::
Manager
.
prepend
SidekiqVersioning
::
Manager
Sidekiq
.
server_middleware
do
|
chain
|
chain
.
add
SidekiqVersioning
::
Middleware
end
# The Sidekiq client API always adds the queue to the Sidekiq queue
# list, but mail_room and gitlab-shell do not. This is only necessary
# for monitoring.
...
...
lib/gitlab/sidekiq_versioning/middleware.rb
View file @
324c544c
...
...
@@ -4,7 +4,7 @@ module Gitlab
module
SidekiqVersioning
class
Middleware
def
call
(
worker
,
job
,
queue
)
worker
.
job_version
=
job
[
'version'
]
worker
.
job_version
=
job
[
'version'
]
if
worker
.
is_a?
(
ApplicationWorker
)
&&
Feature
.
enabled?
(
:sidekiq_versioning
)
yield
end
...
...
spec/lib/gitlab/sidekiq_middleware_spec.rb
View file @
324c544c
...
...
@@ -51,6 +51,7 @@ RSpec.describe Gitlab::SidekiqMiddleware do
Gitlab
::
SidekiqMiddleware
::
BatchLoader
,
Labkit
::
Middleware
::
Sidekiq
::
Server
,
Gitlab
::
SidekiqMiddleware
::
InstrumentationLogger
,
Gitlab
::
SidekiqVersioning
::
Middleware
,
Gitlab
::
SidekiqStatus
::
ServerMiddleware
,
Gitlab
::
SidekiqMiddleware
::
ServerMetrics
,
Gitlab
::
SidekiqMiddleware
::
ArgumentsLogger
,
...
...
@@ -78,6 +79,41 @@ RSpec.describe Gitlab::SidekiqMiddleware do
end
end
shared_examples
"a server middleware chain for mailer"
do
let
(
:worker_class
)
{
ActiveJob
::
QueueAdapters
::
SidekiqAdapter
::
JobWrapper
}
let
(
:job_args
)
do
[
{
"job_class"
=>
"ActionMailer::MailDeliveryJob"
,
"job_id"
=>
"a180b47c-3fd6-41b8-81e9-34da61c3400e"
,
"provider_job_id"
=>
nil
,
"queue_name"
=>
"mailers"
,
"priority"
=>
nil
,
"arguments"
=>
[
"Notify"
,
"test_email"
,
"deliver_now"
,
{
"args"
=>
[
"test@example.com"
,
"subject"
,
"body"
],
"_aj_symbol_keys"
=>
[
"args"
]
}
],
"executions"
=>
0
,
"exception_executions"
=>
{},
"locale"
=>
"en"
,
"timezone"
=>
"UTC"
,
"enqueued_at"
=>
"2020-07-27T07:43:31Z"
}
]
end
it_behaves_like
"a server middleware chain"
end
context
"all optional middlewares off"
do
let
(
:metrics
)
{
false
}
let
(
:arguments_logger
)
{
false
}
...
...
@@ -91,6 +127,7 @@ RSpec.describe Gitlab::SidekiqMiddleware do
end
it_behaves_like
"a server middleware chain"
it_behaves_like
"a server middleware chain for mailer"
end
context
"all optional middlewares on"
do
...
...
@@ -100,6 +137,7 @@ RSpec.describe Gitlab::SidekiqMiddleware do
let
(
:disabled_sidekiq_middlewares
)
{
[]
}
it_behaves_like
"a server middleware chain"
it_behaves_like
"a server middleware chain for mailer"
context
"server metrics"
do
let
(
:gitaly_histogram
)
{
double
(
:gitaly_histogram
)
}
...
...
spec/lib/gitlab/sidekiq_versioning/middleware_spec.rb
View file @
324c544c
...
...
@@ -34,5 +34,27 @@ RSpec.describe Gitlab::SidekiqVersioning::Middleware do
it
'yields'
do
expect
{
|
b
|
call!
(
&
b
)
}.
to
yield_control
end
context
'when worker is not ApplicationWorker'
do
let
(
:worker_class
)
do
ActiveJob
::
QueueAdapters
::
SidekiqAdapter
::
JobWrapper
end
it
'does not err'
do
expect
{
call!
}.
not_to
raise_error
end
end
context
'when sidekiq_versioning is disabled'
do
before
do
stub_feature_flags
(
sidekiq_versioning:
false
)
end
it
'does not set job_version'
do
expect
(
worker
).
not_to
receive
(
:job_version
=
)
call!
end
end
end
end
spec/lib/gitlab/sidekiq_versioning_spec.rb
View file @
324c544c
...
...
@@ -35,12 +35,6 @@ RSpec.describe Gitlab::SidekiqVersioning, :redis do
expect
(
Sidekiq
::
Manager
).
to
include
(
Gitlab
::
SidekiqVersioning
::
Manager
)
end
it
'adds the SidekiqVersioning::Middleware Sidekiq server middleware'
do
described_class
.
install!
expect
(
Sidekiq
.
server_middleware
.
entries
.
map
(
&
:klass
)).
to
include
(
Gitlab
::
SidekiqVersioning
::
Middleware
)
end
it
'registers all versionless and versioned queues with Redis'
do
described_class
.
install!
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment