Class: Puppet::SSL::StateMachine::NeedLock Private

Inherits:
SSLState show all
Defined in:
lib/puppet/ssl/state_machine.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Acquire the ssl lock or return LockFailure causing us to exit.

Instance Attribute Summary

Attributes inherited from SSLState

#ssl_context

Instance Method Summary collapse

Methods inherited from SSLState

#log_error, #to_error

Constructor Details

#initialize(machine) ⇒ NeedLock

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of NeedLock.



431
432
433
# File 'lib/puppet/ssl/state_machine.rb', line 431

def initialize(machine)
  super(machine, nil)
end

Instance Method Details

#next_stateObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# File 'lib/puppet/ssl/state_machine.rb', line 435

def next_state
  if @machine.lock
    # our ssl directory may have been cleaned while we were
    # sleeping, start over from the top
    NeedCACerts.new(@machine)
  elsif @machine.waitforlock < 1
    LockFailure.new(@machine, _("Another puppet instance is already running and the waitforlock setting is set to 0; exiting"))
  elsif Time.now.to_i >= @machine.waitlock_deadline
    LockFailure.new(@machine, _("Another puppet instance is already running and the maxwaitforlock timeout has been exceeded; exiting"))
  else
    Puppet.info _("Another puppet instance is already running; waiting for it to finish")
    Puppet.info _("Will try again in %{time} seconds.") % {time: @machine.waitforlock}
    Kernel.sleep @machine.waitforlock

    # try again
    self
  end
end