-
Notifications
You must be signed in to change notification settings - Fork 1.2k
📖Adding ComponentConfig proposal #818
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
📖Adding ComponentConfig proposal #818
Conversation
/assign @vincepri |
774515d
to
f41fc62
Compare
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.
Small grammar edits + a question
f41fc62
to
041b120
Compare
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.
I really like that we standardizing on a controller configuration format thanks for putting this together, sorry the review took so long.
Can we make it easier to use a default component config by providing the struct/methods and unmarshaling?
1740c99
to
d74b31d
Compare
@stealthybox @shawn-hurley updated with new |
7aae5bd
to
33ccd9a
Compare
@stealthybox @shawn-hurley updated again to include the embeddable type of Thanks again for taking a look at this. |
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.
Just to make sure that I am following,
-
the first pass is to create the meta/config types and the default type and new
NewManager
method such that a user could use all the default stuff. -
A new design on how a user could extend the default stuff including adding scaffolding for that?
Correct and #2 will be another PR into Kubebuilder as I'd assume the scaffolding will live there. I'm holding off submitting that until we have this one ironed out. |
5655dcd
to
fce7c66
Compare
@mtaufen @lavalamp @shawn-hurley @stealthybox thanks for all the feedback, this has been updated with the most recent changes:
Appreciate the time reviewing this 😃 |
fce7c66
to
131a1cb
Compare
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.
Nice work.
131a1cb
to
ad5012f
Compare
ad5012f
to
d3884e6
Compare
@shawn-hurley @mtaufen @stealthybox @vincepri any more feedback, I'd love to start moving this forward and get a implementation in place. |
Forge ahead! :) Do take a spin through the Versioned Component Configuration Files doc (2018) while you're implementing and see how this compares (kubernetes-dev membership grants access). /lgtm |
|
||
#### Using Flags w/ ComponentConfig | ||
|
||
Since this design still requires setting up the initial `ComponentConfig` type and passing in a pointer to `ctrl.NewFromComponentConfig()` if you want to allow for the use of flags, your controller can use any of the different flagging interfaces. eg [`flag`](https://golang.org/pkg/flag/), [`pflag`](https://godoc.org/github.com/spf13/pflag), [`flagnum`](https://godoc.org/github.com/luci/luci-go/common/flag/flagenum) and set values on the `ComponentConfig` type prior to passing the pointer into the `ctrl.NewFromComponentConfig()`, example below. |
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.
Just FYI for backwards compatibility flags usually need to take precedence over config (unless you can force users to use exclusively flags or config).
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.
Good callout, since we're decoding in the same object that the flags could have already been set on there isn't a way I'm aware of to not override existing values while decoding. Have any suggestions?
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.
save off the flags and apply them after the decode? (merge the options structs together more or less)?
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.
Yea, that probably makes the most sense. I personally don't think this needs to be documented in the design doc, do you?
Feeling okay with the rest of this @shawn-hurley ?
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.
Instead of ctrl.NewFromComponentConfig()
that returns Manager
, would it be reasonable to have ctrl.NewOptionsFromComponentConfig()
that returns manager.Options
. And then let callers call manager.New()
themselves so that they have more flexibility in updating manager.Options
after it has been populated?
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.
Totally a possibility. I'd originally started with that path and ended up combining the funcs to make the new API quicker to implement.
@shawn-hurley @mtaufen @DirectXMan12 @stealthybox Do you have a preference? The options would be:
- Use a single function
ctrl.NewFromComponentConfig()
which takes theComponentConfig
type and returns actrl.Manager
.
or
- Separate the funcs and make it
ctrl.NewOptionsFromComponentConfig()
which returnsmanager.Options
that implementation wise would be passed intomanager.New()
.
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.
Another thought would be for the ComponentConfig-populating function to accept a pointer to a manager.Options
struct so that something like this would be possible:
func main() {
opts := manager.Options{}
_ = flag.StringVar(&opts.Namespace, "namespace", "", "Namespace to watch.")
ctrl.UpdateOptionsFromComponentConfig(&opts)
// Parse flags after populating from ComponentConfig so that flags
// take precedence
_ = flag.Parse()
_ = manager.New(ctrl.GetConfigOrDie(), opts)
}
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.
We'd need to pass similar params into each func, EG parsing out the ComponentConfig
type into the options we need to have the scheme
, config filename
, the component config type and the Options
struct.
func main() {
opts := manager.Options{}
_ = flag.StringVar(&opts.Namespace, "namespace", "", "Namespace to watch.")
_ = flag.StringVar(&filename, "config", "f", "ConmponentConfig type configuration.")
_ = ctrl.UpdateOptionsFromComponentConfig(scheme, filename, &componentconfig, &opts)
// Parse flags after populating from ComponentConfig so that flags
// take precedence
_ = flag.Parse()
_ = manager.New(ctrl.GetConfigOrDie(), opts)
}
I think both are fair flows and we could achieve the same goals with a composite function that returns the manager or returns the options.
Does anyone have strong opinions against this? @stealthybox @johnsonj @joelanford @djzager @shawn-hurley @mtaufen
Signed-off-by: Chris Hein <[email protected]>
d3884e6
to
23c65a4
Compare
/lgtm |
/approve If any other followups we can still discuss here, but let's get an implementation started and if more things come up we can discuss. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: christopherhein, shawn-hurley The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This is a proposal for how we can integrate
ComponentConfig
intocontroller-runtime
without breaking existing implementations and allows controller authors an easier way to configure their controllers.This was originally documented in #518
This uses the new design proposals from
designs/template.md
for a working example see christopherhein/github-controller#5Signed-off-by: Chris Hein [email protected]