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
edc3ccee
Commit
edc3ccee
authored
Jul 13, 2020
by
Imre Farkas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add deduplication options of the worker to logs
parent
aff2c0b0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
6 deletions
+23
-6
lib/gitlab/sidekiq_logging/deduplication_logger.rb
lib/gitlab/sidekiq_logging/deduplication_logger.rb
+5
-2
lib/gitlab/sidekiq_middleware/duplicate_jobs/strategies/until_executing.rb
...q_middleware/duplicate_jobs/strategies/until_executing.rb
+2
-1
spec/lib/gitlab/sidekiq_logging/deduplication_logger_spec.rb
spec/lib/gitlab/sidekiq_logging/deduplication_logger_spec.rb
+3
-2
spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/strategies/until_executing_spec.rb
...dleware/duplicate_jobs/strategies/until_executing_spec.rb
+13
-1
No files found.
lib/gitlab/sidekiq_logging/deduplication_logger.rb
View file @
edc3ccee
...
@@ -6,11 +6,14 @@ module Gitlab
...
@@ -6,11 +6,14 @@ module Gitlab
include
Singleton
include
Singleton
include
LogsJobs
include
LogsJobs
def
log
(
job
,
deduplication_type
)
def
log
(
job
,
deduplication_type
,
deduplication_options
=
{}
)
payload
=
parse_job
(
job
)
payload
=
parse_job
(
job
)
payload
[
'job_status'
]
=
'deduplicated'
payload
[
'job_status'
]
=
'deduplicated'
payload
[
'message'
]
=
"
#{
base_message
(
payload
)
}
: deduplicated:
#{
deduplication_type
}
"
payload
[
'message'
]
=
"
#{
base_message
(
payload
)
}
: deduplicated:
#{
deduplication_type
}
"
payload
[
'deduplication_type'
]
=
deduplication_type
payload
[
'deduplication.type'
]
=
deduplication_type
# removing nil values from deduplication options
payload
.
merge!
(
deduplication_options
.
compact
.
transform_keys
{
|
k
|
"deduplication.options.
#{
k
}
"
})
Sidekiq
.
logger
.
info
payload
Sidekiq
.
logger
.
info
payload
end
end
...
...
lib/gitlab/sidekiq_middleware/duplicate_jobs/strategies/until_executing.rb
View file @
edc3ccee
...
@@ -17,7 +17,8 @@ module Gitlab
...
@@ -17,7 +17,8 @@ module Gitlab
job
[
'duplicate-of'
]
=
duplicate_job
.
existing_jid
job
[
'duplicate-of'
]
=
duplicate_job
.
existing_jid
if
duplicate_job
.
droppable?
if
duplicate_job
.
droppable?
Gitlab
::
SidekiqLogging
::
DeduplicationLogger
.
instance
.
log
(
job
,
"dropped until executing"
)
Gitlab
::
SidekiqLogging
::
DeduplicationLogger
.
instance
.
log
(
job
,
"dropped until executing"
,
duplicate_job
.
options
)
return
false
return
false
end
end
end
end
...
...
spec/lib/gitlab/sidekiq_logging/deduplication_logger_spec.rb
View file @
edc3ccee
...
@@ -18,11 +18,12 @@ RSpec.describe Gitlab::SidekiqLogging::DeduplicationLogger do
...
@@ -18,11 +18,12 @@ RSpec.describe Gitlab::SidekiqLogging::DeduplicationLogger do
expected_payload
=
{
expected_payload
=
{
'job_status'
=>
'deduplicated'
,
'job_status'
=>
'deduplicated'
,
'message'
=>
"
#{
job
[
'class'
]
}
JID-
#{
job
[
'jid'
]
}
: deduplicated: a fancy strategy"
,
'message'
=>
"
#{
job
[
'class'
]
}
JID-
#{
job
[
'jid'
]
}
: deduplicated: a fancy strategy"
,
'deduplication_type'
=>
'a fancy strategy'
'deduplication.type'
=>
'a fancy strategy'
,
'deduplication.options.foo'
=>
:bar
}
}
expect
(
Sidekiq
.
logger
).
to
receive
(
:info
).
with
(
a_hash_including
(
expected_payload
)).
and_call_original
expect
(
Sidekiq
.
logger
).
to
receive
(
:info
).
with
(
a_hash_including
(
expected_payload
)).
and_call_original
described_class
.
instance
.
log
(
job
,
"a fancy strategy"
)
described_class
.
instance
.
log
(
job
,
"a fancy strategy"
,
{
foo: :bar
}
)
end
end
it
"does not modify the job"
do
it
"does not modify the job"
do
...
...
spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/strategies/until_executing_spec.rb
View file @
edc3ccee
...
@@ -40,6 +40,7 @@ RSpec.describe Gitlab::SidekiqMiddleware::DuplicateJobs::Strategies::UntilExecut
...
@@ -40,6 +40,7 @@ RSpec.describe Gitlab::SidekiqMiddleware::DuplicateJobs::Strategies::UntilExecut
allow
(
fake_duplicate_job
).
to
receive
(
:scheduled?
).
and_return
(
false
)
allow
(
fake_duplicate_job
).
to
receive
(
:scheduled?
).
and_return
(
false
)
allow
(
fake_duplicate_job
).
to
receive
(
:check!
).
and_return
(
'the jid'
)
allow
(
fake_duplicate_job
).
to
receive
(
:check!
).
and_return
(
'the jid'
)
allow
(
fake_duplicate_job
).
to
receive
(
:droppable?
).
and_return
(
true
)
allow
(
fake_duplicate_job
).
to
receive
(
:droppable?
).
and_return
(
true
)
allow
(
fake_duplicate_job
).
to
receive
(
:options
).
and_return
({})
job_hash
=
{}
job_hash
=
{}
expect
(
fake_duplicate_job
).
to
receive
(
:duplicate?
).
and_return
(
true
)
expect
(
fake_duplicate_job
).
to
receive
(
:duplicate?
).
and_return
(
true
)
...
@@ -102,6 +103,7 @@ RSpec.describe Gitlab::SidekiqMiddleware::DuplicateJobs::Strategies::UntilExecut
...
@@ -102,6 +103,7 @@ RSpec.describe Gitlab::SidekiqMiddleware::DuplicateJobs::Strategies::UntilExecut
allow
(
fake_duplicate_job
).
to
receive
(
:scheduled?
).
and_return
(
false
)
allow
(
fake_duplicate_job
).
to
receive
(
:scheduled?
).
and_return
(
false
)
allow
(
fake_duplicate_job
).
to
receive
(
:check!
).
and_return
(
'the jid'
)
allow
(
fake_duplicate_job
).
to
receive
(
:check!
).
and_return
(
'the jid'
)
allow
(
fake_duplicate_job
).
to
receive
(
:duplicate?
).
and_return
(
true
)
allow
(
fake_duplicate_job
).
to
receive
(
:duplicate?
).
and_return
(
true
)
allow
(
fake_duplicate_job
).
to
receive
(
:options
).
and_return
({})
allow
(
fake_duplicate_job
).
to
receive
(
:existing_jid
).
and_return
(
'the jid'
)
allow
(
fake_duplicate_job
).
to
receive
(
:existing_jid
).
and_return
(
'the jid'
)
allow
(
fake_duplicate_job
).
to
receive
(
:droppable?
).
and_return
(
true
)
allow
(
fake_duplicate_job
).
to
receive
(
:droppable?
).
and_return
(
true
)
end
end
...
@@ -119,7 +121,17 @@ RSpec.describe Gitlab::SidekiqMiddleware::DuplicateJobs::Strategies::UntilExecut
...
@@ -119,7 +121,17 @@ RSpec.describe Gitlab::SidekiqMiddleware::DuplicateJobs::Strategies::UntilExecut
fake_logger
=
instance_double
(
Gitlab
::
SidekiqLogging
::
DeduplicationLogger
)
fake_logger
=
instance_double
(
Gitlab
::
SidekiqLogging
::
DeduplicationLogger
)
expect
(
Gitlab
::
SidekiqLogging
::
DeduplicationLogger
).
to
receive
(
:instance
).
and_return
(
fake_logger
)
expect
(
Gitlab
::
SidekiqLogging
::
DeduplicationLogger
).
to
receive
(
:instance
).
and_return
(
fake_logger
)
expect
(
fake_logger
).
to
receive
(
:log
).
with
(
a_hash_including
({
'jid'
=>
'new jid'
}),
'dropped until executing'
)
expect
(
fake_logger
).
to
receive
(
:log
).
with
(
a_hash_including
({
'jid'
=>
'new jid'
}),
'dropped until executing'
,
{})
strategy
.
schedule
({
'jid'
=>
'new jid'
})
{}
end
it
'logs the deduplication options of the worker'
do
fake_logger
=
instance_double
(
Gitlab
::
SidekiqLogging
::
DeduplicationLogger
)
expect
(
Gitlab
::
SidekiqLogging
::
DeduplicationLogger
).
to
receive
(
:instance
).
and_return
(
fake_logger
)
allow
(
fake_duplicate_job
).
to
receive
(
:options
).
and_return
({
foo: :bar
})
expect
(
fake_logger
).
to
receive
(
:log
).
with
(
a_hash_including
({
'jid'
=>
'new jid'
}),
'dropped until executing'
,
{
foo: :bar
})
strategy
.
schedule
({
'jid'
=>
'new jid'
})
{}
strategy
.
schedule
({
'jid'
=>
'new jid'
})
{}
end
end
...
...
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