@@ -118,65 +118,59 @@ spec:
118118 echo "[mapt] Spot: $(params.spot)"
119119 echo "[mapt] =================================="
120120
121- SPOT_ARGS=""
122- if [[ "$(params.spot)" == "true" ]]; then
123- SPOT_ARGS="--spot --spot-eviction-tolerance highest"
124- fi
125-
126- if [[ "$(params.spot)" == "true" ]]; then
127- export AWS_DEFAULT_REGION="us-east-1"
128- echo "[mapt] Using spot instances (searching all regions)..."
129- mapt aws rhel-ai create \
130- --project-name "mapt-rhel-ai-${RUN_ID}" \
131- --backed-url "s3://${BUCKET}/mapt/rhel-ai/${RUN_ID}" \
121+ MAPT_COMMON_ARGS="--project-name mapt-rhel-ai-${RUN_ID} \
122+ --backed-url s3://${BUCKET}/mapt/rhel-ai/${RUN_ID} \
132123 --conn-details-output /opt/host-info \
133- --compute-sizes "$(params.instance-type)" \
134- --version "$(params.rhelai-version)" \
135- ${SPOT_ARGS} \
124+ --compute-sizes $(params.instance-type) \
125+ --version $(params.rhelai-version) \
136126 --auto-start \
137- --model " $(params.model)" \
138- --hf-token " ${HF_TOKEN}" \
139- --api-key " ${VLLM_API_KEY}" \
127+ --model $(params.model) \
128+ --hf-token ${HF_TOKEN} \
129+ --api-key ${VLLM_API_KEY} \
140130 --expose-ports 8000 \
141- --vllm-extra-args "--max-model-len 131072 --enable-auto-tool-choice --tool-call-parser llama3_json --chat-template /opt/app-root/template/tool_chat_template_llama3.1_json.jinja" \
142- --tags "project=lightspeed-core,environment=konflux-ci"
131+ --vllm-extra-args '--max-model-len 131072 --enable-auto-tool-choice --tool-call-parser llama3_json --chat-template /opt/app-root/template/tool_chat_template_llama3.1_json.jinja' \
132+ --tags project=lightspeed-core,environment=konflux-ci"
133+
134+ CREATED=0
135+
136+ # Try spot first
137+ echo "[mapt] Trying spot instances..."
138+ export AWS_DEFAULT_REGION="us-east-1"
139+ if mapt aws rhel-ai create $MAPT_COMMON_ARGS --spot --spot-eviction-tolerance highest; then
140+ CREATED=1
143141 else
142+ echo "[mapt] Spot failed, cleaning up..."
143+ mapt aws rhel-ai destroy \
144+ --project-name "mapt-rhel-ai-${RUN_ID}" \
145+ --backed-url "s3://${BUCKET}/mapt/rhel-ai/${RUN_ID}" \
146+ --force-destroy 2>/dev/null || true
147+ fi
148+
149+ # Fall back to on-demand with region rotation
150+ if [ "$CREATED" -ne 1 ]; then
144151 REGIONS="us-east-1 us-east-2 us-west-2 eu-west-1 eu-central-1 ap-northeast-1"
145152 TIMEOUT=600
146- CREATED=0
147153
148154 for REGION in $REGIONS; do
149155 echo "[mapt] Trying on-demand in ${REGION}..."
150156 export AWS_DEFAULT_REGION="$REGION"
151157
152- if timeout $TIMEOUT mapt aws rhel-ai create \
153- --project-name "mapt-rhel-ai-${RUN_ID}" \
154- --backed-url "s3://${BUCKET}/mapt/rhel-ai/${RUN_ID}" \
155- --conn-details-output /opt/host-info \
156- --compute-sizes "$(params.instance-type)" \
157- --version "$(params.rhelai-version)" \
158- --auto-start \
159- --model "$(params.model)" \
160- --hf-token "${HF_TOKEN}" \
161- --api-key "${VLLM_API_KEY}" \
162- --expose-ports 8000 \
163- --vllm-extra-args "--max-model-len 131072 --enable-auto-tool-choice --tool-call-parser llama3_json --chat-template /opt/app-root/template/tool_chat_template_llama3.1_json.jinja" \
164- --tags "project=lightspeed-core,environment=konflux-ci"; then
158+ if timeout $TIMEOUT mapt aws rhel-ai create $MAPT_COMMON_ARGS; then
165159 CREATED=1
166160 break
167161 fi
168162
169- echo "[mapt] Failed in ${REGION}, cleaning up and trying next ..."
163+ echo "[mapt] Failed in ${REGION}, cleaning up..."
170164 mapt aws rhel-ai destroy \
171165 --project-name "mapt-rhel-ai-${RUN_ID}" \
172166 --backed-url "s3://${BUCKET}/mapt/rhel-ai/${RUN_ID}" \
173167 --force-destroy 2>/dev/null || true
174168 done
169+ fi
175170
176- if [ "$CREATED" -ne 1 ]; then
177- echo "[mapt] ERROR: Failed to create instance in any region"
178- exit 1
179- fi
171+ if [ "$CREATED" -ne 1 ]; then
172+ echo "[mapt] ERROR: Failed to create instance (spot + on-demand)"
173+ exit 1
180174 fi
181175
182176 echo "[mapt] Instance created and vLLM started."
0 commit comments