Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Remove sync-asset-manager-from-master cron job from asset slaves
Browse files Browse the repository at this point in the history
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]:
d9cf0ee
[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]: alphagov/asset-manager#373
[5]:
https://github.com/alphagov/asset-manager/blob/d803db930614a6063c0fc16730f6ba3eaf08e6d9/lib/tasks/govuk_assets.rake#L5
  • Loading branch information
floehopper committed Jan 4, 2018
1 parent 19837b4 commit 153ca36
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions modules/govuk/manifests/node/s_asset_slave.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 153ca36

Please sign in to comment.