-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[v15] Update Proxy Features #48224
Merged
+303
−45
Merged
[v15] Update Proxy Features #48224
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9fdd9b0
Update proxy features (#45979)
mcbattirola 72b7e75
Export ClusterFeatures
mcbattirola cf91623
Merge fix
mcbattirola e416820
Fix tests
mcbattirola b89f5f9
Merge branch 'branch/v15' into mcbattirola/v15/update-proxy-features
mcbattirola acafb60
Merge branch 'branch/v15' into mcbattirola/v15/update-proxy-features
mcbattirola File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Teleport | ||
* Copyright (C) 2024 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package web | ||
|
||
import ( | ||
"github.com/gravitational/teleport/api/client/proto" | ||
) | ||
|
||
// SetClusterFeatures sets the flags for supported and unsupported features. | ||
// TODO(mcbattirola): make method unexported, fix tests using it to set | ||
// test modules instead. | ||
func (h *Handler) SetClusterFeatures(features proto.Features) { | ||
h.Mutex.Lock() | ||
defer h.Mutex.Unlock() | ||
|
||
h.ClusterFeatures = features | ||
} | ||
|
||
// GetClusterFeatures returns flags for supported and unsupported features. | ||
func (h *Handler) GetClusterFeatures() proto.Features { | ||
h.Mutex.Lock() | ||
defer h.Mutex.Unlock() | ||
|
||
return h.ClusterFeatures | ||
} | ||
|
||
// startFeatureWatcher periodically pings the auth server and updates `clusterFeatures`. | ||
// Must be called only once per `handler`, otherwise it may close an already closed channel | ||
// which will cause a panic. | ||
// The watcher doesn't ping the auth server immediately upon start because features are | ||
// already set by the config object in `NewHandler`. | ||
func (h *Handler) startFeatureWatcher() { | ||
ticker := h.clock.NewTicker(h.cfg.FeatureWatchInterval) | ||
h.log.WithField("interval", h.cfg.FeatureWatchInterval).Info("Proxy handler features watcher has started") | ||
ctx := h.cfg.Context | ||
|
||
defer ticker.Stop() | ||
for { | ||
select { | ||
case <-ticker.Chan(): | ||
h.log.Info("Pinging auth server for features") | ||
pingResponse, err := h.GetProxyClient().Ping(ctx) | ||
if err != nil { | ||
h.log.WithError(err).Error("Auth server ping failed") | ||
continue | ||
} | ||
|
||
h.SetClusterFeatures(*pingResponse.ServerFeatures) | ||
h.log.WithField("features", pingResponse.ServerFeatures).Info("Done updating proxy features") | ||
case <-ctx.Done(): | ||
h.log.Info("Feature service has stopped") | ||
return | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI,
cmp.Or
requires Go 1.22 or later.We build with Go 1.22, so that's why the build hasn't failed.
We do however set the language level to Go 1.21 in branch/v15, which generates a warning.
At this point, we might as well just update the go directive to 1.22 here.