Skip to content

Commit

Permalink
feat(control-instance): Check task state before running command
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfr committed Aug 14, 2024
1 parent f326bc1 commit 1ba6ab9
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/control-instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,39 @@ jobs:
`${{ steps.command.outputs.command_name }}` command failed because **${{ steps.define.outputs.instance_name }}** instance does not exist.
- name: Check if server action already in progress
id: check_task_state
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
task_state=$(openstack server show instance-30 -f json | \
jq -r '.["OS-EXT-STS:task_state"]')
echo "task_state [$task_state]"
echo "task_state=$task_state" >> $GITHUB_OUTPUT
if [[ "$task_state" != "null" ]]; then
echo "::error ::Server action already in progress. Task state is '$task_state'."
exit 1
fi
env:
INSTANCE_NAME: ${{ steps.define.outputs.instance_name }}

- name: comment (server action already in progress)
if: ${{ steps.check_task_state.outcome == 'failure' && failure() }}
uses: peter-evans/[email protected]
with:
issue-number: ${{ github.event.issue.number }}
body: |
### Command Results ❌
`${{ steps.command.outputs.command_name }}` command failed to be applied to **${{ steps.define.outputs.instance_name }}** instance.
A server action is already in progress. Task state is `${{ steps.check_task_state.outputs.task_state }}`.
See details at https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Execute command
id: execute_command
if:
Expand Down

0 comments on commit 1ba6ab9

Please sign in to comment.