Skip to content

Commit feb6371

Browse files
authored
Merge pull request #9 from sustainable-computing-io/rpm
support rhel based runner
2 parents dd13708 + 3f8c272 commit feb6371

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
| github_repo | (Optional) The GitHub repository in the format "owner/repository" to clone and use. | "sustainable-computing-io/kepler-model-server" |
108108
| aws_region | (Optional) The AWS region to launch the spot instance. | "us-east-2" |
109109
| key_name | (Optional) The name of the key pair to use for the instance. | Empty. |
110-
| root_volume_size | (Optional) The size of the root volume in GB. | 8 |
110+
| root_volume_size | (Optional) The size of the root volume in GB. | 20 |
111111
| spot_inastance_only | (Optional) If true, only create a spot instance. | "true" |
112112
| create_s3_bucket | (Optional) If true, create a S3 bucket to store the model. | "false" |
113113
| bucket_name | (Optional) The name of the S3 bucket to store the model. | The bucket name is the same as the repository name with time date stamp. |

entrypoint.sh

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ GITHUB_REPO="${INPUT_GITHUB_REPO:-"sustainable-computing-io/kepler-model-server"
1919
REGION="${INPUT_AWS_REGION:-us-east-2}" # Region to launch the spot instance
2020
DEBUG="${DEBUG:-false}" # Enable debug mode
2121
KEY_NAME="${INPUT_KEY_NAME:-}" # Name of the key pair to use for the instance
22-
ROOT_VOLUME_SIZE="${INPUT_ROOT_VOLUME_SIZE:-8}" # Size of the root volume in GB
22+
ROOT_VOLUME_SIZE="${INPUT_ROOT_VOLUME_SIZE:-20}" # Size of the root volume in GB
2323
SPOT_INSTANCE_ONLY="${INPUT_SPOT_INSTANCE_ONLY:-true}" # If true, only create spot instance
2424
CREATE_S3_BUCKET="${INPUT_CREATE_S3_BUCKET:-false}" # Wehther to create a S3 bucket to store the model
2525
BUCKET_NAME="${INPUT_BUCKET_NAME:-}" # Name of the S3 bucket
@@ -113,8 +113,12 @@ create_uesr_data () {
113113
# ENCODED_USER_DATA=$(echo "$USER_DATA" | base64 | tr -d \\n)
114114
cat <<EOF > user_data.sh
115115
#!/bin/bash
116-
apt-get update
117-
apt-get install -y curl jq
116+
if command -v yum &> /dev/null; then
117+
yum install -y curl jq libicu
118+
else
119+
apt-get update
120+
apt-get install -y curl jq
121+
fi
118122
# install the latest kernel modeules and enable rapl. it doesn seem uname -r works in user data script...
119123
# export KERNEL_VERSION=$(apt list --installed 2>&1 | grep 'linux-image-' | awk -F'/' '{print $1}' |grep "\." | cut -d'-' -f3-)
120124
# echo "installing kernel modules for version $KERNEL_VERSION"
@@ -149,7 +153,7 @@ run_spot_instance () {
149153
--instance-market-options '{"MarketType":"spot", "SpotOptions": {"MaxPrice": "'${BID_PRICE}'" }}' \
150154
--block-device-mappings '[{"DeviceName": "/dev/sda1","Ebs": { "VolumeSize": '${ROOT_VOLUME_SIZE}', "DeleteOnTermination": true } }]'\
151155
$KEY_NAME_OPT \
152-
--user-data file://user_data.sh)
156+
--user-data file://user_data.sh 2>&1)
153157
}
154158

155159
run_on_demand_instance() {
@@ -208,7 +212,18 @@ create_runner () {
208212
# Check if instance creation failed
209213
if [ -z "$INSTANCE_ID" ]; then
210214
debug "Failed to create instance with bid price ${BID_PRICE}"
211-
BID_PRICE=$(echo "$BID_PRICE * 1.1" | bc)
215+
# if bid price is too low, and the error message contains"An error occurred (SpotMaxPriceTooLow) when calling the RunInstances operation: Your Spot request price of 0.0035200000000000023 is lower than the minimum required Spot request fulfillment price of 0.06319999999999999."
216+
# then we extract the minimum required price and use that as the new bid price
217+
if [[ "$INSTANCE_JSON" == *"SpotMaxPriceTooLow"* ]]; then
218+
debug "SpotMaxPriceTooLow error, extracting minimum required price"
219+
MIN_PRICE=$(echo -n "$INSTANCE_JSON" | awk '{print $NF}' | head -c -2)
220+
debug "Minimum required price: ${MIN_PRICE}"
221+
#BID_PRICE=$(echo "$MIN_PRICE * 1.1" | bc)
222+
BID_PRICE=$MIN_PRICE
223+
continue
224+
else
225+
BID_PRICE=$(echo "$BID_PRICE * 1.1" | bc)
226+
fi
212227
debug "Creating a spot instance with a new bid of ${BID_PRICE}"
213228
continue
214229
else

0 commit comments

Comments
 (0)