From 10cf34128df329302a8bf7fb3fa4f0391e09c81a Mon Sep 17 00:00:00 2001 From: Giacomo Marciani Date: Tue, 16 Dec 2025 12:31:41 -0500 Subject: [PATCH] [Build] Ubuntu: disable snap refresh during AMI build to prevent background updates. This is to prevent side effects, such as reboot failure caused by background update onf SSM agent. --- .../imagebuilder/parallelcluster.yaml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cli/src/pcluster/resources/imagebuilder/parallelcluster.yaml b/cli/src/pcluster/resources/imagebuilder/parallelcluster.yaml index 07ba029660..071012ee2d 100644 --- a/cli/src/pcluster/resources/imagebuilder/parallelcluster.yaml +++ b/cli/src/pcluster/resources/imagebuilder/parallelcluster.yaml @@ -34,6 +34,21 @@ phases: *) echo "Unsupported OS: $RELEASE" && exit {{ FailExitCode }} ;; esac + # Disable snap refresh to prevent background updates during build (Ubuntu only) + - name: DisableSnapRefresh + action: ExecuteBash + inputs: + commands: + - | + set -x + OS="{{ build.OperatingSystemName.outputs.stdout }}" + if [[ $OS =~ ^ubuntu ]]; then + # Wait for any in-progress snap operations to complete, then stop and disable + snap watch --last=auto-refresh 2>/dev/null || true + systemctl stop snapd.refresh.timer + systemctl disable snapd.refresh.timer + fi + # Initialize system information and URLs - name: SystemInfo action: ExecuteBash @@ -260,6 +275,12 @@ phases: echo "SSM agent is installed by default" fi + # Re-enable snap refresh timer (Ubuntu only) + if [[ $OS =~ ^ubuntu ]]; then + systemctl enable snapd.refresh.timer + systemctl start snapd.refresh.timer + fi + # Final cleanup rm -f /opt/parallelcluster/system_info /usr/local/sbin/ami_cleanup.sh "${CfnParamIsOfficialAmiBuild}"