Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Linux VM images broken by changes to apt_sku in locals.tf #4282

Open
TonyWildish-BH opened this issue Jan 23, 2025 · 0 comments
Open
Labels
bug Something isn't working

Comments

@TonyWildish-BH
Copy link
Contributor

Describe the bug
locals.tf calculates apt_sku with a dynamic lookup from the selected image. The configuration for custom images provides no mechanism for passing a value for this. Attempting to boot custom images therefore fails before terraform manages to do anything.

Steps to reproduce

  1. Define custom images in your TRE
  2. Attempt to boot a custom Linux VM
  3. Wait for the failure message referring to apt_sku

In the past, there was a line checking to see if apt_sku was defined on the selected image, and substituting unknown_sku if it wasn't. Restoring this line resolves the terraform problem, and the machine will boot:

vscode ➜ .../guacamole/user_resources/guacamole-azure-linuxvm/terraform (main) $ git diff locals.tf
diff --git a/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/terraform/locals.tf b/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/terraform/locals.tf
index a7f326ef..72c98bfb 100644
--- a/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/terraform/locals.tf
+++ b/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/terraform/locals.tf
@@ -25,7 +25,8 @@ locals {
   # selected_image_source_refs is an array to enable easy use of a dynamic block
   selected_image_source_refs = lookup(local.selected_image, "source_image_reference", null) == null ? [] : [local.selected_image.source_image_reference]
   selected_image_source_id   = lookup(local.selected_image, "source_image_name", null) == null ? null : "${var.image_gallery_id}/images/${local.selected_image.source_image_name}"
-  apt_sku                    = local.selected_image_source_refs[0]["apt_sku"]
+  # apt_sku                    = local.selected_image_source_refs[0]["apt_sku"]
+  apt_sku = length(local.selected_image_source_refs) > 0 ? local.selected_image_source_refs[0]["apt_sku"] : "unknown_sku"
 
   cmk_name                 = "tre-encryption-${local.workspace_resource_name_suffix}"
   encryption_identity_name = "id-encryption-${var.tre_id}-${local.short_workspace_id}"

However, that leads to another problem. The value of apt_sku is used to configure Nexus to point to the correct Ubuntu repository, being instantiated by using apt-sources_config.yml as a template.

A robust way to fix this is to use the VERSION_ID from /etc/os-release at boot-time to correct the unknown_sku:

vscode ➜ .../guacamole/user_resources/guacamole-azure-linuxvm/terraform (main) $ git diff vm_config.sh
diff --git a/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/terraform/vm_config.sh b/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/terraform/vm_config.sh
index 1c1f918f..4a2da16e 100644
--- a/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/terraform/vm_config.sh
+++ b/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/terraform/vm_config.sh
@@ -9,6 +9,10 @@ set -o xtrace
 # Remove apt sources not included in sources.list file
 sudo rm -f /etc/apt/sources.list.d/*
 
+# Fix Ubuntu version in APT sources for custom images
+. /etc/os-release
+sed -i "s%unknown_sku%$VERSION_ID%" /etc/apt/sources.list
+
 # Update apt packages from configured Nexus sources
 echo "init_vm.sh: START"
 sudo apt update || true

Azure TRE release version (e.g. v0.14.0 or main):

Head as of middle of last week.

Deployed Azure TRE components - click the (i) in the UI:
UI Version: 0.6.3
API Version: 0.20.3

@TonyWildish-BH TonyWildish-BH added the bug Something isn't working label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant