Skip to content

Commit 9c5dbd5

Browse files
committed
2 parents 6df8acb + f523b57 commit 9c5dbd5

2 files changed

Lines changed: 68 additions & 50 deletions

File tree

wd/conf/eks/aws-do-hyperpod-eks/generate-config.sh

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
#!/bin/bash
22

3+
# Show debug info about the environment files
4+
echo "==== The content of env_input ===="
5+
cat ./env_input
6+
echo "==============================================="
7+
8+
echo "==== The content of env_vars ===="
9+
cat ./env_vars
10+
echo "==============================================="
11+
312
source ./env_input
413
source ./env_vars
514

15+
# Start writing the JSON
616
cat > hyperpod-config.json << EOL
717
{
818
"ClusterName": "${HYPERPOD_NAME}",
@@ -29,8 +39,16 @@ cat > hyperpod-config.json << EOL
2939
"OnCreate": "on_create.sh"
3040
},
3141
"ExecutionRole": "${EXECUTION_ROLE}",
32-
"ThreadsPerCore": 1,
33-
"OnStartDeepHealthChecks": ${ONSTART_DEEP_HEALTHCHECKS}
42+
"ThreadsPerCore": 1
43+
EOL
44+
45+
# Conditionally add OnStartDeepHealthChecks only if not empty
46+
if [ -n "${ONSTART_DEEP_HEALTHCHECKS}" ]; then
47+
echo ' ,"OnStartDeepHealthChecks": '${ONSTART_DEEP_HEALTHCHECKS} >> hyperpod-config.json
48+
fi
49+
50+
# Finish writing the JSON
51+
cat >> hyperpod-config.json << EOL
3452
},
3553
{
3654
"InstanceGroupName": "worker-group-2",
@@ -58,3 +76,20 @@ cat > hyperpod-config.json << EOL
5876
"NodeRecovery": "${NODE_RECOVERY}"
5977
}
6078
EOL
79+
80+
# Display the generated JSON file
81+
echo "==== Generated hyperpod-config.json ===="
82+
cat hyperpod-config.json
83+
echo "=================================================="
84+
85+
# Validate the JSON if jq is available
86+
if command -v jq &> /dev/null; then
87+
echo "==== Validate output JSON ===="
88+
if jq empty hyperpod-config.json 2>/dev/null; then
89+
echo "JSON is valid"
90+
else
91+
echo "ERROR: Invalid JSON"
92+
jq empty hyperpod-config.json
93+
fi
94+
echo "=================================="
95+
fi
Lines changed: 31 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
#!/bin/bash
22

3+
# Show debug info about the environment files
4+
echo "==== The content of env_input ===="
5+
cat ./env_input
6+
echo "==============================================="
7+
8+
echo "==== The content of env_vars ===="
9+
cat ./env_vars
10+
echo "==============================================="
11+
312
source ./env_input
413
source ./env_vars
514

6-
if [ "$ONSTART_DEEP_HEALTHCHECKS" == "" ]; then
7-
15+
# Start writing the JSON
816
cat > hyperpod-update-config.json << EOL
917
{
1018
"ClusterName": "${HYPERPOD_NAME}",
@@ -26,54 +34,14 @@ cat > hyperpod-update-config.json << EOL
2634
},
2735
"ExecutionRole": "${EXECUTION_ROLE}",
2836
"ThreadsPerCore": 1
29-
},
30-
{
31-
"InstanceGroupName": "worker-group-2",
32-
"InstanceType": "${GEN_INSTANCE_TYPE}",
33-
"InstanceCount": ${GEN_COUNT},
34-
"InstanceStorageConfigs": [
35-
{
36-
"EbsVolumeConfig": {
37-
"VolumeSizeInGB": ${GEN_VOLUME_SIZE}
38-
}
39-
}
40-
],
41-
"LifeCycleConfig": {
42-
"SourceS3Uri": "s3://${S3_BUCKET_NAME}",
43-
"OnCreate": "on_create.sh"
44-
},
45-
"ExecutionRole": "${EXECUTION_ROLE}",
46-
"ThreadsPerCore": 1
47-
}
48-
],
49-
"NodeRecovery": "${NODE_RECOVERY}"
50-
}
5137
EOL
5238

53-
else
39+
# Conditionally add OnStartDeepHealthChecks only if not empty
40+
if [ -n "${ONSTART_DEEP_HEALTHCHECKS}" ]; then
41+
echo ' ,"OnStartDeepHealthChecks": '${ONSTART_DEEP_HEALTHCHECKS} >> hyperpod-update-config.json
42+
fi
5443

55-
cat > hyperpod-update-config.json << EOL
56-
{
57-
"ClusterName": "${HYPERPOD_NAME}",
58-
"InstanceGroups": [
59-
{
60-
"InstanceGroupName": "worker-group-1",
61-
"InstanceType": "${ACCEL_INSTANCE_TYPE}",
62-
"InstanceCount": ${ACCEL_COUNT},
63-
"InstanceStorageConfigs": [
64-
{
65-
"EbsVolumeConfig": {
66-
"VolumeSizeInGB": ${ACCEL_VOLUME_SIZE}
67-
}
68-
}
69-
],
70-
"LifeCycleConfig": {
71-
"SourceS3Uri": "s3://${S3_BUCKET_NAME}",
72-
"OnCreate": "on_create.sh"
73-
},
74-
"ExecutionRole": "${EXECUTION_ROLE}",
75-
"ThreadsPerCore": 1,
76-
"OnStartDeepHealthChecks": ${ONSTART_DEEP_HEALTHCHECKS}
44+
cat >> hyperpod-update-config.json << EOL
7745
},
7846
{
7947
"InstanceGroupName": "worker-group-2",
@@ -98,4 +66,19 @@ cat > hyperpod-update-config.json << EOL
9866
}
9967
EOL
10068

101-
fi
69+
# Display the generated JSON file
70+
echo "==== Generated hyperpod-update-config.json ===="
71+
cat hyperpod-update-config.json
72+
echo "=================================================="
73+
74+
# Validate the JSON if jq is available
75+
if command -v jq &> /dev/null; then
76+
echo "==== Validate output JSON ===="
77+
if jq empty hyperpod-update-config.json 2>/dev/null; then
78+
echo "JSON is valid"
79+
else
80+
echo "ERROR: Invalid JSON"
81+
jq empty hyperpod-update-config.json
82+
fi
83+
echo "=================================="
84+
fi

0 commit comments

Comments
 (0)