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

Change how plugins work #133

Merged
merged 1 commit into from
Nov 9, 2017
Merged

Change how plugins work #133

merged 1 commit into from
Nov 9, 2017

Conversation

chuckha
Copy link
Contributor

@chuckha chuckha commented Nov 7, 2017

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

Fixes: #96

Signed-off-by: Chuck Ha chuck@heptio.com

@chuckha
Copy link
Contributor Author

chuckha commented Nov 7, 2017

201711071651_sonobuoy_d2e178db-0eeb-4c35-9001-f3d84be72fc2.tar.gz

Here is a sample run using this code.

Copy link
Contributor

@timothysc timothysc left a 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
Copy link
Contributor

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 {
Copy link
Contributor

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(
Copy link
Contributor

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.

if err != nil {
var b bytes.Buffer
p.Definition.Template.Execute(&b, p.DfnTemplateData)
var job v1.Pod
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as before.

cfg := &plugin.WorkerConfig{
ResultType: dfn.ResultType,
}
// TODO(cha): could just pass `masterAddress` directly into the NewPlugin functions.
Copy link
Contributor

Choose a reason for hiding this comment

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

?

if err != nil {
logrus.Warningf("Error unmarshalling bytes at %v: %v", fullPath, err)
continue
return pluginDfns, err
Copy link
Contributor

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?

Copy link
Contributor

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.

@@ -261,7 +290,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: status.podIP
image: gcr.io/heptio-images/sonobuoy:master
image: gcr.io/heptio-images/sonobuoy:latest
Copy link
Contributor

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")
Copy link
Contributor

Choose a reason for hiding this comment

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

Look into this one.

Copy link
Contributor Author

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.

@timothysc timothysc changed the title [WIP] Change how plugins work Change how plugins work Nov 9, 2017
Copy link
Contributor

@timothysc timothysc left a 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 <chuck@heptio.com>
@timothysc timothysc merged commit a0c3e42 into vmware-tanzu:master Nov 9, 2017
jhamilton1 pushed a commit to jhamilton1/sonobuoy that referenced this pull request Jun 27, 2018
Change how plugins work
Signed-off-by: Jesse Hamilton jesse.hamilton@heptio.com
jhamilton1 pushed a commit to jhamilton1/sonobuoy that referenced this pull request Jun 27, 2018
Change how plugins work
Signed-off-by: Jesse Hamilton jesse.hamilton@heptio.com

Signed-off-by: Jesse Hamilton jesse.hamilton@heptio.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants