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
Add features package #1849
Add features package #1849
Conversation
Looking at how this is currently written, how one might consume it, and based on the design proposal, I think it might make more sense to do an API like this within the var flags sets.String
func Enabled(name string) bool {
flags.Has(name)
}
func Enable(names ...string) {
flags.Insert(names....)
}
func All() []string {
return flags.List()
} This then skips requiring initializing our own flag set struct, and callers can simply use I can simplify the enabling code by just doing What do others think of that? |
I'm asking about this slightly different design because passing around a flag set on the client's factory seems a bit unwieldy for something that should be accessible ~anywhere in the code base easily. I guess the last question I would have is if we're terribly concerned with concurrent access to the flag list, but I'm assuming that is something we don't have to address until later. |
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
f04a276
to
2d65c2b
Compare
Feature flags must be consumed as the `--features` command line argument. There is currently no plugin API change in order to minimize changes. Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
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.
One minor comment for now.
@@ -76,6 +81,24 @@ func SaveConfig(config map[string]string) error { | |||
return json.NewEncoder(configFile).Encode(&config) | |||
} | |||
|
|||
func (c VeleroConfig) Namespace() string { | |||
ns, ok := c[ConfigKeyNamespace] | |||
if !ok { |
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.
Very subjective, but I think this and the next function would read better if the check on the map key was all inlined.
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 think we can't do this here since val
is used outside the if...
block?
@skriss @prydonius Curious about your thoughts on this approach before I proceed further. |
I would agree, seems like a global here would be a lot easier. As far as concurrent access, seems like we'll only need to set the flags once at the start of the server, so not sure that we really need the mutexes? |
True - part of my concern there came when I realized this might be used by plugins. If we think it's overkill I can definitely remove. |
Ah okay, do we expect plugins to enable/disable features? |
I'm thinking they'll have to inside their process. As an example, this code passes the As a concrete example of passing to plugins, I would think any CSI plugin would check for the relevant feature before doing any work, and exit as a no-op if it's not enabled. |
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.
Approach WFM, added some comments.
The client factory isn't where the features flags should get initialized, as it's not guaranteed to be around. Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
Users shouldn't have to call NewFeatureFlagSet, so Enable will call it for them if necessary. Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
I believe I've addressed all the feedback now. Mutexes were removed since I don't think they provided much value. I'm thinking it may be useful to add feature information to the |
It does seem useful though the only CLI command that exposes the |
The |
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.
Mostly LGTM, just one style nit.
Have you been able to manually verify the flag-parsing for both server and CLI commands?
Yep - makes sense to me. |
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
Yeah, I've tested this with There's one thing that may be an issue - now that we have the root It could also be a local development convenience, so I'm unsure if I want to add any sort of conditional loading logic. |
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
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.
lgtm - one small formatting issue!
I'm not too worried about this atm, guessing it'll be pretty obvious if that's happening. Ready to merge once adnan's comment is addressed! |
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
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.
LGTM
* upstream/master: (38 commits) sync controller: replace revision file with full diff each interval (vmware-tanzu#1892) Increment logging for item backupper (vmware-tanzu#1904) Add LD_LIBRARY_PATH as an env varible for the use of vsphere plugin (vmware-tanzu#1893) Remove unused flag (vmware-tanzu#1913) Use layers in the builder Dockerfile (vmware-tanzu#1907) Fix for vmware-tanzu#1888: check item's original namespace, not remapped one, for inclusion/exclusion (vmware-tanzu#1909) fail on make verify if generated CRDs differ (vmware-tanzu#1906) velero API type changes for structural schema CRDs (vmware-tanzu#1898) Generate CRDs with structural schema (vmware-tanzu#1885) Plan for moving plugin repos (vmware-tanzu#1870) move plugin proto updating into make update (vmware-tanzu#1887) Add features package (vmware-tanzu#1849) GCP: support specifying Cloud KMS key name for backup storage locations (vmware-tanzu#1879) Adds to website (vmware-tanzu#1882) proposal for generating Velero CRDs with structural schema (vmware-tanzu#1875) Improve contributing docs (vmware-tanzu#1852) [doc] Diagram (image) now mentions velero (vmware-tanzu#1877) AWS: add support for arbitrary SSE algorithms, e.g. AES256 (vmware-tanzu#1869) update restic docs for PR vmware-tanzu#1807 (vmware-tanzu#1867) changelog for PR vmware-tanzu#1864 ...
This PR creates the
features
package and the necessary plumbing for flags to be enabled at the command line and in the configuration file.Closes #1798