Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-2573

Puppet::Agent::Locker#lock doesn't return whether it acquired the lock or not

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • None
    • PUP 4.3.0
    • Types and Providers
    • None
    • 1
    • Client 2015-07-22
    • Bug Fix
    • Hide
      The puppet agent uses a lock file to ensure that only one instance is running at a time. However, the agent was susceptible to a race condition that could cause two agents to try to acquire the lock at the same time, and have one of them fail with a generic "Could not run" error. Now the agent will atomically try to acquire the lock, and if that fails, log a meaningful error.
      Show
      The puppet agent uses a lock file to ensure that only one instance is running at a time. However, the agent was susceptible to a race condition that could cause two agents to try to acquire the lock at the same time, and have one of them fail with a generic "Could not run" error. Now the agent will atomically try to acquire the lock, and if that fails, log a meaningful error.

    Description

      The Puppet::Agent::Locker#lock method documentation says

      Return true/false depending on whether we get the lock.

      But that's not actually what happens. Instead it returns whatever the yielded block returns. As a result, there's no way to know if the lock was successfully acquired:

        def lock
          if lockfile.lock
            begin
              yield
            ensure
              lockfile.unlock
            end
          end
        end
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dalen Erik Dalén
              Narmadha Perumal Narmadha Perumal
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support

                  Time Tracking

                    Estimated:
                    Original Estimate - 0 minutes
                    0m
                    Remaining:
                    Remaining Estimate - 0 minutes
                    0m
                    Logged:
                    Time Spent - 5 minutes
                    5m