Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cloud-credential expiry display #12335

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

m-ildefons
Copy link
Contributor

@m-ildefons m-ildefons commented Oct 23, 2024

Fix cloud-credential being displayed if the expiry annotation has a Unix timestamp of "0".

When Rancher is upgraded and there are cloud-credentials for a Harvester cluster without a token (e.g. when the token expired and purged or was manually removed), the cloud-credential's expiry will be updated with a Unix timestamp of "0" (i.e. as if the token had expired at 00:00 AM on Jan 1st 1970), since the actual time of expiry of the token can not be determined.
This fix makes the UI display such a cloud credential correctly as "expired".

Summary

Related to: rancher/rancher#47583
Related to: rancher/rancher#47667

Occurred changes and/or fixed issues

Technical notes summary

When the cloud-credential annotation rancher.io/expiration-timestamp has the value "0", the getter function expires() will return an integer 0. In Javascript, this is a falsy value, therefore the condition

if (!this.expires)

is met and the getter function expiresIn() returns null instead of the expected time difference (also an integer 0, indicating that the cloud-credential is expired).
By checking not against falsiness, but against undefined explicitly in the getter function expiresIn(), the correct time difference is returned and the cloud-credential will be displayed correctly as expired.

Areas or cases that should be tested

  • Rancher Upgrade
  • Cloud Credential expiry

Local testing done via yarn dev with Firefox

  1. Install Harvester (e.g. v1.3.2)
  2. Install Rancher v2.9.2
  3. Import Harvester cluster into Rancher for virtualization management
  4. Set default kubeconfig TTL to a short period (e.g. 10 minutes)
  5. Create new cloud-credential
  6. Wait for cloud-credential to expire and the associated kubeconfig-token to be removed. Alternatively just delete the token
  7. Upgrade Rancher

Outcome before the fix:
The UI displays the cloud-credential, but omits the warning that it is expired. Nevertheless, there is the menu option to renew it.

Expected outcome with this fix:
The UI should display the cloud-credential as expired and offer a menu option to renew it.

Areas which could experience regressions

  • cloud credential display, renewal

Screenshot/Video

Before:
Screenshot at 2024-10-23 13-02-09

After:
Screenshot at 2024-10-23 13-01-44

Checklist

  • The PR is linked to an issue and the linked issue has a Milestone, or no issue is needed
  • The PR has a Milestone
  • The PR template has been filled out
  • The PR has been self reviewed
  • The PR has a reviewer assigned
  • The PR has automated tests or clear instructions for manual tests and the linked issue has appropriate QA labels, or tests are not needed
  • The PR has reviewed with UX and tested in light and dark mode, or there are no UX changes

Fix cloud-credential being displayed if the expiry annotation has a Unix
timestamp of "0".

When Rancher is upgraded and there are cloud-credentials for a Harvester
cluster without a token (e.g. when the token expired and purged or
was manually removed), the cloud-credential's expiry will be updated
with a Unix timestamp of "0" (i.e. as if the token had expired at 00:00
AM on Jan 1st 1970), since the actual time of expiry of the token can
not be determined.
This fix makes the UI display such a cloud credential correctly as
"expired".

Signed-off-by: Moritz Röhrich <moritz.rohrich@suse.com>
@richard-cox richard-cox merged commit bbbe926 into rancher:master Oct 24, 2024
34 checks passed
@richard-cox
Copy link
Member

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