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

Don't fail requests if we can't update clusterAuthToken.lastUsedAt #32

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

pmatseykanets
Copy link
Contributor

@pmatseykanets pmatseykanets commented Feb 6, 2025

Ref: rancher/rancher#48986

Ideally we want to migrate cluster.cattle.io to wrangler and use patch for lastUsedAt updates instead as we do for the counterpart tokens in the local cluster.

@pmatseykanets pmatseykanets self-assigned this Feb 6, 2025
@pmatseykanets pmatseykanets requested a review from a team as a code owner February 6, 2025 18:19
@samjustus
Copy link

samjustus commented Feb 6, 2025

rancher/rancher#48986

@pmatseykanets pmatseykanets changed the title Don't fail requests if can't update lastUsedAt Don't fail requests if we can't update clusterAuthToken.lastUsedAt Feb 6, 2025
@@ -135,31 +133,31 @@ func (h *KubeAPIHandlers) v1getAndVerifyUser(accessKey, secretKey string) (*type

if refresh.Add(refreshPeriod).Before(now) {
clusterUserAttribute.NeedsRefresh = true
shouldUpdate = true
if _, err := h.clusterUserAttribute.Update(clusterUserAttribute); err != nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously we weren't updating the clusterUserAttribute. Why are we adding this here?

Copy link
Contributor Author

@pmatseykanets pmatseykanets Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We accidentally stopped updating it in #28 and now we do again as we should.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it thanks for the context!

_, err = h.clusterAuthTokens.Update(clusterAuthToken)
if err != nil {
return nil, fmt.Errorf("error updating clusterAuthToken %s: %w", clusterAuthToken.Name, err)
if _, err = h.clusterAuthTokens.Update(clusterAuthToken); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future we may want to migrate to wrangler and use patch here instead as we do for the local cluster.

@@ -135,31 +133,31 @@ func (h *KubeAPIHandlers) v1getAndVerifyUser(accessKey, secretKey string) (*type

if refresh.Add(refreshPeriod).Before(now) {
clusterUserAttribute.NeedsRefresh = true
shouldUpdate = true
if _, err := h.clusterUserAttribute.Update(clusterUserAttribute); err != nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it thanks for the context!

Copy link

@crobby crobby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, seems to do what it says it does

@pmatseykanets pmatseykanets merged commit a83f0f8 into rancher:master Feb 6, 2025
4 checks passed
@pmatseykanets pmatseykanets deleted the lastUsedAt-updates branch February 6, 2025 20:28
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.

4 participants