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

Update proxy features #45979

Merged
merged 41 commits into from
Oct 1, 2024
Merged

Update proxy features #45979

merged 41 commits into from
Oct 1, 2024

Conversation

mcbattirola
Copy link
Contributor

@mcbattirola mcbattirola commented Aug 28, 2024

The proxy service only reads features at startup, leading to potential stale features if they change after the initial load. Some code paths (e.g., SCIM web handlers) check features during requests, which means proxies must be restarted when features change.

This PR introduces a startFeatureWatcher method in the web handler. The watcher periodically pings the auth server (every 5 to 10 minutes) to fetch and update features, ensuring they remain up-to-date without restarting the proxy.

I chose to add the watcher within the handler rather than service.TeleportProcess to minimize the impact on other services. This avoids unintended side effects, as the proxy handler is currently the only component requiring dynamic feature updates. If other services need this in the future, we can consider moving the watcher to a higher-level component. Let me know what you think.

Closes #39161

@mcbattirola mcbattirola force-pushed the mcbattirola/update-proxy-features branch from 7ef795d to b610f4c Compare August 28, 2024 19:34
entitlements/entitlements.go Outdated Show resolved Hide resolved
lib/web/apiserver.go Outdated Show resolved Hide resolved
lib/web/apiserver.go Outdated Show resolved Hide resolved
lib/web/features.go Outdated Show resolved Hide resolved
lib/web/apiserver.go Outdated Show resolved Hide resolved
@mcbattirola mcbattirola force-pushed the mcbattirola/update-proxy-features branch from a5561d3 to 0b30b7b Compare August 29, 2024 12:01
@mcbattirola mcbattirola force-pushed the mcbattirola/update-proxy-features branch from 08a8cf0 to 5c8233e Compare September 2, 2024 13:01
@mcbattirola mcbattirola marked this pull request as ready for review September 2, 2024 13:59
@mcbattirola mcbattirola marked this pull request as draft September 2, 2024 13:59
Copy link

github-actions bot commented Sep 2, 2024

The PR changelog entry failed validation: Changelog entry not found in the PR body. Please add a "no-changelog" label to the PR, or changelog lines starting with changelog: followed by the changelog entries for the PR.

@github-actions github-actions bot requested review from r0mant and rudream September 2, 2024 13:59
@mcbattirola mcbattirola added the no-changelog Indicates that a PR does not require a changelog entry label Sep 2, 2024
@mcbattirola mcbattirola marked this pull request as ready for review September 2, 2024 16:05
lib/web/apiserver_test.go Outdated Show resolved Hide resolved
lib/web/apiserver_test.go Outdated Show resolved Hide resolved
lib/web/apiserver_test.go Outdated Show resolved Hide resolved
@mcbattirola mcbattirola added this pull request to the merge queue Sep 30, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 30, 2024
@mcbattirola mcbattirola added this pull request to the merge queue Sep 30, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 30, 2024
@mcbattirola mcbattirola added this pull request to the merge queue Oct 1, 2024
Merged via the queue into master with commit 75bc1f2 Oct 1, 2024
39 checks passed
@mcbattirola mcbattirola deleted the mcbattirola/update-proxy-features branch October 1, 2024 15:18
@public-teleport-github-review-bot

@mcbattirola See the table below for backport results.

Branch Result
branch/v16 Create PR

mcbattirola added a commit that referenced this pull request Oct 31, 2024
* Add feature watcher

* Add test

* Update godocs, fix typos, rename SupportEntitlementsCompatibility to BackfillFeatures

* Godocs; rename start and stop functions

* Use `Feature` prefix in var names instead of `License`

* Fix lint

* Fix TestGetWebConfig_LegacyFeatureLimits

* Fix TestGetWebConfig_WithEntitlements

* Fix tests and lint

* Remove sync.Once

* Add jitter

* Remove Ping call from getUserContext

* Move entitlements test to entitlements package

* Apply suggestions from code review: godoc and tests improvement.

Co-authored-by: Zac Bergquist <[email protected]>

* Improve tests

* Shadow `t` in EventuallyWithT closure to avoid mistakes

* Improve startFeatureWatcher godoc

* Log features on update

* Log features on update

* Avoid race condition on test

* Improve TODO comment

Co-authored-by: rosstimothy <[email protected]>

* Use handler config context

* Start feature watcher in NewHandler

* Improve startFeatureWatcher godocs

* Add TODO to unexport SetClusterFeatures

* Remove featureWatcherReady

* Use require in require.EventuallyWithT in cases where an error is not expected

* Use return of assert.NoError` to return early on require.EventuallyWithT

---------

Co-authored-by: Zac Bergquist <[email protected]>
Co-authored-by: rosstimothy <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Nov 4, 2024
* Update proxy features (#45979)

* Add feature watcher

* Add test

* Update godocs, fix typos, rename SupportEntitlementsCompatibility to BackfillFeatures

* Godocs; rename start and stop functions

* Use `Feature` prefix in var names instead of `License`

* Fix lint

* Fix TestGetWebConfig_LegacyFeatureLimits

* Fix TestGetWebConfig_WithEntitlements

* Fix tests and lint

* Remove sync.Once

* Add jitter

* Remove Ping call from getUserContext

* Move entitlements test to entitlements package

* Apply suggestions from code review: godoc and tests improvement.

Co-authored-by: Zac Bergquist <[email protected]>

* Improve tests

* Shadow `t` in EventuallyWithT closure to avoid mistakes

* Improve startFeatureWatcher godoc

* Log features on update

* Log features on update

* Avoid race condition on test

* Improve TODO comment

Co-authored-by: rosstimothy <[email protected]>

* Use handler config context

* Start feature watcher in NewHandler

* Improve startFeatureWatcher godocs

* Add TODO to unexport SetClusterFeatures

* Remove featureWatcherReady

* Use require in require.EventuallyWithT in cases where an error is not expected

* Use return of assert.NoError` to return early on require.EventuallyWithT

---------

Co-authored-by: Zac Bergquist <[email protected]>
Co-authored-by: rosstimothy <[email protected]>

* Export ClusterFeatures

* Merge fix

* Fix tests

---------

Co-authored-by: Zac Bergquist <[email protected]>
Co-authored-by: rosstimothy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v16 no-changelog Indicates that a PR does not require a changelog entry size/md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proxy web handler p.h.ClusterFeatures are stale upon cloud feature changes
5 participants