-
Notifications
You must be signed in to change notification settings - Fork 4.6k
xds/bootstrap: add trusted_xds_server server feature
#8692
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -162,6 +162,29 @@ func (c *clientImpl) decrRef() int32 { | |
| return atomic.AddInt32(&c.refCount, -1) | ||
| } | ||
|
|
||
| func buildServerConfigs(bootstrapSC []*bootstrap.ServerConfig, grpcTransportConfigs map[string]grpctransport.Config, gServerCfgMap map[xdsclient.ServerConfig]*bootstrap.ServerConfig) ([]xdsclient.ServerConfig, error) { | ||
| var gServerCfg []xdsclient.ServerConfig | ||
| for _, sc := range bootstrapSC { | ||
| if err := populateGRPCTransportConfigsFromServerConfig(sc, grpcTransportConfigs); err != nil { | ||
| return nil, err | ||
| } | ||
| var serverFeatures xdsclient.ServerFeature | ||
| if sc.ServerFeaturesIgnoreResourceDeletion() { | ||
| serverFeatures = serverFeatures | xdsclient.ServerFeatureIgnoreResourceDeletion | ||
| } | ||
| if sc.ServerFeaturesTrustedXDSServer() { | ||
| serverFeatures = serverFeatures | xdsclient.ServerFeatureTrustedXDSServer | ||
| } | ||
| gsc := xdsclient.ServerConfig{ | ||
| ServerIdentifier: clients.ServerIdentifier{ServerURI: sc.ServerURI(), Extensions: grpctransport.ServerIdentifierExtension{ConfigName: sc.SelectedChannelCreds().Type}}, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Please use a separate line for individual fields (in sub-struct fields as well). I understand this is continuing to do what the existing code was doing. But that happened to be a part of a giant refactor, and it was often easy to miss things during the review. See: go/go-style/decisions#literal-formatting Thanks. |
||
| ServerFeature: serverFeatures, | ||
| } | ||
| gServerCfg = append(gServerCfg, gsc) | ||
| gServerCfgMap[gsc] = sc | ||
| } | ||
| return gServerCfg, nil | ||
| } | ||
|
|
||
| // buildXDSClientConfig builds the xdsclient.Config from the bootstrap.Config. | ||
| func buildXDSClientConfig(config *bootstrap.Config, metricsRecorder estats.MetricsRecorder, target string, watchExpiryTimeout time.Duration) (xdsclient.Config, error) { | ||
| grpcTransportConfigs := make(map[string]grpctransport.Config) | ||
|
|
@@ -175,30 +198,16 @@ func buildXDSClientConfig(config *bootstrap.Config, metricsRecorder estats.Metri | |
| if len(cfg.XDSServers) >= 1 { | ||
| serverCfg = cfg.XDSServers | ||
| } | ||
| var gServerCfg []xdsclient.ServerConfig | ||
| for _, sc := range serverCfg { | ||
| if err := populateGRPCTransportConfigsFromServerConfig(sc, grpcTransportConfigs); err != nil { | ||
| return xdsclient.Config{}, err | ||
| } | ||
| gsc := xdsclient.ServerConfig{ | ||
| ServerIdentifier: clients.ServerIdentifier{ServerURI: sc.ServerURI(), Extensions: grpctransport.ServerIdentifierExtension{ConfigName: sc.SelectedChannelCreds().Type}}, | ||
| IgnoreResourceDeletion: sc.ServerFeaturesIgnoreResourceDeletion()} | ||
| gServerCfg = append(gServerCfg, gsc) | ||
| gServerCfgMap[gsc] = sc | ||
| gsc, err := buildServerConfigs(serverCfg, grpcTransportConfigs, gServerCfgMap) | ||
| if err != nil { | ||
| return xdsclient.Config{}, err | ||
| } | ||
| gAuthorities[name] = xdsclient.Authority{XDSServers: gServerCfg} | ||
| gAuthorities[name] = xdsclient.Authority{XDSServers: gsc} | ||
| } | ||
|
|
||
| gServerCfgs := make([]xdsclient.ServerConfig, 0, len(config.XDSServers())) | ||
| for _, sc := range config.XDSServers() { | ||
| if err := populateGRPCTransportConfigsFromServerConfig(sc, grpcTransportConfigs); err != nil { | ||
| return xdsclient.Config{}, err | ||
| } | ||
| gsc := xdsclient.ServerConfig{ | ||
| ServerIdentifier: clients.ServerIdentifier{ServerURI: sc.ServerURI(), Extensions: grpctransport.ServerIdentifierExtension{ConfigName: sc.SelectedChannelCreds().Type}}, | ||
| IgnoreResourceDeletion: sc.ServerFeaturesIgnoreResourceDeletion()} | ||
| gServerCfgs = append(gServerCfgs, gsc) | ||
| gServerCfgMap[gsc] = sc | ||
| gServerCfgs, err := buildServerConfigs(config.XDSServers(), grpcTransportConfigs, gServerCfgMap) | ||
| if err != nil { | ||
| return xdsclient.Config{}, err | ||
| } | ||
|
|
||
| node := config.Node() | ||
|
|
||
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.
Nit: You could get rid of the newline and add a trailing comment to this line saying this field stores a bitmap of supported features.