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

Upstream changes to fix token validity and utilizing inmemory creds source #6001

Conversation

pmahindrakar-oss
Copy link
Contributor

@pmahindrakar-oss pmahindrakar-oss commented Nov 13, 2024

Why are the changes needed?

With changes in this PR #5407 only one request was allowed to fetch auth token from the provider if multiple parallel requests came in.

There were two calls made to MaterializeCredentials, the purpose of which was to fetch the token from cache or get new token and add them to communication channel.

Expectation of fetching new token on the first MaterializeCredentials was unexpected as this was only expected to fetch the token from cache if available and add it to the communication channel.

The new change fixes this issue so that the first call is always fetching from in memory cache by introducing a new InMemoryTokenSourceProvider.

Also the Oauth token library uses relative time using the expires_in field for validity checks which doesn't work when we are returning cache tokens as it incorrectly gives an invalid expiry and client tries to use this invalid token

Modified the logic to define custom validity function which parses the exp claim and checks for validity. Also added this to baseorchestrator so that all the other auth mechanisms use the same Validity check

How was this patch tested?

This has been tested internally on Union cluster

Setup process

Screenshots

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

Copy link

codecov bot commented Nov 13, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 20 lines in your changes missing coverage. Please review.

Project coverage is 36.97%. Comparing base (3c3ae05) to head (29e31d3).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
flyteidl/clients/go/admin/utils/token_utils.go 66.66% 6 Missing and 2 partials ⚠️
flyteidl/clients/go/admin/auth_interceptor.go 60.00% 4 Missing and 2 partials ⚠️
flyteidl/clients/go/admin/token_source_provider.go 77.77% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6001      +/-   ##
==========================================
+ Coverage   36.95%   36.97%   +0.02%     
==========================================
  Files        1310     1312       +2     
  Lines      131451   131525      +74     
==========================================
+ Hits        48575    48632      +57     
- Misses      78655    78666      +11     
- Partials     4221     4227       +6     
Flag Coverage Δ
unittests-datacatalog 51.58% <ø> (ø)
unittests-flyteadmin 54.07% <ø> (ø)
unittests-flytecopilot 22.23% <ø> (ø)
unittests-flytectl 62.39% <ø> (ø)
unittests-flyteidl 7.05% <75.00%> (+0.09%) ⬆️
unittests-flyteplugins 53.83% <ø> (ø)
unittests-flytepropeller 43.10% <ø> (+0.02%) ⬆️
unittests-flytestdlib 55.31% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Cherry-pick the following change to populate oauth metadata once on initialization using Sync.Do
ca04314

Tested locally using uctl-admin and fetched projects calling into admin which exercises the auth flow
https://buildkite.com/unionai/org-staging-sync/builds/3541

Rollout to all canary and then prod tenants

- [x] To be upstreamed to OSS

*TODO: Link Linear issue(s) using [magic words](https://linear.app/docs/github#magic-words). `fixes` will move to merged status, while `ref` will only link the PR.*

* [ ] Added tests
* [ ] Ran a deploy dry run and shared the terraform plan
* [ ] Added logging and metrics
* [ ] Updated [dashboards](https://unionai.grafana.net/dashboards) and [alerts](https://unionai.grafana.net/alerting/list)
* [ ] Updated documentation

Signed-off-by: pmahindrakar-oss <[email protected]>
…token (#330)

* Add logs for token

* add logs

* Fixing the validity check logic for token

* nit

* nit

* Adding in memory token source provider

* nit

* changed Valid method to log and ignore parseDateClaim error

* nit

* Fix unit tests

* lint

* fix unit tests

Signed-off-by: pmahindrakar-oss <[email protected]>
Signed-off-by: pmahindrakar-oss <[email protected]>
@pmahindrakar-oss pmahindrakar-oss force-pushed the union/upstream-d6b17dc0c1addc68c593fc79d4c53a9f081a6387 branch from 185248b to 29e31d3 Compare November 13, 2024 01:07
@pmahindrakar-oss pmahindrakar-oss marked this pull request as ready for review November 13, 2024 19:48
@pmahindrakar-oss pmahindrakar-oss merged commit da220be into master Nov 14, 2024
51 checks passed
@pmahindrakar-oss pmahindrakar-oss deleted the union/upstream-d6b17dc0c1addc68c593fc79d4c53a9f081a6387 branch November 14, 2024 03:01
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