For yesterday's atomic deployment discussion, ther...
# puppet
c
For yesterday's atomic deployment discussion, there is still a race condition with the method of: 1. Change the symlink. 2. Clear the environment cache. The race condition happens when a manifest specifies a file to be retrieved via
source => puppet:///modules/
. https://www.puppet.com/docs/puppet/7/types/file.html#file-attribute-source This is because the agent requests such files asynchronously some time after the catalog has been compiled. A demonstration of this is to use code like:
Copy code
# This gives time for demonstrating the race condition. Imagine that in a real
# scenario, puppet would be doing some other "real" things that take time.
exec { 'sleep':
    command => ['/bin/sleep', '10'],
}

file { "/tmp/foo":
    source => 'puppet:///modules/puppet/foo',
    require => Exec['sleep'],
}
Also create a file at
modules/puppet/files/foo
. Then prepare a new codebase which has the source as
'puppet:///modules/puppet/bar'
and also renames the file to
modules/puppet/files/bar
, accordingly. Prepare a command to atomically replace the environment symlink and do a cache clear. Start a puppet run, and wait for the agent to start applying the catalog. Then run the command to atomically replace the environment symlink and do a cache clear. This will result in the agent receiving a 404 because the catalog it received specified the old file path. Even if the codebase used for catalog compilation can be changed atomically via a symlink, that is not enough to ensure that an agent gets a consistent run. I suspect a similar problem can happen if the environment symlink is replaced during the pluginsync phase or between the pluginsync and catalog compilation. I have not tested that, though.