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: long running setup for expired auth token track 2 bug #391

Merged
merged 9 commits into from
Jun 28, 2024

Conversation

Bryce-Soghigian
Copy link
Collaborator

@Bryce-Soghigian Bryce-Soghigian commented Jun 7, 2024

Fixes #

Description
The track 2 sdk has a bug for long living tokens(longer than 24hrs) they will not be refreshed properly. This pr adds a thin wrapper around the GetToken() interface method to set the ExpiresOn timestamp to be earlier and force a token refresh earlier.

How was this change tested?

  • 2 long running clusters both on NAP and Self Hosted ran without seeing expired token errors
  • make presubmit

Does this change impact docs?

  • Yes, PR includes docs updates
  • Yes, issue opened: #
  • No

Release Note


@Bryce-Soghigian Bryce-Soghigian added the kind/experiment experimentation or informal poc level work that warrants PR label Jun 7, 2024
@coveralls
Copy link

coveralls commented Jun 7, 2024

Pull Request Test Coverage Report for Build 9421738010

Details

  • 0 of 16 (0.0%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.04%) to 97.73%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/providers/instance/azure_client.go 0 3 0.0%
pkg/auth/cred.go 0 13 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/auth/cred.go 1 44.44%
Totals Coverage Status
Change from base Build 9388584261: -0.04%
Covered Lines: 36286
Relevant Lines: 37129

💛 - Coveralls

pkg/auth/cred.go Outdated
return azcore.AccessToken{}, err
}
logging.FromContext(ctx).Info("refreshing MDAL Token")
token.ExpiresOn = time.Now().Add(1 * time.Hour)

Choose a reason for hiding this comment

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

I think 2 hours is better since the original expiration time is 2 hours

@coveralls
Copy link

coveralls commented Jun 10, 2024

Pull Request Test Coverage Report for Build 9450969455

Details

  • 0 of 16 (0.0%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.04%) to 97.73%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/providers/instance/azure_client.go 0 3 0.0%
pkg/auth/cred.go 0 13 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/auth/cred.go 1 44.44%
Totals Coverage Status
Change from base Build 9388584261: -0.04%
Covered Lines: 36286
Relevant Lines: 37129

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jun 14, 2024

Pull Request Test Coverage Report for Build 9522232903

Details

  • 0 of 14 (0.0%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.04%) to 97.73%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/providers/instance/azure_client.go 0 1 0.0%
pkg/auth/cred.go 0 13 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/auth/cred.go 1 44.44%
Totals Coverage Status
Change from base Build 9520296180: -0.04%
Covered Lines: 36286
Relevant Lines: 37129

💛 - Coveralls

@Bryce-Soghigian Bryce-Soghigian changed the title [WIP DONT REVIEW] exp: testing long running setup for expired auth token track 2 bug fix: long running setup for expired auth token track 2 bug Jun 20, 2024
@Bryce-Soghigian Bryce-Soghigian marked this pull request as ready for review June 20, 2024 02:15
@coveralls
Copy link

coveralls commented Jun 20, 2024

Pull Request Test Coverage Report for Build 9590583019

Details

  • 0 of 14 (0.0%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.04%) to 97.73%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/providers/instance/azure_client.go 0 1 0.0%
pkg/auth/cred.go 0 13 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/auth/cred.go 1 44.44%
Totals Coverage Status
Change from base Build 9587074007: -0.04%
Covered Lines: 36286
Relevant Lines: 37129

💛 - Coveralls

@andyzhangx
Copy link

does this workaround work? @Bryce-Soghigian

pkg/auth/cred.go Outdated
return azcore.AccessToken{}, err
}
logging.FromContext(ctx).Info("refreshing MDAL Token")
token.ExpiresOn = time.Now().Add(2 * time.Hour)
Copy link

Choose a reason for hiding this comment

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

Do we need to check the original ExpiresOn in case it’s already less than 2 hours?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that would be prudent

Copy link

Choose a reason for hiding this comment

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

IIRC the underlying token credential attempts to fetch from the cache first. It seems like it could return a short-lived token?

Copy link
Member

Choose a reason for hiding this comment

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

yep this value should be set with the minimum value of token expires on and the 2hr we want to use here.

@Bryce-Soghigian
Copy link
Collaborator Author

@andyzhangx yes it seems to be working for over a week for me

@Bryce-Soghigian Bryce-Soghigian added kind/bug Categorizes issue or PR as related to a bug. and removed kind/experiment experimentation or informal poc level work that warrants PR labels Jun 21, 2024
pkg/providers/instance/azure_client.go Show resolved Hide resolved
pkg/auth/cred.go Outdated Show resolved Hide resolved
@Bryce-Soghigian Bryce-Soghigian self-assigned this Jun 22, 2024
pkg/auth/cred.go Outdated Show resolved Hide resolved
pkg/auth/cred.go Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Jun 25, 2024

Pull Request Test Coverage Report for Build 9669960661

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 14 (0.0%) changed or added relevant lines in 2 files are covered.
  • 7 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.04%) to 97.727%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/providers/instance/azure_client.go 0 1 0.0%
pkg/auth/cred.go 0 13 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/auth/cred.go 1 44.44%
pkg/providers/instancetype/instancetypes.go 6 88.3%
Totals Coverage Status
Change from base Build 9587074007: -0.04%
Covered Lines: 36287
Relevant Lines: 37131

💛 - Coveralls

pkg/auth/cred.go Outdated Show resolved Hide resolved
pkg/auth/cred.go Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Jun 25, 2024

Pull Request Test Coverage Report for Build 9670992016

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 14 (0.0%) changed or added relevant lines in 2 files are covered.
  • 7 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.04%) to 97.727%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/providers/instance/azure_client.go 0 1 0.0%
pkg/auth/cred.go 0 13 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/auth/cred.go 1 44.44%
pkg/providers/instancetype/instancetypes.go 6 88.3%
Totals Coverage Status
Change from base Build 9587074007: -0.04%
Covered Lines: 36287
Relevant Lines: 37131

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jun 27, 2024

Pull Request Test Coverage Report for Build 9700805392

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 20 (0.0%) changed or added relevant lines in 2 files are covered.
  • 7 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.06%) to 97.711%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/providers/instance/azure_client.go 0 1 0.0%
pkg/auth/cred.go 0 19 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/auth/cred.go 1 38.1%
pkg/providers/instancetype/instancetypes.go 6 88.3%
Totals Coverage Status
Change from base Build 9587074007: -0.06%
Covered Lines: 36287
Relevant Lines: 37137

💛 - Coveralls

pkg/auth/cred.go Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Jun 27, 2024

Pull Request Test Coverage Report for Build 9701170413

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 22 (0.0%) changed or added relevant lines in 2 files are covered.
  • 7 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.06%) to 97.706%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/providers/instance/azure_client.go 0 1 0.0%
pkg/auth/cred.go 0 21 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/auth/cred.go 1 36.36%
pkg/providers/instancetype/instancetypes.go 6 88.3%
Totals Coverage Status
Change from base Build 9587074007: -0.06%
Covered Lines: 36287
Relevant Lines: 37139

💛 - Coveralls

Copy link
Member

@bcho bcho left a comment

Choose a reason for hiding this comment

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

LGTM

@coveralls
Copy link

coveralls commented Jun 28, 2024

Pull Request Test Coverage Report for Build 9718106940

Details

  • 0 of 22 (0.0%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.06%) to 97.706%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/providers/instance/azure_client.go 0 1 0.0%
pkg/auth/cred.go 0 21 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/auth/cred.go 1 36.36%
Totals Coverage Status
Change from base Build 9717899097: -0.06%
Covered Lines: 36287
Relevant Lines: 37139

💛 - Coveralls

@Bryce-Soghigian Bryce-Soghigian merged commit 23ae64d into main Jun 28, 2024
9 of 10 checks passed
@Bryce-Soghigian Bryce-Soghigian deleted the bsoghigian/token/repro branch June 28, 2024 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants