Fix WorkerDataConsistency cop offenses [RUN AS-IF-FOSS]
What does this MR do?
Fixes all cop offenses silenced in !65341 (merged) and removes the silence.
Semantically this is a no-op; setting data_consistency
to :always
had been the default previously. We are merely making this explicit in code, so as to encourage teams to always consider this setting during development, rather than it being tucked away in a yaml file.
This is somewhat different to a merely syntactical offense because domain knowledge is required to decide for each worker whether it is safe to use replicas or not, and it is not feasible for our team to make these decisions on behalf of others. Only for newly added workers we now enforce this decision to be made consciously.
More about worker data consistency here: https://docs.gitlab.com/ee/development/sidekiq_style_guide.html#job-data-consistency-strategies
I tried to catch all existing offenses by running the cop, then using a script to insert data_consistency :always
, which is semantically a no-op (as it's the default).
bin/bundle exec rubocop --parallel app/workers ee/app/workers | egrep -o '(ee/)?app/workers/[^:]+' | ./fix-cop-offenses.rb
script:
#!/usr/bin/env ruby
$stdin.each_line do |worker|
path = worker.strip
puts "Processing #{path}"
contents = IO.read(File.join(Dir.pwd, path))
new_contents =
contents.gsub(/^( +)include ApplicationWorker$/,
"\\1include ApplicationWorker\n\n" +
"\\1data_consistency :always")
IO.write(path, new_contents)
end
based on Sean's work in ab0f9788
Does this MR meet the acceptance criteria?
Conformity
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) - [-] I have tested this MR in all supported browsers, or it's not needed.
- [-] I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.
Closes #335170 (closed)