Skip to content

Commit

Permalink
fix logic for spot (#1429)
Browse files Browse the repository at this point in the history
* fix logic for spot

* add projectId to namespace manifest
  • Loading branch information
pepoviola authored Oct 18, 2023
1 parent 38775b7 commit 68a97ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class KubeClient extends Client {
labels: {
jobId: process.env.CI_JOB_ID || "",
projectName: process.env.CI_PROJECT_NAME || "",
projectId: process.env.CI_PROJECT_ID || "",
},
},
};
Expand Down
27 changes: 16 additions & 11 deletions scripts/ci/run-test-local-env-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,22 @@ function set_instance_env {
echo pipeline_id: $CI_PIPELINE_ID
echo job_name: $CI_JOB_NAME

# export default
export X_INFRA_INSTANCE=ondemand

STATUS=$(curl -s -o response.txt -w "%{http_code}" -H "Accept: application/json" "https://gitlab.parity.io/api/v4/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/jobs?include_retried=true")
if [ $STATUS == "200" ]; then
JOBS_CANCELED_BY_US=$(cat response.txt |jq -c ".[] | select((.name | contains(\"${CI_JOB_NAME}\")) and .status == \"canceled\" and (.duration >= 0))") | wc -l
if [[ $JOBS_CANCELED_BY_US -eq 0 ]]; then
# only mod 10 for PoC
R=$(( $CI_PIPELINE_ID % 10));
if [[ $R -eq 0 ]];then
export X_INFRA_INSTANCE=spot
if [[ "${FORCED_INFRA_INSTANCE:=""}" != "" ]];then
echo "setting env X_INFRA_INSTANCE to $FORCED_INFRA_INSTANCE"
export X_INFRA_INSTANCE=$FORCED_INFRA_INSTANCE
else
# export default
export X_INFRA_INSTANCE=ondemand

STATUS=$(curl -s -o response.txt -w "%{http_code}" -H "Accept: application/json" "https://gitlab.parity.io/api/v4/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/jobs?include_retried=true")
if [ $STATUS == "200" ]; then
JOBS_CANCELED_BY_US=$(cat response.txt |jq -c ".[] | select((.name | contains(\"${CI_JOB_NAME}\")) and .status == \"canceled\" and (.duration >= 0))" | wc -l)
if [[ $JOBS_CANCELED_BY_US -eq 0 ]]; then
# only mod 10 for PoC
R=$(( $CI_PIPELINE_ID % 10));
if [[ $R -eq 0 ]];then
export X_INFRA_INSTANCE=spot
fi;
fi;
fi;
fi;
Expand Down

0 comments on commit 68a97ed

Please sign in to comment.