Skip to content

Commit 008b20d

Browse files
fix: handle idle image builder templates when retrying prefetch optimization and increase retry count (#8623)
1 parent eeb4960 commit 008b20d

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

.pipelines/templates/.builder-release-template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ steps:
286286
eq(variables.PREFETCH_COMPATIBLE, 'True')
287287
)
288288
displayName: Run Prefetch Optimization and Convert to VHD blob
289-
retryCountOnTaskFailure: 3
289+
retryCountOnTaskFailure: 10
290290
env:
291291
SUBSCRIPTION_ID: $(SUBSCRIPTION_ID)
292292
LOCATION: $(PACKER_BUILD_LOCATION)

vhdbuilder/prefetch/scripts/optimize.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,13 @@ run_image_builder_template() {
109109
echo "image builder template ${IMAGE_BUILDER_TEMPLATE_NAME} has been created, starting run..."
110110
az image builder run -n "${IMAGE_BUILDER_TEMPLATE_NAME}" -g "${IMAGE_BUILDER_RG_NAME}"
111111
else
112-
echo "will attempt to wait for image builder template ${IMAGE_BUILDER_TEMPLATE_NAME} to finish its last run..."
113-
az image builder wait -n "${IMAGE_BUILDER_TEMPLATE_NAME}" -g "${IMAGE_BUILDER_RG_NAME}" --custom "lastRunStatus.runState!='Running'"
112+
if [ "$(az image builder show -n "${IMAGE_BUILDER_TEMPLATE_NAME}" -g "${IMAGE_BUILDER_RG_NAME}" | jq -r '.lastRunStatus')" = "null" ]; then
113+
echo "template ${IMAGE_BUILDER_TEMPLATE_NAME} has no lastRunStatus, will attempt to run..."
114+
az image builder run -n "${IMAGE_BUILDER_TEMPLATE_NAME}" -g "${IMAGE_BUILDER_RG_NAME}"
115+
else
116+
echo "will attempt to wait for image builder template ${IMAGE_BUILDER_TEMPLATE_NAME} to finish its last run..."
117+
az image builder wait -n "${IMAGE_BUILDER_TEMPLATE_NAME}" -g "${IMAGE_BUILDER_RG_NAME}" --custom "lastRunStatus.runState!='Running'"
118+
fi
114119
fi
115120

116121
template_run_state=$(az image builder show -n "${IMAGE_BUILDER_TEMPLATE_NAME}" -g "${IMAGE_BUILDER_RG_NAME}" | jq -r '.lastRunStatus.runState')

0 commit comments

Comments
 (0)