Fix cloud-credential expiry display #12335
Merged
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 functionexpires()
will return an integer0
. In Javascript, this is a falsy value, therefore the conditionis met and the getter function
expiresIn()
returnsnull
instead of the expected time difference (also an integer0
, indicating that the cloud-credential is expired).By checking not against falsiness, but against
undefined
explicitly in the getter functionexpiresIn()
, the correct time difference is returned and the cloud-credential will be displayed correctly as expired.Areas or cases that should be tested
Local testing done via
yarn dev
with FirefoxOutcome 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
Screenshot/Video
Before:
After:
Checklist