Commit 487fda4d authored by Lucas Charles's avatar Lucas Charles Committed by Ash McKenzie

Fix Ruby 2.7 deprecations

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/257438
parent a5032437
...@@ -105,7 +105,7 @@ module Ci ...@@ -105,7 +105,7 @@ module Ci
raise ArgumentError, 'Offset is out of range' if offset < 0 || offset > size raise ArgumentError, 'Offset is out of range' if offset < 0 || offset > size
raise ArgumentError, 'Chunk size overflow' if CHUNK_SIZE < (offset + new_data.bytesize) raise ArgumentError, 'Chunk size overflow' if CHUNK_SIZE < (offset + new_data.bytesize)
in_lock(*lock_params) { unsafe_append_data!(new_data, offset) } in_lock(lock_key, **lock_params) { unsafe_append_data!(new_data, offset) }
schedule_to_persist! if full? schedule_to_persist! if full?
end end
...@@ -151,7 +151,7 @@ module Ci ...@@ -151,7 +151,7 @@ module Ci
# acquired # acquired
# #
def persist_data! def persist_data!
in_lock(*lock_params) do # exclusive Redis lock is acquired first in_lock(lock_key, **lock_params) do # exclusive Redis lock is acquired first
raise FailedToPersistDataError, 'Modifed build trace chunk detected' if has_changes_to_save? raise FailedToPersistDataError, 'Modifed build trace chunk detected' if has_changes_to_save?
self.reset.then do |chunk| # we ensure having latest lock_version self.reset.then do |chunk| # we ensure having latest lock_version
...@@ -289,11 +289,16 @@ module Ci ...@@ -289,11 +289,16 @@ module Ci
build.trace_chunks.maximum(:chunk_index).to_i build.trace_chunks.maximum(:chunk_index).to_i
end end
def lock_key
"trace_write:#{build_id}:chunks:#{chunk_index}"
end
def lock_params def lock_params
["trace_write:#{build_id}:chunks:#{chunk_index}", {
{ ttl: WRITE_LOCK_TTL, ttl: WRITE_LOCK_TTL,
retries: WRITE_LOCK_RETRY, retries: WRITE_LOCK_RETRY,
sleep_sec: WRITE_LOCK_SLEEP }] sleep_sec: WRITE_LOCK_SLEEP
}
end end
def metrics def metrics
......
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