From 153ca365aee150339ef6eb1fbc2300ff81994c25 Mon Sep 17 00:00:00 2001 From: James Mead Date: Thu, 4 Jan 2018 11:31:13 +0000 Subject: [PATCH] Remove sync-asset-manager-from-master cron job from asset slaves This cron job runs every 10 mins on each of the asset slaves copying Asset Manager (not Whitehall) asset files from the asset master using rsync via an NFS mount of the latter's /mnt/uploads directory. As far as I can tell from this commit [1] this cron job was added to solve a problem with environment syncing. However, environment syncing of Asset Manager assets is now taken care of by syncing of S3 buckets by the assets.sh job [2] rather than by rsync-ing of directories by the attachments.sh job [3]. Since this change [4] to Asset Manager the files for new assets are deleted from the filesystem once they have been virus scanned and uploaded to S3. Thus the Asset Manager app should no longer be permanently adding asset files to the filesystem and there's no need to have this sync in place. We're about to delete the files for Asset Manager assets which have been uploaded to S3 i.e. the vast majority of them. We plan to use this Asset Manager Rake task [5] to delete the files via the Carrierwave uploader mounted on Asset#file. This will delete the underlying file from the uploads directory under the Rails root directory which is sym-linked to /data/uploads/asset-manager. The latter is where the asset-master /mnt/uploads directory is mounted using NFS. If we were to leave the sync-asset-manager-from-master cron job in place, its rsync command would have to handle the sudden deletion of tens of thousands of file which might put undue load on the asset slaves and/or their NFS mounts. Since Asset Manager is no longer permanently adding asset files to the filesystem, we can safely remove this cron job and avoid the problem mentioned above. Another advantage of doing this is that we will effectively retain a backup of the Asset Manager asset files on the asset slaves in case deleting them causes an unforseen problem. We can delete the files from the slaves once we're happy that everything is working OK. We could probably also remove the /data/master-uploads NFS mount in this commit, but I think it's safer to apply that change separately later. Note that we'll be able to reove the cron job definition entirely once the changes in this commit have been applied in all environments. [1]: https://github.com/alphagov/govuk-puppet/commit/d9cf0eecd5190107618dec544fc2ea065b0aea7a [2]: https://github.com/alphagov/env-sync-and-backup/blob/169cb5846567f12030568c842e1ffe7630ca07fe/jobs/assets.sh [3]: https://github.com/alphagov/env-sync-and-backup/blob/169cb5846567f12030568c842e1ffe7630ca07fe/jobs/attachments.sh [4]: https://github.com/alphagov/asset-manager/pull/373 [5]: https://github.com/alphagov/asset-manager/blob/d803db930614a6063c0fc16730f6ba3eaf08e6d9/lib/tasks/govuk_assets.rake#L5 --- modules/govuk/manifests/node/s_asset_slave.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/govuk/manifests/node/s_asset_slave.pp b/modules/govuk/manifests/node/s_asset_slave.pp index c3ec32faf3..fd2d9fd500 100644 --- a/modules/govuk/manifests/node/s_asset_slave.pp +++ b/modules/govuk/manifests/node/s_asset_slave.pp @@ -42,6 +42,7 @@ } cron { 'sync-asset-manager-from-master': + ensure => 'absent', user => 'assets', minute => '*/10', command => '/usr/bin/setlock -n /var/tmp/asset-manager.lock /usr/bin/rsync -a --delete /data/master-uploads/asset-manager/ /mnt/uploads/asset-manager',