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

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

Overview

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

#to_error

Constructor Details

#initialize(machine) ⇒ NeedLock

Returns a new instance of NeedLock.



295
296
297
# File 'lib/puppet/ssl/state_machine.rb', line 295

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

Instance Method Details

#next_stateObject



299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/puppet/ssl/state_machine.rb', line 299

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