Skip to content

Fix variable name in EKS command for token expiration timestamp - #53720

Merged
vincbeck merged 1 commit into
apache:mainfrom
aaron-y-chen:bug-53626_fix_empty_expirationTimestamp
Jul 25, 2025
Merged

vincbeck merged 1 commit into
apache:mainfrom
aaron-y-chen:bug-53626_fix_empty_expirationTimestamp

Conversation

@aaron-y-chen

Copy link
Copy Markdown
Contributor

Closes: #53626

Why

There is a typo in the variable.

{{"expirationTimestamp": "%s","token": "%s"}}}}' "$expiration_timestamp" "$token")

How

Change it to timestamp.

What

cat <<EOF > get_token.py
output=\$(cat output.txt)

status=\$?

if [ "\$status" -ne 0 ]; then
    printf '%s' "\$output" >&2
    exit "\$status"
fi

# Use pure bash below to parse so that it's posix compliant
last_line=\${output##*$'\n'}  # strip everything up to the last newline

timestamp=\${last_line#expirationTimestamp: }  # drop the label
timestamp=\${timestamp%%,*}  # keep up to the first comma

token=\${last_line##*, token: }  # text after ", token: "

json_string=\$(printf '{"kind": "ExecCredential","apiVersion":                 "client.authentication.k8s.io/v1alpha1","spec": {},"status":                 {"expirationTimestamp": "%s","token": "%s"}}' "\$expiration_timestamp" "\$token")
echo \$json_string
EOF

Then we can see the expirationTimestamp is back.

root@c30540d9dba1:/opt/airflow# bash get_token.py 
{"kind": "ExecCredential","apiVersion": "client.authentication.k8s.io/v1alpha1","spec": {},"status": {"expirationTimestamp": "2025-07-22T08:47:47Z","token": "foo"}}

@boring-cyborg boring-cyborg Bot added area:providers provider:amazon AWS/Amazon - related issues labels Jul 24, 2025
@eladkal
eladkal requested a review from vincbeck July 25, 2025 15:16
@vincbeck
vincbeck merged commit 8881579 into apache:main Jul 25, 2025
@peloyeje

Copy link
Copy Markdown
Contributor

Thank you!

@aaron-y-chen

Copy link
Copy Markdown
Contributor Author

My pleasure 😁

@aaron-y-chen
aaron-y-chen deleted the bug-53626_fix_empty_expirationTimestamp branch July 25, 2025 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:amazon AWS/Amazon - related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty expirationTimestamp after parsing output of eks_get_token.py

3 participants