Update AccessToken Status When Site is Deleted#2416
Update AccessToken Status When Site is Deleted#2416shailie-1998 wants to merge 1 commit intoskupperproject:mainfrom
Conversation
|
Fixes #2408 |
| wasOperational := link.IsReady() | ||
| if link.SetOperational(operational, remoteSiteId, remoteSiteName) { | ||
| return s.updateLinkStatus(link) | ||
| err := s.updateLinkStatus(link) | ||
| // If link became non-operational, update associated access tokens | ||
| if wasOperational && !operational { | ||
| s.updateAccessTokensForLink(link) | ||
| } |
There was a problem hiding this comment.
@shailie-1998 I do not think this change is needed.
The state of a Link resource which was generated from an AccessToken, should not affect the state of the AccessToken itself.
There was a problem hiding this comment.
@fgiorgetti I agree that the state of a Link resource shouldn’t directly drive the state of the AccessToken.
That said, I’m trying to understand what the right trigger point would be for updating the AccessToken status. In the current flow, when the remote site is deleted, we update the router and network status, which eventually marks the Link as non-operational. However, the AccessToken continues to remain in a Ready state, even though it’s no longer effectively usable.
From your perspective, what would be the appropriate place to update the AccessToken status in such scenarios? Should it be tied to some form of network status change, absence of a valid AccessGrant, or something else entirely?
There was a problem hiding this comment.
This is an interesting question. Once a site is deleted, any access tokens are no longer usable. Even if you create a new access token in a namespace then create a site, that access token will not take effect. It must be deleted and re-applied for it to work.
It seems that an AccessToken is either "pending" or "redeemed" (or "failed"). "Ready" doesn't properly describe the state of an AccessToken. Further, if you apply an AccessToken when there is no Site, it gets no status and nothing ever happens with it. I would think such an AccessToken would be in "pending" state until a Site was created, then it would transition to "redeemed".
| for _, token := range tokenList.Items { | ||
| if token.IsRedeemed() { | ||
| // Mark the token as failed due to site deletion | ||
| if token.SetRedeemedWithSiteDeletion(fmt.Errorf("Site has been deleted")) { |
There was a problem hiding this comment.
If a Site is deleted but then a new one is created, right after that, this message might confuse users, as it says that the site has been deleted, but there is a site on the namespace.
What if we use something more precise, like: Already redeemed for a deleted site ?
Summary
This PR implements functionality to update AccessToken status when a site is deleted, covering two scenarios: local site deletion and remote site deletion.
Solution
Scenario 1: Local Site Deletion
Implementation:
Test Evidence
Scenario 2: Remote Site Deletion
Implementation:
Test Evidence