Skip to content

Use a new token in terminate_command#25

Merged
sadsfae merged 2 commits into
quadsproject:developmentfrom
mcornea:main
Mar 25, 2026
Merged

Use a new token in terminate_command#25
sadsfae merged 2 commits into
quadsproject:developmentfrom
mcornea:main

Conversation

@mcornea

@mcornea mcornea commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

The token generated at playbook runtime expires after a couple of hours so updating the terminate command to use a fresh token.

@sadsfae

sadsfae commented Mar 3, 2026

Copy link
Copy Markdown
Collaborator

@mcornea hey thanks for submitting this, we must have missed it last year. I think it's on the right track and fixes recording a potentially stale token for someone to re-use.

First, can you instead PR against development branch? That's where all PR's should go. I can change it for you on the Github end if it's easier.

Secondly can you also address ensuring that terminate_command also gets the updated token value along with the generated quads_commands txt file?

e.g.

--- a/quads_self_schedule.yml
+++ b/quads_self_schedule.yml
@@ -124,8 +124,7 @@
                {%- set result = [] -%}
                {%- for asn in active_assignments.json -%}
                  {%- set check_cmd = "curl -s https://{}/api/v3/assignments/{} | jq '.validated'".format(quads_api_server, asn.id) -%}
-                  {%- set term_cmd = "curl -s -k -X POST -H 'Authorization: Bearer {}' https://{}/api/v3/assignments/terminate/{} | \
-                    jq".format(quads_token, quads_api_server, asn.id) -%}
+                  {%- set term_cmd = "curl -s -k -X POST -H \"Authorization: Bearer $(curl -s -k -X POST -u '{}:{}' https://{}/api/v3/login/ | jq -r '.auth_token')\" https://{}/api/v3/assignments/terminate/{} | jq".format(quads_user_email, quads_password, quads_api_server, quads_api_server, asn.id) -%}
                  {%- set _ = asn.update({'check_status_command': check_cmd, 'terminate_command': term_cmd}) -%}
                  {%- set _ = result.append(asn) -%}
                {%- endfor -%}
@@ -238,8 +237,9 @@
       ansible.builtin.set_fact:
         check_status_command: "curl -s https://{{ quads_api_server }}/api/v3/assignments/{{ assignment_id }} | jq '.validated'"
         terminate_command: >-
-          curl -s -k -X POST -H 'Authorization: Bearer {{ quads_token }}'
+          curl -s -k -X POST -H "Authorization: Bearer $(curl -s -k -X POST -u '{{ quads_user_email }}:{{ quads_password }}'
+          https://{{ quads_api_server }}/api/v3/login/ | jq -r '.auth_token')"
           https://{{ quads_api_server }}/api/v3/assignments/terminate/{{ assignment_id }} | jq
       changed_when: false
```       

@sadsfae sadsfae changed the base branch from main to development March 5, 2026 19:33
The token generated at playbook runtime expires after
a couple of hours so updating the terminate command to use
a fresh token.

Signed-off-by: Marius Cornea <mcornea@redhat.com>
@sadsfae sadsfae merged commit 5a0ea34 into quadsproject:development Mar 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants