microsoft / microsoft/AzureTRE
Custom Linux VM images broken by changes to apt_sku in locals.tf
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 235
- Forks
- 192
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 13
Description
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
- Define custom images in your TRE
- Attempt to boot a custom Linux VM
- 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/terraform/locals.tf and vm_config.sh. Trace how custom images produce apt_sku and how the generated APT sources are used during VM boot. Done means a custom Linux image boots successfully and its APT sources use the image's VERSION_ID when apt_sku is unavailable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, shell, terraform
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100