From 1e7e061819ec7c9c33d8f2eb1db1145ec2b6081a Mon Sep 17 00:00:00 2001 From: Cade Jacobson Date: Thu, 16 Oct 2025 09:50:10 -0700 Subject: [PATCH 1/9] Attempt to link a shared kvp pool --- testinit/docker-compose.yml | 5 +++++ testinit/testing-server/docker-compose.yml | 11 +++++++++-- testinit/testing-server/wireserver_handler.py | 12 ++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/testinit/docker-compose.yml b/testinit/docker-compose.yml index 8461f8bf..051ea27c 100644 --- a/testinit/docker-compose.yml +++ b/testinit/docker-compose.yml @@ -11,6 +11,7 @@ services: volumes: - /sys/fs/cgroup:/sys/fs/cgroup:rw - /run/dbus/system_bus_socket:/run/dbus/system_bus_socket:rw + - /var/lib/hyperv/.kvp_pool_1 stdin_open: true tty: true container_name: azureinit-provisioning-agent @@ -22,6 +23,10 @@ services: - imds-network - wireserver-network +volumes: + kvp-pool: + + networks: imds-network: external: true diff --git a/testinit/testing-server/docker-compose.yml b/testinit/testing-server/docker-compose.yml index b037d627..d5b4da8e 100644 --- a/testinit/testing-server/docker-compose.yml +++ b/testinit/testing-server/docker-compose.yml @@ -10,18 +10,25 @@ services: - SYS_MODULE ports: - "80:80" + volumes: + - kvp-pool:/shared-kvp networks: imds-network: ipv4_address: 169.254.169.254 wireserver-network: ipv4_address: 168.63.129.16 healthcheck: - test: ["CMD", "curl", "-f", "-H", "Metadata: true", "http://localhost:80/metadata/instance?api-version=2021-02-01"] + test: [ "CMD", "curl", "-f", "-H", "Metadata: true", "http://localhost:80/metadata/instance?api-version=2021-02-01" ] interval: 30s timeout: 10s retries: 3 start_period: 40s +volumes: + kvp-pool: + external: true + name: testinit_kvp-pool + networks: imds-network: driver: bridge @@ -30,7 +37,7 @@ networks: config: - subnet: 169.254.0.0/16 gateway: 169.254.0.1 - + wireserver-network: driver: bridge name: wireserver-network diff --git a/testinit/testing-server/wireserver_handler.py b/testinit/testing-server/wireserver_handler.py index 1b30faa9..8ca09c13 100644 --- a/testinit/testing-server/wireserver_handler.py +++ b/testinit/testing-server/wireserver_handler.py @@ -1,6 +1,7 @@ from http.server import BaseHTTPRequestHandler import time import json +import os import xml.etree.ElementTree as ET from utils import logger @@ -54,6 +55,17 @@ def load_responses(cls): logger.info("Outputting loaded custom WireServer responses") logger.info(json.dumps(cls._responses, indent=2)) + def log_kvp_file(): + """Log the entire contents of the KVP pool file.""" + try: + with open("/shared-kvp/.kvp_pool_1", "r") as f: + content = f.read() + logger.info(f"KVP file contents: \n{content}") + except FileNotFoundError: + logger.error("KVP file not found at /shared-kvp/.kvp_pool_1") + except Exception as e: + logger.error(f"Error reading KVP file: {e}") + def write_custom_response(self): responses_list = self._responses From 6451b2f77358d82739f3dadb20f0227c75ae1204 Mon Sep 17 00:00:00 2001 From: Cade Jacobson Date: Thu, 16 Oct 2025 09:51:28 -0700 Subject: [PATCH 2/9] Call log function --- testinit/testing-server/wireserver_handler.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testinit/testing-server/wireserver_handler.py b/testinit/testing-server/wireserver_handler.py index 8ca09c13..4bfdf7a5 100644 --- a/testinit/testing-server/wireserver_handler.py +++ b/testinit/testing-server/wireserver_handler.py @@ -118,6 +118,8 @@ def do_POST(self): logger.info(f"WireServer POST request: {self.path}") logger.info(f"POST data: {post_data.decode('utf-8', errors='ignore')}") + self.log_kvp_file() + if self._responses is not None: self.write_custom_response() return From e5ad32c0fd2a322fe85f1c1e5809a7708a21e650 Mon Sep 17 00:00:00 2001 From: Cade Jacobson Date: Thu, 16 Oct 2025 10:26:45 -0700 Subject: [PATCH 3/9] Do not use external tag --- testinit/docker-compose.yml | 5 +++-- testinit/testing-server/docker-compose.yml | 7 +++---- testinit/testing-server/wireserver_handler.py | 17 ++++++++--------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/testinit/docker-compose.yml b/testinit/docker-compose.yml index 051ea27c..2ea22c5a 100644 --- a/testinit/docker-compose.yml +++ b/testinit/docker-compose.yml @@ -11,7 +11,8 @@ services: volumes: - /sys/fs/cgroup:/sys/fs/cgroup:rw - /run/dbus/system_bus_socket:/run/dbus/system_bus_socket:rw - - /var/lib/hyperv/.kvp_pool_1 + - kvp_data:/var/lib/hyperv # Add shared volume + stdin_open: true tty: true container_name: azureinit-provisioning-agent @@ -24,7 +25,7 @@ services: - wireserver-network volumes: - kvp-pool: + kvp_data: networks: diff --git a/testinit/testing-server/docker-compose.yml b/testinit/testing-server/docker-compose.yml index d5b4da8e..6d97a6d5 100644 --- a/testinit/testing-server/docker-compose.yml +++ b/testinit/testing-server/docker-compose.yml @@ -11,7 +11,7 @@ services: ports: - "80:80" volumes: - - kvp-pool:/shared-kvp + - kvp_data:/var/lib/hyperv networks: imds-network: ipv4_address: 169.254.169.254 @@ -25,9 +25,8 @@ services: start_period: 40s volumes: - kvp-pool: - external: true - name: testinit_kvp-pool + kvp_data: + networks: imds-network: diff --git a/testinit/testing-server/wireserver_handler.py b/testinit/testing-server/wireserver_handler.py index 4bfdf7a5..200aca15 100644 --- a/testinit/testing-server/wireserver_handler.py +++ b/testinit/testing-server/wireserver_handler.py @@ -56,15 +56,14 @@ def load_responses(cls): logger.info(json.dumps(cls._responses, indent=2)) def log_kvp_file(): - """Log the entire contents of the KVP pool file.""" - try: - with open("/shared-kvp/.kvp_pool_1", "r") as f: - content = f.read() - logger.info(f"KVP file contents: \n{content}") - except FileNotFoundError: - logger.error("KVP file not found at /shared-kvp/.kvp_pool_1") - except Exception as e: - logger.error(f"Error reading KVP file: {e}") + kvp_file_path = "/var/lib/hyperv/.kvp_pool_1" + + if os.path.exists(kvp_file_path): + with open(kvp_file_path, "r") as f: + kvp_data = f.read() + logger.info(f"KVP data: {kvp_data}") + else: + logger.info("KVP file not found") def write_custom_response(self): responses_list = self._responses From 61eea04e783ff72742172371337cb29e8f87b38f Mon Sep 17 00:00:00 2001 From: Cade Jacobson Date: Thu, 16 Oct 2025 10:34:19 -0700 Subject: [PATCH 4/9] Add self to the log kvp file --- testinit/testing-server/wireserver_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testinit/testing-server/wireserver_handler.py b/testinit/testing-server/wireserver_handler.py index 200aca15..a507d63d 100644 --- a/testinit/testing-server/wireserver_handler.py +++ b/testinit/testing-server/wireserver_handler.py @@ -55,7 +55,7 @@ def load_responses(cls): logger.info("Outputting loaded custom WireServer responses") logger.info(json.dumps(cls._responses, indent=2)) - def log_kvp_file(): + def log_kvp_file(self): kvp_file_path = "/var/lib/hyperv/.kvp_pool_1" if os.path.exists(kvp_file_path): From 00af9b32bf46a1b7938cae301a59cd44ffe2c269 Mon Sep 17 00:00:00 2001 From: Cade Jacobson Date: Thu, 16 Oct 2025 10:47:48 -0700 Subject: [PATCH 5/9] Mount to a place that already exists --- testinit/docker-compose.yml | 7 +------ testinit/start-all.sh | 2 ++ testinit/testing-server/docker-compose.yml | 6 +----- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/testinit/docker-compose.yml b/testinit/docker-compose.yml index 2ea22c5a..8cbffe29 100644 --- a/testinit/docker-compose.yml +++ b/testinit/docker-compose.yml @@ -11,8 +11,7 @@ services: volumes: - /sys/fs/cgroup:/sys/fs/cgroup:rw - /run/dbus/system_bus_socket:/run/dbus/system_bus_socket:rw - - kvp_data:/var/lib/hyperv # Add shared volume - + - /var/lib/hyperv:/var/lib/hyperv:rw stdin_open: true tty: true container_name: azureinit-provisioning-agent @@ -24,10 +23,6 @@ services: - imds-network - wireserver-network -volumes: - kvp_data: - - networks: imds-network: external: true diff --git a/testinit/start-all.sh b/testinit/start-all.sh index a368a3e2..8edd93e2 100755 --- a/testinit/start-all.sh +++ b/testinit/start-all.sh @@ -1,4 +1,6 @@ #!/bin/bash +sudo mkdir -p /var/lib/hyperv +sudo touch /var/lib/hyperv/.kvp_pool_1 echo "Starting testing-server first (creates networks with Azure IP addresses)..." pushd testing-server diff --git a/testinit/testing-server/docker-compose.yml b/testinit/testing-server/docker-compose.yml index 6d97a6d5..1a8de7e7 100644 --- a/testinit/testing-server/docker-compose.yml +++ b/testinit/testing-server/docker-compose.yml @@ -11,7 +11,7 @@ services: ports: - "80:80" volumes: - - kvp_data:/var/lib/hyperv + - /var/lib/hyperv:/var/lib/hyperv:rw networks: imds-network: ipv4_address: 169.254.169.254 @@ -24,10 +24,6 @@ services: retries: 3 start_period: 40s -volumes: - kvp_data: - - networks: imds-network: driver: bridge From 4836a2672c85c356226689414c0cd5e17cbd0f0b Mon Sep 17 00:00:00 2001 From: Cade Jacobson Date: Thu, 16 Oct 2025 11:23:07 -0700 Subject: [PATCH 6/9] Test if the hyperv directory already exists --- testinit/start-all.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testinit/start-all.sh b/testinit/start-all.sh index 8edd93e2..b626bd2e 100755 --- a/testinit/start-all.sh +++ b/testinit/start-all.sh @@ -1,6 +1,6 @@ #!/bin/bash -sudo mkdir -p /var/lib/hyperv -sudo touch /var/lib/hyperv/.kvp_pool_1 +# sudo mkdir -p /var/lib/hyperv +# sudo touch /var/lib/hyperv/.kvp_pool_1 echo "Starting testing-server first (creates networks with Azure IP addresses)..." pushd testing-server From e3f0b34a1e021f86a5b363480b308e30fa9d0fad Mon Sep 17 00:00:00 2001 From: Cade Jacobson Date: Thu, 16 Oct 2025 11:37:17 -0700 Subject: [PATCH 7/9] Remove unnecessary calls --- testinit/start-all.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/testinit/start-all.sh b/testinit/start-all.sh index b626bd2e..a368a3e2 100755 --- a/testinit/start-all.sh +++ b/testinit/start-all.sh @@ -1,6 +1,4 @@ #!/bin/bash -# sudo mkdir -p /var/lib/hyperv -# sudo touch /var/lib/hyperv/.kvp_pool_1 echo "Starting testing-server first (creates networks with Azure IP addresses)..." pushd testing-server From 4e23585a1fb3674341b1317645981e2a77a2d932 Mon Sep 17 00:00:00 2001 From: Cade Jacobson Date: Thu, 16 Oct 2025 11:42:50 -0700 Subject: [PATCH 8/9] Output the correct kvp file --- .github/workflows/e2e-testing.yml | 2 +- testinit/testing-server/wireserver_handler.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e-testing.yml b/.github/workflows/e2e-testing.yml index 6a8db730..86d8cd5c 100644 --- a/.github/workflows/e2e-testing.yml +++ b/.github/workflows/e2e-testing.yml @@ -73,7 +73,7 @@ jobs: - name: Output KVP telemetry if: always() run: | - docker exec azureinit-provisioning-agent cat /var/lib/hyperv/.kvp_pool_1 + docker exec testing-server cat /tmp/testinit.kvp_pool_1 - name: Output Azure-init log if: always() diff --git a/testinit/testing-server/wireserver_handler.py b/testinit/testing-server/wireserver_handler.py index a507d63d..8a81c63e 100644 --- a/testinit/testing-server/wireserver_handler.py +++ b/testinit/testing-server/wireserver_handler.py @@ -55,13 +55,20 @@ def load_responses(cls): logger.info("Outputting loaded custom WireServer responses") logger.info(json.dumps(cls._responses, indent=2)) - def log_kvp_file(self): + def store_kvp_file(self): kvp_file_path = "/var/lib/hyperv/.kvp_pool_1" + output_file_path = "/tmp/testinit.kvp_pool_1" if os.path.exists(kvp_file_path): with open(kvp_file_path, "r") as f: kvp_data = f.read() - logger.info(f"KVP data: {kvp_data}") + + # Write to output file, overwriting if it exists since this gets + # called multiple times with a failure. + with open(output_file_path, "w") as f: + f.write(kvp_data) + + logger.info(f"KVP data written to {output_file_path}") else: logger.info("KVP file not found") @@ -117,7 +124,7 @@ def do_POST(self): logger.info(f"WireServer POST request: {self.path}") logger.info(f"POST data: {post_data.decode('utf-8', errors='ignore')}") - self.log_kvp_file() + self.store_kvp_file() if self._responses is not None: self.write_custom_response() From 94b8dd3b46e82dc7e210b082ddf82af1c10e3a2b Mon Sep 17 00:00:00 2001 From: Cade Jacobson Date: Thu, 16 Oct 2025 11:51:57 -0700 Subject: [PATCH 9/9] Update container name --- .github/workflows/e2e-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-testing.yml b/.github/workflows/e2e-testing.yml index 86d8cd5c..e8341a77 100644 --- a/.github/workflows/e2e-testing.yml +++ b/.github/workflows/e2e-testing.yml @@ -73,7 +73,7 @@ jobs: - name: Output KVP telemetry if: always() run: | - docker exec testing-server cat /tmp/testinit.kvp_pool_1 + docker exec azure-testing-server cat /tmp/testinit.kvp_pool_1 - name: Output Azure-init log if: always()