Class: CI::Queue::Redis::Supervisor
- Defined in:
- lib/ci/queue/redis/supervisor.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Base
Base::CONNECTION_ERRORS, Base::DEFAULT_TIMEOUT, Base::TEN_MINUTES
Constants included from Common
Instance Attribute Summary collapse
-
#time_left ⇒ Object
readonly
Returns the value of attribute time_left.
-
#time_left_with_no_workers ⇒ Object
readonly
Returns the value of attribute time_left_with_no_workers.
Attributes included from Common
Instance Method Summary collapse
Methods inherited from Base
#boot_heartbeat_process!, #created_at=, #custom_config, #custom_middlewares, #ensure_heartbeat_thread_alive!, #exhausted?, #expired?, #increment_test_failed, #initialize, #max_test_failed?, #progress, #queue_initialized?, #queue_initializing?, #reconnect_attempts, #remaining, #running, #size, #stop_heartbeat!, #streaming?, #test_failed, #test_ids, #to_a, #wait_for_master, #with_heartbeat, #workers_count
Methods included from Common
#distributed?, #flaky?, #release!, #report_failure!, #report_success!, #rescue_connection_errors, #retrying?
Constructor Details
This class inherits a constructor from CI::Queue::Redis::Base
Instance Attribute Details
#time_left ⇒ Object (readonly)
Returns the value of attribute time_left.
64 65 66 |
# File 'lib/ci/queue/redis/supervisor.rb', line 64 def time_left @time_left end |
#time_left_with_no_workers ⇒ Object (readonly)
Returns the value of attribute time_left_with_no_workers.
64 65 66 |
# File 'lib/ci/queue/redis/supervisor.rb', line 64 def time_left_with_no_workers @time_left_with_no_workers end |
Instance Method Details
#build ⇒ Object
16 17 18 |
# File 'lib/ci/queue/redis/supervisor.rb', line 16 def build @build ||= CI::Queue::Redis::BuildRecord.new(self, redis, config) end |
#master? ⇒ Boolean
7 8 9 |
# File 'lib/ci/queue/redis/supervisor.rb', line 7 def master? false end |
#total ⇒ Object
11 12 13 14 |
# File 'lib/ci/queue/redis/supervisor.rb', line 11 def total wait_for_master(timeout: config.queue_init_timeout, allow_streaming: true) redis.get(key('total')).to_i end |
#wait_for_workers ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ci/queue/redis/supervisor.rb', line 20 def wait_for_workers duration = measure do wait_for_master(timeout: config.queue_init_timeout, allow_streaming: true) end yield if block_given? @time_left = config.report_timeout - duration.to_i @time_left_with_no_workers = config.inactive_workers_timeout until exhausted? || @time_left <= 0 || max_test_failed? || @time_left_with_no_workers <= 0 @time_left -= 1 sleep 1 if active_workers? || streaming? @time_left_with_no_workers = config.inactive_workers_timeout else @time_left_with_no_workers -= 1 end yield if block_given? end # On retry runs (BUILDKITE_RETRY_COUNT > 0), the main queue is already # exhausted from the original run. A retry worker may have found unresolved # failures via the error-reports fallback and be running them via the Retry # queue — but those tests are NOT in the Redis running set so active_workers? # returns false and the loop above exits immediately. # # Wait up to inactive_workers_timeout for retry workers to clear error-reports. # This prevents the summary from canceling retry workers before they finish. if exhausted? && config.retry? && !rescue_connection_errors { build.failed_tests }.empty? @time_left_with_no_workers = config.inactive_workers_timeout until rescue_connection_errors { build.failed_tests }.empty? || @time_left_with_no_workers <= 0 sleep 1 @time_left_with_no_workers -= 1 end end exhausted? rescue CI::Queue::Redis::LostMaster false end |