aboutsummaryrefslogtreecommitdiff
path: root/app/models/backends/terraform_aws/backend_methods.rb
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-12-31 18:22:12 +0000
committerChristopher Baines <mail@cbaines.net>2019-01-01 02:38:23 +0000
commit3459059ed1f9332a9e71a4a7be5dc5e22e7f6bae (patch)
tree477f63fbc4546ee2947f571b831fb9463e2025b2 /app/models/backends/terraform_aws/backend_methods.rb
parent3e78356904b610aa149dd2e2c30e832408f37acc (diff)
downloadgovuk-mini-environment-admin-3459059ed1f9332a9e71a4a7be5dc5e22e7f6bae.tar
govuk-mini-environment-admin-3459059ed1f9332a9e71a4a7be5dc5e22e7f6bae.tar.gz
Start tracking which store paths are in use
This will enable garbage collection of the Guix store, without removing things that are still in use.
Diffstat (limited to 'app/models/backends/terraform_aws/backend_methods.rb')
-rw-r--r--app/models/backends/terraform_aws/backend_methods.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/models/backends/terraform_aws/backend_methods.rb b/app/models/backends/terraform_aws/backend_methods.rb
index cc5ca62..d6665a1 100644
--- a/app/models/backends/terraform_aws/backend_methods.rb
+++ b/app/models/backends/terraform_aws/backend_methods.rb
@@ -80,6 +80,28 @@ module Backends::TerraformAws::BackendMethods
end
end
+ def in_use_store_paths
+ [
+ GovukGuix::Revision.pluck(:store_path),
+ available_data_snapshots.pluck(:store_path),
+ mini_environments.pluck(:backend_data).map { |x| x&.dig('build_output') }
+ ].flatten.compact
+ end
+
+ def update_guix_gcroots
+ GovukGuix::UpdateGcrootsDirectory.set_in_use_store_paths(
+ in_use_store_paths,
+ run_remotely_on_host: build_remote_host
+ )
+ end
+
+ def add_in_use_store_path(store_path)
+ GovukGuix::UpdateGcrootsDirectory.add_store_path(
+ store_path,
+ run_remotely_on_host: build_remote_host
+ )
+ end
+
def within_backend_terraform_working_directory(&block)
with_advisory_lock(
"terraform"