aboutsummaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/backends/terraform_aws/backend_methods.rb22
-rw-r--r--app/models/backends/terraform_aws/mini_environment_methods.rb4
-rw-r--r--app/models/backends/terraform_libvirt/backend_methods.rb20
-rw-r--r--app/models/backends/terraform_libvirt/mini_environment_methods.rb4
4 files changed, 48 insertions, 2 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"
diff --git a/app/models/backends/terraform_aws/mini_environment_methods.rb b/app/models/backends/terraform_aws/mini_environment_methods.rb
index d0a8ab5..63efcd7 100644
--- a/app/models/backends/terraform_aws/mini_environment_methods.rb
+++ b/app/models/backends/terraform_aws/mini_environment_methods.rb
@@ -22,7 +22,7 @@ module Backends::TerraformAws::MiniEnvironmentMethods
def build(mini_environment)
slug = mini_environment.name.parameterize
- GovukGuix::BuildMiniEnvironment.build(
+ store_path = GovukGuix::BuildMiniEnvironment.build(
mini_environment.id,
services: mini_environment.services.map(&:build_argument_string),
arguments: {
@@ -44,6 +44,8 @@ module Backends::TerraformAws::MiniEnvironmentMethods
},
run_remotely_on_host: mini_environment.backend.build_remote_host
)
+
+ add_in_use_store_path(store_path)
end
def start(mini_environment)
diff --git a/app/models/backends/terraform_libvirt/backend_methods.rb b/app/models/backends/terraform_libvirt/backend_methods.rb
index d14affa..85cd427 100644
--- a/app/models/backends/terraform_libvirt/backend_methods.rb
+++ b/app/models/backends/terraform_libvirt/backend_methods.rb
@@ -54,6 +54,26 @@ module Backends::TerraformLibvirt::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
+ )
+ end
+
+ def add_in_use_store_path(store_path)
+ GovukGuix::UpdateGcrootsDirectory.add_store_path(
+ store_path
+ )
+ end
+
def within_backend_terraform_working_directory(&block)
with_advisory_lock(
"terraform"
diff --git a/app/models/backends/terraform_libvirt/mini_environment_methods.rb b/app/models/backends/terraform_libvirt/mini_environment_methods.rb
index ef2b4c1..582aebb 100644
--- a/app/models/backends/terraform_libvirt/mini_environment_methods.rb
+++ b/app/models/backends/terraform_libvirt/mini_environment_methods.rb
@@ -22,7 +22,7 @@ module Backends::TerraformLibvirt::MiniEnvironmentMethods
def build(mini_environment)
slug = mini_environment.name.parameterize
- GovukGuix::BuildMiniEnvironment.build(
+ store_path = GovukGuix::BuildMiniEnvironment.build(
mini_environment.id,
services: mini_environment.services.map(&:build_argument_string),
arguments: {
@@ -41,6 +41,8 @@ module Backends::TerraformLibvirt::MiniEnvironmentMethods
data_snapshot: mini_environment.data_snapshot.try(:store_path)
}.compact
)
+
+ add_in_use_store_path(store_path)
end
def start(mini_environment)