[PUP-9691] Puppet pidlock incorrectly clears lock when running under bundler Created: 2019/05/03  Updated: 2019/07/02  Resolved: 2019/06/18

Status: Closed
Project: Puppet
Component/s: None
Affects Version/s: None
Fix Version/s: PUP 5.5.16, PUP 6.0.10, PUP 6.4.3, PUP 6.6.0

Type: Task Priority: Normal
Reporter: Josh Cooper Assignee: Oana Tanasoiu
Resolution: Fixed Votes: 0
Labels: resolved-issue-added
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Blocks
blocks PA-2669 Lockfile prevents Puppet runs if it i... Resolved
Relates
relates to PUP-9247 Puppet pidlock checks only look for P... Closed
Template:
Epic Link: Agent Locking
Team: Night's Watch
Sprint: PR - 2019-05-29, PR - 2019-06-12, PR - 2019-06-25
Release Notes: Bug Fix
Release Notes Summary: If a Puppet run is killed the lockfile remains containing the PID that was previously being used for the process. If another process starts and uses this PID, the Puppet agent will fail. Fix: puppet will check that the PID belongs to puppet in order to lock the PID correctly. This fix works for Puppet even if it runs as a gem.
QA Risk Assessment: Needs Assessment

 Description   

When running puppet in bundler, puppet will take ownership of its pidfile even if another puppet process is still running. It's because ps -p <pid> -o comm= returns the entire command line instead of just the process name:

$ ps -p 33239 -o comm=
/Users/josh/work/puppet/.bundle/ruby/2.5.0/bin/puppet agent --no-daemonize --runinterval 15s --certname wtf18 -v

The behavior seems to be ruby or platform specific. On redhat with ruby 2.3:

root@k1zm807wxji34df:~# ps -p 17196 -o comm=
ruby2.3
root@k1zm807wxji34df:~# ps -p 17196 -o args=
ruby2.3 /root/puppet/.bundle/ruby/2.3.0/bin/puppet agent --no-daemonize -v

When running puppet from a package, the process name is just puppet

[root@dp4uykbg81px49u ~]# ps -p `cat /var/run/puppetlabs/agent.pid` -o comm=
puppet

This regression was introduced in PUP-9247.



 Comments   
Comment by Josh Cooper [ 2019/06/11 ]

Merged to 5.5.x in https://github.com/puppetlabs/puppet/commi/3eda57c2d5a51de86e8eac387f9f57835cdd6211

Generated at Mon Sep 23 07:02:06 PDT 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.