@@ -580,7 +580,7 @@ tasks:
580580 - |
581581 echo "Deleting CMX VM {{.CMX_VM_NAME}}..."
582582 replicated vm rm {{.CMX_VM_NAME}}
583-
583+
584584 cmx-vm-install :
585585 desc : Download and install the app as Embedded Cluster on CMX VM
586586 silent : true
@@ -611,52 +611,10 @@ tasks:
611611 exit 1
612612 fi
613613
614- # Check if airgap build is available when airgap mode is enabled
614+ # Run airgap- build task if airgap mode is enabled
615615 if [ "{{.AIRGAP}}" = "true" ]; then
616- echo "Checking if airgap build is available for lastest release in channel {{.CHANNEL}}..."
617-
618- # Get release list and extract app ID and channel ID
619- RELEASE_DATA=$(replicated release ls -o json)
620- APP_ID=$(echo "$RELEASE_DATA" | jq -r '.[0].appId')
621- CHANNEL_ID=$(echo "$RELEASE_DATA" | jq -r '.[0].activeChannels[] | select(.name == "{{.CHANNEL}}") | .id')
622-
623- if [ -z "$APP_ID" ] || [ "$APP_ID" = "null" ]; then
624- echo "Error: Could not retrieve app ID from releases"
625- exit 1
626- fi
627-
628- if [ -z "$CHANNEL_ID" ] || [ "$CHANNEL_ID" = "null" ]; then
629- echo "Error: Could not find channel ID for channel {{.CHANNEL}}"
630- exit 1
631- fi
632-
633- echo "Found app ID: $APP_ID, channel ID: $CHANNEL_ID"
634-
635- # Get channel releases and check airgap build status
636- CHANNEL_RELEASES=$(replicated api get "v3/app/$APP_ID/channel/$CHANNEL_ID/releases")
637- AIRGAP_BUILD_STATUS=$(echo "$CHANNEL_RELEASES" | jq -r '.releases[0].airgapBuildStatus // "none"')
638- AIRGAP_BUILD_ERROR=$(echo "$CHANNEL_RELEASES" | jq -r '.releases[0].airgapBuildError // "none"')
639- AIRGAP_BUNDLE_IMAGES=$(echo "$CHANNEL_RELEASES" | jq -r '.releases[0].airgapBundleImages // "none"')
640- AIRGAP_LATEST_SEQUENCE=$(echo "$CHANNEL_RELEASES" | jq -r '.releases[0].sequence')
641-
642- echo "Airgap build status: $AIRGAP_BUILD_STATUS"
643-
644- if [ "$AIRGAP_BUILD_STATUS" = "metadata" ]; then
645- echo "Airgap has not been built yet. Triggering build..."
646- replicated api post "v3/app/$APP_ID/channel/$CHANNEL_ID/release/$AIRGAP_LATEST_SEQUENCE/airgap/build"
647- echo "Airgap build triggered. Run the task again later to check if it's ready."
648- exit 1
649- fi
650-
651- if [ "$AIRGAP_BUILD_STATUS" != "built" ]; then
652- echo "Error: Airgap build is not ready. Status: $AIRGAP_BUILD_STATUS"
653- echo "Airgap build error (if any): $AIRGAP_BUILD_ERROR"
654- echo "Please wait for the airgap build to complete before installing in airgap mode."
655- exit 1
656- fi
657-
658- echo "Airgap build is ready. Proceeding with installation..."
659- echo "Contents of airgap bundle images: $AIRGAP_BUNDLE_IMAGES"
616+ echo "Airgap mode enabled, ensuring airgap build is ready..."
617+ task airgap-build
660618 fi
661619
662620 echo "SSH into the VM and download the app binary..."
@@ -706,3 +664,72 @@ tasks:
706664
707665 echo "Visit above URL to access the Admin Console, password: {{.ADMIN_CONSOLE_PASSWORD}}"
708666 fi
667+
668+ airgap-build :
669+ desc : Check and build airgap bundle for the latest release
670+ silent : true
671+ cmds :
672+ - |
673+ echo "Checking if airgap build is available for latest release in channel {{.RELEASE_CHANNEL}}..."
674+
675+ # Get release list and extract app ID and channel ID
676+ RELEASE_DATA=$(replicated release ls -o json)
677+ APP_ID=$(echo "$RELEASE_DATA" | jq -r '.[0].appId')
678+ CHANNEL_ID=$(echo "$RELEASE_DATA" | jq -r '.[0].activeChannels[] | select(.name == "{{.RELEASE_CHANNEL}}") | .id')
679+
680+ if [ -z "$APP_ID" ] || [ "$APP_ID" = "null" ]; then
681+ echo "Error: Could not retrieve app ID from latest releases"
682+ exit 1
683+ fi
684+
685+ if [ -z "$CHANNEL_ID" ] || [ "$CHANNEL_ID" = "null" ]; then
686+ echo "Error: Could not find channel ID for channel {{.RELEASE_CHANNEL}}"
687+ exit 1
688+ fi
689+
690+ echo "Found app ID: $APP_ID, channel ID: $CHANNEL_ID"
691+
692+ # Get channel releases and check airgap build status
693+ CHANNEL_RELEASES=$(replicated api get "v3/app/$APP_ID/channel/$CHANNEL_ID/releases")
694+ AIRGAP_BUILD_STATUS=$(echo "$CHANNEL_RELEASES" | jq -r '.releases[0].airgapBuildStatus // "none"')
695+ AIRGAP_BUILD_ERROR=$(echo "$CHANNEL_RELEASES" | jq -r '.releases[0].airgapBuildError // "none"')
696+ AIRGAP_BUNDLE_IMAGES=$(echo "$CHANNEL_RELEASES" | jq -r '.releases[0].airgapBundleImages // "none"')
697+ AIRGAP_LATEST_SEQUENCE=$(echo "$CHANNEL_RELEASES" | jq -r '.releases[0].sequence')
698+
699+ echo "Airgap build status: $AIRGAP_BUILD_STATUS"
700+
701+ if [ "$AIRGAP_BUILD_STATUS" = "built" ]; then
702+ echo "Airgap is already buit for sequence $AIRGAP_LATEST_SEQUENCE"
703+ echo "Airgap bundle images: $AIRGAP_BUNDLE_IMAGES"
704+ exit 0
705+ fi
706+
707+ if [ "$AIRGAP_BUILD_STATUS" = "metadata" ]; then
708+ echo "Airgap has not been built yet. Triggering build..."
709+ replicated api post "v3/app/$APP_ID/channel/$CHANNEL_ID/release/$AIRGAP_LATEST_SEQUENCE/airgap/build"
710+ fi
711+
712+ echo "Airgap build triggered. Polling every 10 seconds for up to 5 minutes..."
713+ for i in $(seq 1 30); do
714+ echo "Checking airgap build status... (attempt $i/30)"
715+
716+ CHANNEL_RELEASES=$(replicated api get "v3/app/$APP_ID/channel/$CHANNEL_ID/releases")
717+ AIRGAP_BUILD_STATUS=$(echo "$CHANNEL_RELEASES" | jq -r '.releases[0].airgapBuildStatus // "none"')
718+ AIRGAP_BUILD_ERROR=$(echo "$CHANNEL_RELEASES" | jq -r '.releases[0].airgapBuildError // "none"')
719+ AIRGAP_BUNDLE_IMAGES=$(echo "$CHANNEL_RELEASES" | jq -r '.releases[0].airgapBundleImages // "none"')
720+ AIRGAP_LATEST_SEQUENCE=$(echo "$CHANNEL_RELEASES" | jq -r '.releases[0].sequence')
721+
722+ echo "Airgap build current status: $AIRGAP_BUILD_STATUS"
723+
724+ if [ "$AIRGAP_BUILD_STATUS" = "built" ]; then
725+ echo "Airgap build completed successfully!"
726+ echo "Airgap bundle images: $AIRGAP_BUNDLE_IMAGES"
727+ exit 0
728+ fi
729+ sleep 10
730+ done
731+
732+ echo "Timeout: Airgap build did not complete within 5 minutes."
733+ echo "Last build status: $AIRGAP_BUILD_STATUS"
734+ echo "Last build error: $AIRGAP_BUILD_ERROR"
735+ exit 1
0 commit comments