Skip to content

Commit dfa5bbb

Browse files
authored
Merge pull request #15 from sustainable-computing-io/label
runner: add labels to distinguish OS types
2 parents 82cd501 + c6f1704 commit dfa5bbb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

entrypoint.sh

+8-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,14 @@ create_uesr_data () {
113113
# ENCODED_USER_DATA=$(echo "$USER_DATA" | base64 | tr -d \\n)
114114
cat <<EOF > user_data.sh
115115
#!/bin/bash
116+
export RUNNER_LABEL="${INSTANCE_TYPE}"
116117
if command -v yum &> /dev/null; then
118+
# add rhel to the label
119+
export RUNNER_LABEL="rhel,${INSTANCE_TYPE}"
117120
yum install -y curl jq libicu
118121
else
122+
# add ubuntu to the label
123+
export RUNNER_LABEL="ubuntu,${INSTANCE_TYPE}"
119124
apt-get update
120125
apt-get install -y curl jq
121126
fi
@@ -135,7 +140,7 @@ tar xzf ./actions-runner-linux-x64-2.311.0.tar.gz
135140
# Create the runner and start the configuration experience
136141
# there is a bug in the github instruction. The config script does not work with sudo unless we set RUNNER_ALLOW_RUNASROOT=true
137142
export RUNNER_ALLOW_RUNASROOT=true
138-
./config.sh --replace --unattended --name ${RUNNER_NAME} --url "https://github.com/${GITHUB_REPO}" --token ${RUNNER_TOKEN}
143+
./config.sh --replace --unattended --name ${RUNNER_NAME} --url "https://github.com/${GITHUB_REPO}" --token ${RUNNER_TOKEN} --labels "\${RUNNER_LABEL}"
139144
# Last step, run it!
140145
./run.sh
141146
EOF
@@ -216,9 +221,9 @@ create_runner () {
216221
# then we extract the minimum required price and use that as the new bid price
217222
if [[ "$INSTANCE_JSON" == *"SpotMaxPriceTooLow"* ]]; then
218223
debug "SpotMaxPriceTooLow error, extracting minimum required price"
219-
MIN_PRICE=$(echo -n "$INSTANCE_JSON" | awk '{print $NF}' | head -c -2)
224+
MIN_PRICE=$(echo -n "$INSTANCE_JSON" | awk '{print $NF}' | head -c -2 | tr -d '\r')
220225
debug "Minimum required price: ${MIN_PRICE}"
221-
#BID_PRICE=$(echo "$MIN_PRICE * 1.1" | bc)
226+
BID_PRICE=$(echo "$MIN_PRICE * 1.01" | bc)
222227
BID_PRICE=$MIN_PRICE
223228
continue
224229
else

0 commit comments

Comments
 (0)