Skip to content

Commit

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

```
$ git shortlog MorphoCloud/MorphoCloudWorkflow@2c82cc3..MorphoCloud/MorphoCloudWorkflow@7fee216 --no-merges
Jean-Christophe Fillion-Robin (3):
      feat: Attach 60GB volume
      fix(attach volume): Customize mountpoint setting exoVolumes property
      fix(create volume): Prevent duplicated volume creation fixing condition
```
  • Loading branch information
jcfr committed Jul 26, 2024
1 parent 1dcab84 commit 5b46306
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 3 deletions.
33 changes: 33 additions & 0 deletions .github/actions/check-volume-exists/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Check volume exists"
description: "Check volume exists"
inputs:
volume_name:
description: "Name of the volume"
required: true
outputs:
exists:
description: "Set to 'true' or 'false'"
value: ${{ steps.check_volume.outputs.exists }}
runs:
using: "composite"
steps:
- name: Check volume exists
id: check_volume
shell: bash
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
volume=$(openstack volume list -f json | \
jq \
--arg volume_name "$VOLUME_NAME" \
-c '.[] | select(.Name != null) | select(.Name == $volume_name)' | \
jq -r '.Name' | tail -1)
[[ $volume == "$VOLUME_NAME" ]] && exists="true" || exists="false"
echo "exists [$exists]"
echo "exists=$exists" >> $GITHUB_OUTPUT
env:
VOLUME_NAME: ${{ inputs.volume_name }}
10 changes: 10 additions & 0 deletions .github/actions/comment-progress/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ inputs:
create_ip:
description: "Template input set to '', ✅ or ⏳"
required: true
create_volume:
description: "Template input set to '', ✅ or ⏳"
required: true
create_instance:
description: "Template input set to '', ✅ or ⏳"
required: true
Expand All @@ -13,6 +16,9 @@ inputs:
setup_instance:
description: "Template input set to '', ✅ or ⏳"
required: true
attach_volume:
description: "Template input set to '', ✅ or ⏳"
required: true
retrieve_connection_url:
description: "Template input set to '', ✅ or ⏳"
required: true
Expand All @@ -34,9 +40,11 @@ runs:
run: |
if [[ \
"{{ inputs.create_ip }}" == "✅" && \
"{{ inputs.create_volume }}" == "✅" && \
"{{ inputs.create_instance }}" == "✅" && \
"{{ inputs.associate_ip }}" == "✅" && \
"{{ inputs.setup_instance }}" == "✅" && \
"{{ inputs.attach_volume }}" == "✅" && \
"{{ inputs.retrieve_connection_url }}" == "✅" && \
"{{ inputs.send_email }}" == "✅" \
]]; then
Expand All @@ -54,9 +62,11 @@ runs:
vars: |
details_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
create_ip: ${{ inputs.create_ip }}
create_volume: ${{ inputs.create_volume }}
create_instance: ${{ inputs.create_instance }}
associate_ip: ${{ inputs.associate_ip }}
setup_instance: ${{ inputs.setup_instance }}
attach_volume: ${{ inputs.attach_volume }}
retrieve_connection_url: ${{ inputs.retrieve_connection_url }}
send_email: ${{ inputs.send_email }}
status: ${{ steps.status.outputs.value }}
Expand Down
34 changes: 34 additions & 0 deletions .github/actions/define-volume-name/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "Define volume name"
description: "Define volume name"
inputs:
issue_number:
description: "Issue number used to set the volume name"
required: true
suffix:
description:
"Optional string to append. If suffix is not empty, output is of the form
'My-Data-NNN-<SUFFIX>'."
outputs:
volume_name:
description:
"Name of the volume formatted as 'My-Data-NNN[-<SUFFIX>]' where 'NNN' is
the issue number"
value: ${{ steps.define.outputs.volume_name }}
volume_suffix:
description:
"If input suffix is not empty, volume suffix is set to '-<SUFFIX>'"
value: ${{ steps.define.outputs.volume_suffix }}
runs:
using: "composite"
steps:
- name: "Define volume name"
id: define
shell: bash
run: |
volume_suffix=${SUFFIX:+-${SUFFIX}}
volume_name="My-Data-$ISSUE_NUMBER${volume_suffix}"
echo "volume_name=$volume_name" >> $GITHUB_OUTPUT
echo "volume_suffix=$volume_suffix" >> $GITHUB_OUTPUT
env:
ISSUE_NUMBER: ${{ inputs.issue_number }}
SUFFIX: ${{ inputs.suffix }}
6 changes: 3 additions & 3 deletions .github/instance-creation-progress-template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Instance Creation Progress {{ .status }}

| Create IP | Create Instance | Associate IP | Setup Instance | Retrieve Connection URL | Send Email |
| :--------------: | :--------------------: | :-----------------: | :-------------------: | :---------------------------: | :---------------: |
| {{ .create_ip }} | {{ .create_instance }} | {{ .associate_ip }} | {{ .setup_instance }} | {{ .retrieve_connection_url}} | {{ .send_email }} |
| Create IP | Create Volume | Create Instance | Associate IP | Setup Instance | Attach volume | Retrieve Connection URL | Send Email |
| :--------------: | :------------------: | :--------------------: | :-----------------: | :-------------------: | :------------------: | :---------------------------: | :---------------: |
| {{ .create_ip }} | {{ .create_volume }} | {{ .create_instance }} | {{ .associate_ip }} | {{ .setup_instance }} | {{ .attach_volume }} | {{ .retrieve_connection_url}} | {{ .send_email }} |

See details at {{ .details_url }}
131 changes: 131 additions & 0 deletions .github/workflows/create-instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ jobs:
uses: ./.github/actions/comment-progress
with:
create_ip:
create_volume: ""
create_instance: ""
associate_ip: ""
setup_instance: ""
attach_volume: ""
retrieve_connection_url: ""
send_email: ""

Expand Down Expand Up @@ -129,9 +131,72 @@ jobs:
with:
comment-id: ${{ steps.couc_progress.outputs.comment-id }}
create_ip:
create_volume:
create_instance: ""
associate_ip: ""
setup_instance: ""
attach_volume: ""
retrieve_connection_url: ""
send_email: ""

- name: Define volume name
id: define_volume_name
uses: ./.github/actions/define-volume-name
with:
issue_number: ${{ github.event.issue.number }}
suffix: ${{ vars.VOLUME_NAME_SUFFIX }}

- name: Check volume exists
id: check_volume
uses: ./.github/actions/check-volume-exists
with:
volume_name: ${{ steps.define_volume_name.outputs.volume_name }}

- name: comment (volume already exists)
if: ${{ fromJSON(steps.check_volume.outputs.exists) }}
uses: peter-evans/create-or-update-comment@v4.0.0
with:
issue-number: ${{ github.event.issue.number }}
body: |
### Instance Creation Results ⚠️
Volume **${{ steps.define_volume_name.outputs.volume_name }}** already exists.
See details at https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Create Volume
if: ${{ ! fromJSON(steps.check_volume.outputs.exists) }}
id: create_volume
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
openstack volume create --size 60 "${VOLUME_NAME}"
env:
VOLUME_NAME: ${{ steps.define_volume_name.outputs.volume_name }}

- name: comment (failed to create volume)
if: ${{ steps.create_volume.outcome == 'failure' && failure() }}
uses: peter-evans/create-or-update-comment@v4.0.0
with:
issue-number: ${{ github.event.issue.number }}
body: |
### Instance Creation Results ❌
Failed to create volume.
See details at https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: comment (progress)
uses: ./.github/actions/comment-progress
with:
comment-id: ${{ steps.couc_progress.outputs.comment-id }}
create_ip:
create_volume:
create_instance:
associate_ip: ""
setup_instance: ""
attach_volume: ""
retrieve_connection_url: ""
send_email: ""

Expand Down Expand Up @@ -193,9 +258,11 @@ jobs:
with:
comment-id: ${{ steps.couc_progress.outputs.comment-id }}
create_ip:
create_volume:
create_instance:
associate_ip:
setup_instance: ""
attach_volume: ""
retrieve_connection_url: ""
send_email: ""

Expand Down Expand Up @@ -236,9 +303,11 @@ jobs:
with:
comment-id: ${{ steps.couc_progress.outputs.comment-id }}
create_ip:
create_volume:
create_instance:
associate_ip:
setup_instance:
attach_volume: ""
retrieve_connection_url: ""
send_email: ""

Expand Down Expand Up @@ -299,9 +368,67 @@ jobs:
with:
comment-id: ${{ steps.couc_progress.outputs.comment-id }}
create_ip:
create_volume:
create_instance:
associate_ip:
setup_instance:
attach_volume:
retrieve_connection_url: ""
send_email: ""

- name: Attach Volume
id: attach_volume
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
instance_id=$(openstack server list -f json | \
jq \
--arg instance_name "$INSTANCE_NAME" \
-c '.[] | select(.Name == $instance_name)' | \
jq -r '.ID' | tail -1)
echo "instance_id [$instance_id]"
volume_id=$(openstack volume list -f json | \
jq \
--arg volume_name "$VOLUME_NAME" \
-c '.[] | select(.Name == $volume_name)' | \
jq -r '.ID' | tail -1)
echo "volume_id [$volume_id]"
openstack server set \
--property "exoVolumes::$volume_id={\"name\":\"My Data\"}" \
$instance_id
openstack server add volume \
$instance_id \
$volume_id
env:
INSTANCE_NAME: ${{ steps.define.outputs.instance_name }}
VOLUME_NAME: ${{ steps.define_volume_name.outputs.volume_name }}

- name: comment (failed to attach volume)
if: ${{ steps.attach_volume.outcome == 'failure' && failure() }}
uses: peter-evans/create-or-update-comment@v4.0.0
with:
issue-number: ${{ github.event.issue.number }}
body: |
### Instance Creation Results ❌
Failed to attach volume **${{ steps.define_volume_name.outputs.volume_name }}** to instance **${{ steps.define.outputs.instance_name }}**.
See details at https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: comment (progress)
uses: ./.github/actions/comment-progress
with:
comment-id: ${{ steps.couc_progress.outputs.comment-id }}
create_ip:
create_volume:
create_instance:
associate_ip:
setup_instance:
attach_volume:
retrieve_connection_url:
send_email: ""

Expand Down Expand Up @@ -345,9 +472,11 @@ jobs:
with:
comment-id: ${{ steps.couc_progress.outputs.comment-id }}
create_ip:
create_volume:
create_instance:
associate_ip:
setup_instance:
attach_volume:
retrieve_connection_url:
send_email:

Expand All @@ -368,9 +497,11 @@ jobs:
with:
comment-id: ${{ steps.couc_progress.outputs.comment-id }}
create_ip:
create_volume:
create_instance:
associate_ip:
setup_instance:
attach_volume:
retrieve_connection_url:
send_email:

Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/request-initial-comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,34 @@ jobs:
_The instance name is derived from the GitHub issue number using the template `${{ steps.define.outputs.instance_prefix }}instance-NNN`. The instance may also be located in the exosphere interface using this name._
edit-mode: replace

- name: Define volume name
id: define_volume_name
uses: ./.github/actions/define-volume-name
with:
issue_number: ${{ steps.collect_inputs.outputs.issue_number }}
suffix: ${{ vars.VOLUME_NAME_SUFFIX }}

- name: Find Volume Name Comment
uses: peter-evans/find-comment@v3
id: fc_volume_name
with:
issue-number: ${{ steps.collect_inputs.outputs.issue_number }}
comment-author: "github-actions[bot]"
body-includes: "### Volume Name"

- name: comment (volume name)
uses: peter-evans/create-or-update-comment@v4.0.0
with:
comment-id: ${{ steps.fc_volume_name.outputs.comment-id }}
issue-number: ${{ steps.collect_inputs.outputs.issue_number }}
body: |
### Volume Name
`${{ steps.define_volume_name.outputs.volume_name }}`
_The volume name is derived from the GitHub issue number using the template `My-Data-NNN${{ steps.define_volume_name.outputs.volume_suffix }}`. The volume may also be located in the exosphere interface using this name._
edit-mode: replace

- name: Find Issue Commands Comment
uses: peter-evans/find-comment@v3
id: fc_commands
Expand Down

0 comments on commit 5b46306

Please sign in to comment.