Sha256: 5ca9b993bac4e31625af99b9c9e4bbd9a97270467413f32e7e92bfdb30a30f39

Contents?: true

Size: 1.44 KB

Versions: 25

Compression:

Stored size: 1.44 KB

Contents

# DelayedJob is a unique diagnostic that creates a series of delayed jobs
# in the hopes that enough nodes will touch these jobs to determine
# if delayed job workers are running the latest application version
#
# `DELAYED_VER` environment variable should be set in the
# delayed jobs initializer.
#
module Marty::Diagnostic; class DelayedJobVersion < Base
  self.aggregatable = false

  def self.generate
    raise 'DelayedJob cannot be called with local scope.' if scope == 'local'

    raise 'DELAYED_VER environment variable has not been initialized.' if
      ENV['DELAYED_VER'].nil?

    total_workers = Node.get_target_connections('delayed').count

    raise 'No delayed jobs are running.' if total_workers.zero?

    # we will only iterate by half of the total delayed workers to avoid
    # excess use of delayed job time
    total_workers = (total_workers / 2).zero? ? 1 : total_workers / 2

    d_engine = Marty::ScriptSet.new.get_engine('Diagnostics')
    res = d_engine.
            evaluate('VersionDelay', 'result', 'count' => total_workers - 1)

    # merge results, remove duplicates, and construct "aggregate" object
    res.each_with_object({}) do |r, hash|
      hash[r[0]] ||= []
      hash[r[0]] << r[1]
    end.map do |node, result|
      versions = result.uniq
      status = versions.count == 1 && versions[0] == ENV['DELAYED_VER']

      { node => { 'Version' => create_info(versions.join("\n"), status) } }
    end.reduce(:deep_merge)
  end
end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
marty-14.3.0 lib/marty/diagnostic/delayed_job_version.rb
marty-14.0.0 lib/marty/diagnostic/delayed_job_version.rb
marty-13.0.2 lib/marty/diagnostic/delayed_job_version.rb
marty-11.0.0 lib/marty/diagnostic/delayed_job_version.rb
marty-10.0.3 lib/marty/diagnostic/delayed_job_version.rb
marty-10.0.2 lib/marty/diagnostic/delayed_job_version.rb
marty-10.0.0 lib/marty/diagnostic/delayed_job_version.rb
marty-9.5.1 lib/marty/diagnostic/delayed_job_version.rb
marty-9.5.0 lib/marty/diagnostic/delayed_job_version.rb
marty-9.3.3 lib/marty/diagnostic/delayed_job_version.rb
marty-9.3.2 lib/marty/diagnostic/delayed_job_version.rb
marty-9.3.0 lib/marty/diagnostic/delayed_job_version.rb
marty-8.5.0 lib/marty/diagnostic/delayed_job_version.rb
marty-8.4.1 lib/marty/diagnostic/delayed_job_version.rb
marty-8.3.1 lib/marty/diagnostic/delayed_job_version.rb
marty-8.2.0 lib/marty/diagnostic/delayed_job_version.rb
marty-8.0.0 lib/marty/diagnostic/delayed_job_version.rb
marty-6.1.0 lib/marty/diagnostic/delayed_job_version.rb
marty-5.2.0 other/marty/diagnostic/delayed_job_version.rb
marty-5.1.4 other/marty/diagnostic/delayed_job_version.rb