-
Notifications
You must be signed in to change notification settings - Fork 345
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
Change how plugins work #133
Conversation
201711071651_sonobuoy_d2e178db-0eeb-4c35-9001-f3d84be72fc2.tar.gz Here is a sample run using this code. |
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.
So the path of .tmpl -> quickstart.yaml generation is still fuzzy to me.
if err != nil { | ||
var b bytes.Buffer | ||
p.Definition.Template.Execute(&b, p.DfnTemplateData) | ||
var daemonSet v1beta1ext.DaemonSet |
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.
Please group the var declarations for consistency.
I really wish the type could be inferred and plugins be more
return errors.Wrapf(err, "could not create ConfigMap for daemonset plugin %v", p.GetName()) | ||
} | ||
if _, err = kubeclient.ExtensionsV1beta1().DaemonSets(p.Namespace).Create(daemonSet); err != nil { | ||
if _, err := kubeclient.ExtensionsV1beta1().DaemonSets(p.DfnTemplateData.Namespace).Create(&daemonSet); err != nil { |
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.
Add a // TODO to switch to .Apps in once extensions has been deprecated, or we will need to explicitly wrap.
|
||
// Delete the ConfigMap created by this plugin | ||
err = kubeclient.CoreV1().ConfigMaps(p.Namespace).DeleteCollection( | ||
err := kubeclient.ExtensionsV1beta1().DaemonSets(p.DfnTemplateData.Namespace).DeleteCollection( |
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.
so the if err != nil handling here is inconsistent. Let follow the boy-scout model and make the campground a bit cleaner then when we arrived.
pkg/plugin/driver/job/job.go
Outdated
if err != nil { | ||
var b bytes.Buffer | ||
p.Definition.Template.Execute(&b, p.DfnTemplateData) | ||
var job v1.Pod |
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.
same comment as before.
pkg/plugin/loader/loader.go
Outdated
cfg := &plugin.WorkerConfig{ | ||
ResultType: dfn.ResultType, | ||
} | ||
// TODO(cha): could just pass `masterAddress` directly into the NewPlugin functions. |
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.
?
pkg/plugin/loader/loader.go
Outdated
if err != nil { | ||
logrus.Warningf("Error unmarshalling bytes at %v: %v", fullPath, err) | ||
continue | ||
return pluginDfns, err |
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.
why not return nil,err on failure here?
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 realize it's nil, but it's less explicit when reading.
examples/quickstart.yaml
Outdated
@@ -261,7 +290,7 @@ spec: | |||
valueFrom: | |||
fieldRef: | |||
fieldPath: status.podIP | |||
image: gcr.io/heptio-images/sonobuoy:master | |||
image: gcr.io/heptio-images/sonobuoy:latest |
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.
should be master
@@ -47,6 +47,7 @@ func LoadConfig() (*plugin.WorkerConfig, error) { | |||
viper.BindEnv("masterurl", "MASTER_URL") | |||
viper.BindEnv("nodename", "NODE_NAME") | |||
viper.BindEnv("resultsdir", "RESULTS_DIR") | |||
viper.BindEnv("resulttype", "RESULT_TYPE") |
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.
Look into this one.
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 do need this. I am providing these values to the worker via Env Vars in the plugin template. This allows me to bypass the ConfigMap entirely.
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 - thx @chuckha !
Instead of creating our own schema for a plugin we will use annotations to get metadata to sonobuoy instead. We can then define full kubernetes resources as plugins. The resources we define are templates. The idea is to eventually move these templates over to ksonnet and have a nice ksonnet library for the shared pieces between plugins. Remaining work: * Whatever configuration can be passed into the template should be allowed to be passed into the template (`RESULTS_DIR`). * Add a test or two to the plugin.Interface implementations Signed-off-by: Chuck Ha <[email protected]>
Change how plugins work Signed-off-by: Jesse Hamilton [email protected]
Change how plugins work Signed-off-by: Jesse Hamilton [email protected] Signed-off-by: Jesse Hamilton [email protected]
Instead of creating our own schema for a plugin we will use annotations
to get metadata to sonobuoy instead. We can then define full kubernetes
resources as plugins.
The resources we define are templates. The idea is to eventually move
these templates over to ksonnet and have a nice ksonnet library for the
shared pieces between plugins.
Remaining work:
should be allowed to be passed into the template (
RESULTS_DIR
).Fixes: #96
Signed-off-by: Chuck Ha [email protected]