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

certprovider-api: bootstrap support for certificate providers #3901

Merged
merged 2 commits into from Sep 24, 2020

Conversation

easwars
Copy link
Contributor

@easwars easwars commented Sep 23, 2020

Changes include:

  • Exporting the GetBuilder function from certprovider package.
  • Add a CertProviderConfigs field in the Config type exported by the bootstrap package. This will contain the parsed certprovider configs.

// If no builder is registered with the provided name, nil will be returned.
func getBuilder(name string) Builder {
func GetBuilder(name string) Builder {
Copy link
Contributor

Choose a reason for hiding this comment

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

This package is not internal, so this means the users can GetBuilder() directly.
Did we want users to use the store only?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched back to not exporting, and using the internal package trick now.

if err != nil {
return nil, fmt.Errorf("xds: Config parsing for plugin %q failed: %v", name, err)
}
configs[instance] = c
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we not need the name in the returned config as well? How will the consumer of this config know which builder to use?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Thank you. Fixed.

return nil, fmt.Errorf("xds: json.Unmarshal(%v) for field %q failed during bootstrap: %v", string(v), k, err)
}
configs := make(map[string]certprovider.StableConfig)
for instance, data := range providerInstances {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is an instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A plugin_instance, which represents a plugin_name+plugin_config.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably minor detail.

Why does the instance need an "instance_name"? Would we have two instances with the same plugin_name, but different config? And since we always stop at the first valid config, what's the point?

This is similar to what we need for the balancing policy + config. We didn't make it a map[string]{policy+config}, but a []{policy+config}.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we can have two different instances with same plugin_name but different config. An instance is supposed to represent an instantiation of a plugin (which includes the plugin_name+config).

We don't stop at the first valid config here. We process all configs and use the instance specified by the control plane.

if len(gotCfgs) != len(wantCfgs) {
return fmt.Errorf("config.CertProviderConfigs is %d entries, want %d", len(gotCfgs), len(wantCfgs))
}
for name, gotCfg := range gotCfgs {
Copy link
Contributor

Choose a reason for hiding this comment

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

The key of this map should be instance, not name, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was going the right thing, just using the wrong variable name. :) Fixed it too.

* Do not export `getBuilder` from `certprovider` package.
* Include `pluginName` in configs exported by the `bootstrap` package.
Copy link
Contributor Author

@easwars easwars left a comment

Choose a reason for hiding this comment

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

Handled all your comments. Thanks for the catch.
I can't seem to be able to reply to your comments because some of those changes are undone now.

return nil, fmt.Errorf("xds: json.Unmarshal(%v) for field %q failed during bootstrap: %v", string(v), k, err)
}
configs := make(map[string]certprovider.StableConfig)
for instance, data := range providerInstances {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A plugin_instance, which represents a plugin_name+plugin_config.

@easwars
Copy link
Contributor Author

easwars commented Sep 24, 2020

Now, I was able to reply to your individual comments as well.

return nil, fmt.Errorf("xds: json.Unmarshal(%v) for field %q failed during bootstrap: %v", string(v), k, err)
}
configs := make(map[string]certprovider.StableConfig)
for instance, data := range providerInstances {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably minor detail.

Why does the instance need an "instance_name"? Would we have two instances with the same plugin_name, but different config? And since we always stop at the first valid config, what's the point?

This is similar to what we need for the balancing policy + config. We didn't make it a map[string]{policy+config}, but a []{policy+config}.

@easwars easwars merged commit 21f897e into grpc:master Sep 24, 2020
@easwars easwars deleted the security_bootstrap branch September 24, 2020 18:29
@easwars easwars changed the title xds: Add bootstrap support for certificate providers. certprovider-api: bootstrap support for certificate providers Mar 4, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants