Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
List of MorphoCloudWorkflow changes:

```
$ git shortlog aeb73c1..5874774 --no-merges
Jean-Christophe Fillion-Robin (3):
      fix(cloud-config): Update to MorphoCloud/exosphere@5aabf5688
      feat(automatic shelving): Add support to check for instance shelving extension
      fix(create-instance): Attempt to fix networking removing redundant security group
```

See MorphoCloud/MorphoCloudWorkflow@aeb73c1...5874774
  • Loading branch information
jcfr committed Oct 22, 2024
1 parent a8380ef commit 177bb72
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
38 changes: 31 additions & 7 deletions .github/workflows/automatic-instance-shelving.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,43 @@ jobs:
# an issue where SSH breaks out of the while loop in Bash.
# Reference: https://stackoverflow.com/questions/9393038/ssh-breaks-out-of-while-loop-in-bash
# Retrieve the instance uptime using SSH
uptime_seconds=$(ssh \
has_check_instance_shelve_script=$(ssh \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-o LogLevel=ERROR \
exouser@$instance_ip \
'cat /proc/uptime | awk "{print \$1}"' < /dev/null)
'bash -c "[[ -f /home/exouser/dist/check-instance-shelve.sh ]] && echo yes || echo no"' < /dev/null)
if [[ $? -ne 0 ]]; then
echo "::warning ::Failed to retrieve uptime for $instance_name using IP $instance_ip"
echo "::warning ::Failed to check if 'check-instance-shelve.sh' was found on $instance_name using IP $instance_ip"
continue
fi
# Convert uptime from seconds to hours
uptime_hours=$(echo "scale=2; $uptime_seconds / 3600" | bc)
if [[ "$has_check_instance_shelve_script" == "yes" ]]; then
uptime_hours=$(ssh \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-o LogLevel=ERROR \
exouser@$instance_ip \
'/home/exouser/dist/check-instance-shelve.sh -d' < /dev/null)
if [[ $? -ne 0 ]]; then
echo "::warning ::Failed to retrieve uptime for $instance_name using IP $instance_ip"
continue
fi
else
# Retrieve the instance uptime using SSH
uptime_seconds=$(ssh \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-o LogLevel=ERROR \
exouser@$instance_ip \
'cat /proc/uptime | awk "{print \$1}"' < /dev/null)
if [[ $? -ne 0 ]]; then
echo "::warning ::Failed to retrieve uptime for $instance_name using IP $instance_ip"
continue
fi
# Convert uptime from seconds to hours
uptime_hours=$(echo "scale=2; $uptime_seconds / 3600" | bc)
fi
# Check uptime and define action
if $(python3 -c "valid=($uptime_hours > 3.5 and $uptime_hours <= 4.0); EXIT_SUCCESS=0; EXIT_FAILURE=1; exit(EXIT_SUCCESS if valid else EXIT_FAILURE)"); then
action="notify"
Expand All @@ -90,7 +114,7 @@ jobs:
else
action=""
fi
echo "instance_name [$instance_name], uptime_hours [$uptime_hours] -> action[$action]"
echo "instance_name [$instance_name], has_check_instance_shelve_script [$has_check_instance_shelve_script], uptime_hours [$uptime_hours] -> action[$action]"
# Perform action
if [[ "$action" == "shelve" ]]; then
gh workflow run control-instance-from-workflow.yml \
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/create-instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ jobs:
openstack server create "$INSTANCE_NAME" \
--nic net-id="auto_allocated_network" \
--security-group "default" \
--security-group "exosphere" \
--flavor $INSTANCE_FLAVOR \
--image "Featured-Ubuntu22" \
Expand Down
2 changes: 1 addition & 1 deletion cloud-config
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ runcmd:
# --checkout "{instance-config-mgt-repo-checkout}"
# -e "{ansible-extra-vars}"
rm -rf /opt/instance-config-mgt
exosphere_sha="a2e2381f31647694e80e2baf3e5d0ec7b5c42ffb" # morpho-cloud-portal-2024.07.17-78a7e2d93
exosphere_sha="aa300db7bf9e1f2d0ffd3eb162d3fe5a85985d4c" # morpho-cloud-portal-2024.07.17-78a7e2d93
ansible-pull \
--url "https://github.com/MorphoCloud/exosphere.git" \
--checkout "$exosphere_sha" \
Expand Down

0 comments on commit 177bb72

Please sign in to comment.