Jira (PUP-5609) Puppet apply doesn't protect shared files with a lock

10 views
Skip to first unread message

Erik Dalén (JIRA)

unread,
Dec 14, 2015, 3:17:05 PM12/14/15
to puppe...@googlegroups.com
Erik Dalén created an issue
 
Puppet / Bug PUP-5609
Puppet apply doesn't protect shared files with a lock
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2015/12/14 12:16 PM
Priority: Normal Normal
Reporter: Erik Dalén

Puppet apply should use a filesystem lock just like agent to protect shared state files from simultaneous writes (it actually writes to the same state files as agent even).

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc)
Atlassian logo

Henrik Lindberg (JIRA)

unread,
Dec 15, 2015, 1:40:04 PM12/15/15
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
Change By: Henrik Lindberg
Scrum Team: Client Platform

Michael Smith (JIRA)

unread,
Jan 19, 2016, 2:40:03 PM1/19/16
to puppe...@googlegroups.com
Michael Smith updated an issue
Change By: Michael Smith
Sprint: Client 2016-02-10

Michael Smith (JIRA)

unread,
Jan 19, 2016, 7:14:03 PM1/19/16
to puppe...@googlegroups.com
Michael Smith commented on Bug PUP-5609
 
Re: Puppet apply doesn't protect shared files with a lock

Hit a snag in acceptance tests. The tests/resource/service/puppet_mcollective_service_management.rb test bumps into an issue with the lockfile.

Failed Tests Cases:
Errored Tests Cases:
  Test Case tests/resource/service/puppet_mcollective_service_management.rb reported: #<Beaker::Host::CommandFailure: Host 'i51djgc66a34vp6.delivery.puppetlabs.net' exited with 1 running:
 puppet apply --detailed-exitcodes --verbose
Last 10 lines of output were:
	Error: Could not run: undefined local variable or method `client_class' for #<Puppet::Application::Apply:0x00000003014ca0>>

client_class isn't defined, so that needs to be fixed. But it shouldn't have hit that exception in the first place.

Michael Smith (JIRA)

unread,
Jan 19, 2016, 7:16:04 PM1/19/16
to puppe...@googlegroups.com

Michael Smith (JIRA)

unread,
Jan 20, 2016, 6:01:06 PM1/20/16
to puppe...@googlegroups.com
Michael Smith assigned an issue to Unassigned

Michael Smith (JIRA)

unread,
Jan 20, 2016, 6:01:15 PM1/20/16
to puppe...@googlegroups.com
Michael Smith updated an issue
Change By: Michael Smith
Sprint: Client  2016-02-10  Triage

Josh Cooper (JIRA)

unread,
Feb 3, 2016, 6:32:03 PM2/3/16
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Client  Community  Triage

Josh Cooper (JIRA)

unread,
Mar 8, 2016, 1:38:04 PM3/8/16
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-5609
 
Re: Puppet apply doesn't protect shared files with a lock

I think we're running into bugs in the file locking code itself (as opposed to the PR that Erik submitted). In particular PUP-2515 and https://projects.puppetlabs.com/issues/21705#note-2.

Eric Sorenson (JIRA)

unread,
Jun 22, 2016, 1:02:11 PM6/22/16
to puppe...@googlegroups.com
Eric Sorenson updated an issue
 
Change By: Eric Sorenson
Sprint: Client Community Triage
This message was sent by Atlassian JIRA (v6.4.13#64028-sha1:b7939e9)
Atlassian logo

Eric Sorenson (JIRA)

unread,
Jun 22, 2016, 1:02:14 PM6/22/16
to puppe...@googlegroups.com

David Kramer (JIRA)

unread,
Aug 17, 2016, 12:31:03 PM8/17/16
to puppe...@googlegroups.com
David Kramer updated an issue
Change By: David Kramer
Sprint: i18n Client Triage

Kenn Hussey (JIRA)

unread,
Sep 29, 2016, 2:59:08 PM9/29/16
to puppe...@googlegroups.com
Kenn Hussey updated an issue
Change By: Kenn Hussey
Sprint: Client Triage
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Philipp Gassmann (JIRA)

unread,
Feb 7, 2017, 9:16:02 AM2/7/17
to puppe...@googlegroups.com
Philipp Gassmann commented on Bug PUP-5609
 
Re: Puppet apply doesn't protect shared files with a lock

the apply process should check and set the same lock files as the agent. With --statedir /tmp/foo it should be possible to run it anyways.

We now use the following workaround with hardcoded paths:

  mkdir -p $environment # Puppet 4 requires an environment directory
  # check puppet agent disable lock file
  [ -f /opt/puppetlabs/puppet/cache/state/agent_disabled.lock ] && (
    echo 'Puppet agent disabled - skipping' >&2;
    cat /opt/puppetlabs/puppet/cache/state/agent_disabled.lock >&2; echo >&2;
    exit 1
  )
  # check and set lockfile for puppet apply
  (
    flock -n 9 || ( echo 'Puppet agent lock file exist - skipping' >&2; exit 1 )
    puppet apply \
      --test \
      --show_diff \
      --write-catalog-summary \
      --modulepath=modules:site \
      --hiera_config=hiera.yaml \
      --environmentpath=. \
      --environment $environment \
      manifests/site.pp "$@"
  ) 9>/opt/puppetlabs/puppet/cache/state/agent_catalog_run.lock

Michael Smith (JIRA)

unread,
Feb 9, 2017, 12:01:04 PM2/9/17
to puppe...@googlegroups.com

Erik Dalén (JIRA)

unread,
Feb 10, 2017, 6:51:03 AM2/10/17
to puppe...@googlegroups.com
Erik Dalén commented on Bug PUP-5609
 
Re: Puppet apply doesn't protect shared files with a lock

I rebased my PR for this against the master branch: https://github.com/puppetlabs/puppet/pull/4584

So, there is a fix for this waiting for merge

Michael Smith (JIRA)

unread,
Feb 10, 2017, 4:25:02 PM2/10/17
to puppe...@googlegroups.com

Michael Smith (JIRA)

unread,
Feb 10, 2017, 4:26:02 PM2/10/17
to puppe...@googlegroups.com

Michael Smith (JIRA)

unread,
Feb 13, 2017, 4:14:03 PM2/13/17
to puppe...@googlegroups.com
Michael Smith updated an issue
Change By: Michael Smith
Fix Version/s: PUP 5.0.0

Michael Smith (JIRA)

unread,
Feb 13, 2017, 7:43:02 PM2/13/17
to puppe...@googlegroups.com

Michael Smith (JIRA)

unread,
Feb 13, 2017, 10:50:02 PM2/13/17
to puppe...@googlegroups.com
Michael Smith updated an issue
Change By: Michael Smith
Release Notes Summary: Puppet apply now creates a lock file, as puppet agent does. This prevents simultaneously writing shared state files, as could happen if a puppet agent and puppet apply run occurred simultaneously.
Release Notes: Bug Fix

Michael Smith (JIRA)

unread,
Feb 13, 2017, 10:52:02 PM2/13/17
to puppe...@googlegroups.com
Michael Smith commented on Bug PUP-5609
 
Re: Puppet apply doesn't protect shared files with a lock

Thanks Erik Dalén! I'm going to assume we cleaned up some tests that were misbehaving and that's allowed the patch to go through.

Thomas Mueller (JIRA)

unread,
Feb 14, 2017, 1:15:06 AM2/14/17
to puppe...@googlegroups.com

I'm using puppet apply in parallel to manage different nfs homedirectory roots with many users.

Sounds like now agent_disabled_lockfile and agent_catalog_run_lockfile need to be set to achieve a parallel run. Might be good to have release notes about this.

Michael Smith (JIRA)

unread,
Feb 14, 2017, 12:49:03 PM2/14/17
to puppe...@googlegroups.com
Michael Smith updated an issue
Change By: Michael Smith
Release Notes Summary:
Puppet apply now creates a lock file, as puppet agent does. This prevents simultaneously writing shared state files, as could happen if a puppet agent and puppet apply run occurred simultaneously.


If you have a need to run multiple apply runs simultaneously, you can continue to do so by setting by configuring each run with a distinct {{statedir}}.

Michael Smith (JIRA)

unread,
Feb 14, 2017, 12:49:04 PM2/14/17
to puppe...@googlegroups.com
Michael Smith commented on Bug PUP-5609
 
Re: Puppet apply doesn't protect shared files with a lock

The recommended approach would actually be to use a distinct statedir for each run. I've added that to the release notes.

Josh Cooper (JIRA)

unread,
Mar 6, 2017, 7:06:02 PM3/6/17
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-5609

I reopened this, because it's been causing problems in CI. Our tests often use puppet apply to manage the puppet service. If the agent is daemonized and is applying a catalog in the background, then calling puppet apply to stop the service will fail with:

[root@o3nvm9xl80j4opo ~]# puppet apply -e "service { 'puppet': ensure => stopped }"
Notice: Run of Puppet already in progress; skipping  (/opt/puppetlabs/puppet/cache/state/agent_catalog_run.lock exists)

We could change the tests to specify a unique statedir, most likely via the apply_manifest_on beaker helper, but that is going to take some work. Reopening this until we have a chance to do that (as it affects opensource, PE, and modules pipelines).

Geoff Nichols (JIRA)

unread,
Apr 4, 2017, 12:58:03 AM4/4/17
to puppe...@googlegroups.com

Kenn Hussey (JIRA)

unread,
Apr 10, 2017, 10:21:02 AM4/10/17
to puppe...@googlegroups.com

Geoff Nichols (JIRA)

unread,
Apr 12, 2017, 12:21:02 PM4/12/17
to puppe...@googlegroups.com
Geoff Nichols updated an issue
Change By: Geoff Nichols
Sprint: Agent Grooming  On-Deck

Geoff Nichols (JIRA)

unread,
Apr 12, 2017, 2:18:03 PM4/12/17
to puppe...@googlegroups.com
Geoff Nichols updated an issue
Change By: Geoff Nichols
Fix Version/s: PUP 5.0.0
Fix Version/s: PUP 5.y

Geoff Nichols (JIRA)

unread,
Apr 12, 2017, 2:19:37 PM4/12/17
to puppe...@googlegroups.com
Geoff Nichols updated an issue
Change By: Geoff Nichols
Sprint: Agent Grooming On-Deck

Henrik Lindberg (JIRA)

unread,
May 16, 2017, 3:39:02 PM5/16/17
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
Change By: Henrik Lindberg
Labels: maintenance triaged

Josh Cooper (JIRA)

unread,
Mar 16, 2018, 2:38:03 PM3/16/18
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sub-team: Coremunity
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Josh Cooper (JIRA)

unread,
Mar 16, 2018, 2:40:03 PM3/16/18
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Fix Version/s: PUP 5.y

Josh Cooper (Jira)

unread,
Mar 13, 2020, 6:14:03 PM3/13/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Team: Coremunity Night's Watch
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Bogdan Irimie (Jira)

unread,
Nov 5, 2020, 3:51:05 AM11/5/20
to puppe...@googlegroups.com

Bogdan Irimie (Jira)

unread,
Nov 5, 2020, 3:52:04 AM11/5/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Sprint: ready for triage

Josh Cooper (Jira)

unread,
May 3, 2021, 2:02:03 PM5/3/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Epic Link: PUP-7532
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Ciprian Badescu (Jira)

unread,
Jun 22, 2021, 4:55:01 AM6/22/21
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages