BryanDavis has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/400116 )

Change subject: apt: better support for `apt-get update` refresh
......................................................................

apt: better support for `apt-get update` refresh

We have 3 use cases for running `apt-get update`:
* Run on initial provision before any packages are installed
* Run on `vagrant provision` if it has not run in the last day
* Run on any `vagrant provision` where an apt::pin or apt::repository
  resource has newly been added to the Puppet object graph

The first two use cases have long been handled for us by using
a "schedule => daily" attribute on the Exec['apt-get update'] resource.
This has a flaw however in that the schedule attribute swallows refresh
events triggered by apt:pin and apt:repository if local state shows that
Exec['apt-get update'] is not already due to run. This causes annoying
issues for users who are adding new roles to existing VMs where new apt
repos or pinning are needed to successfully provision.

To support the 3rd use case while not breaking the first 2, this patch
makes the apt-get update triggers a bit more complex. A new
File['/etc/apt/.update'] resource is added which will notify
Exec['apt-get update'] for the first use case. A new Exec['Daily
apt-get update'] resource is added which uses a "schedule => 'daily'"
attribute to support the second use case. Finally the "schedule"
attribute is removed from the existing Exec['apt-get update'] resource
and a "refreshonly" attribute is added so that the previously ignored
notifications needed by the 3rd use case are properly handled.

Change-Id: I5a02476af18580966a5fe57797dfb13c5ba27b9c
---
M puppet/modules/apt/manifests/init.pp
1 file changed, 28 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant 
refs/changes/16/400116/1

diff --git a/puppet/modules/apt/manifests/init.pp 
b/puppet/modules/apt/manifests/init.pp
index 7932f24..092b570 100644
--- a/puppet/modules/apt/manifests/init.pp
+++ b/puppet/modules/apt/manifests/init.pp
@@ -5,11 +5,35 @@
 # supplementary sources.
 #
 class apt {
+    # Elaborate apt-get update trigger machanism ahead. We want apt-get update
+    # to be run on initial provision of a new VM (easy), once a day
+    # thereafter (not too hard with "schedule => daily"), AND any time that
+    # a new apt::pin or apt::repository define shows up in the Puppet graph.
+    # The first 2 can be handled simply via an Exec with the schedule 
attribure.
+    # That setup however keeps the 3rd use case from working as desired.
+    #
+    # The more complex replacement is a state file (/etc/apt/.update),
+    # a schedule=>daily exec to update that file, and a refreshonly
+    # Exec['apt-get update'] resource.
+    file { '/etc/apt/.update':
+        ensure  => 'present',
+        owner   => 'root',
+        group   => 'root',
+        mode    => '0444',
+        content => '',
+        replace => false,
+        notify  => Exec['apt-get update'],
+    }
+    exec { 'Daily apt-get update':
+        command  => '/bin/date > /etc/apt/.update',
+        schedule => 'daily',
+    }
     exec { 'apt-get update':
-        command  => '/usr/bin/apt-get update',
-        schedule => daily,
-        timeout  => 240,
-        returns  => [ 0, 100 ],
+        command     => '/usr/bin/apt-get update',
+        timeout     => 240,
+        returns     => [ 0, 100 ],
+        refreshonly => true,
+        subscribe   => File['/etc/apt/.update'],
     }
 
     # Directory used to store keys added with apt::repository

-- 
To view, visit https://gerrit.wikimedia.org/r/400116
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5a02476af18580966a5fe57797dfb13c5ba27b9c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: stretch-migration
Gerrit-Owner: BryanDavis <bda...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to