Skip to content

Commit

Permalink
Remove plugin.ResultType due to confusion/lack of need (#857)
Browse files Browse the repository at this point in the history
There was redundancy between three different fields of the plugin:
name, resultType, and resultFormat. The first two existed prior
to the third and were the same in almost every case, leading
to confusion about why there were two different values at all.

The problem with this is that the aggregator server would be primarily
concerned with resultType and use it through its code when referring
to plugins. As a result, the plugin name, despite having the more
intuitive title, was actually almost never used.

This all led to a few confusing situations:
 - If a plugin name != resultType it was unclear on which query/screen
they would see which value
 - Uniqueness was only enforced on resultType and not plugin name, leading
to the confusing requirement that they provide a name but not using it often
and it not being required to be unique
 - The plugin name/type were almost always 100% the same even though their
names don't imply that, whereas plugin type/format were never meant to be
related despite sounding like similar ideas.

By removing the plugin result type (and relying on plugin name for the
unique identifier) we are left with two fields (name and format) which
seem much more clear and unique.

Internally, the aggregator server still uses the "ResultType" naming
convention in its own types since those types did not have the 'Name'
field to conflict with. In addition, that is not really a user facing
field whereas plugin definitions (where type/name both exist) are.

Fixes #830

Signed-off-by: John Schnake <[email protected]>
  • Loading branch information
johnSchnake authored Aug 30, 2019
1 parent 2d47854 commit 3b14025
Show file tree
Hide file tree
Showing 34 changed files with 27 additions and 88 deletions.
5 changes: 1 addition & 4 deletions cmd/sonobuoy/app/gen_plugin_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func defaultManifest() manifest.Manifest {
m.Spec.Name = defaultPluginName
m.SonobuoyConfig.Driver = defaultPluginDriver
m.Spec.VolumeMounts = []v1.VolumeMount{
v1.VolumeMount{
{
MountPath: plugin.ResultsDir,
Name: defaultMountName,
ReadOnly: defaultMountReadOnly,
Expand All @@ -142,9 +142,6 @@ func genPluginDefWrapper(cfg *GenPluginDefConfig) func(cmd *cobra.Command, args
// genPluginDef returns the YAML for the plugin which Sonobuoy would expect as
// a configMap in order to run/gen a typical run.
func genPluginDef(cfg *GenPluginDefConfig) ([]byte, error) {
// Result type just duplicates the name in most cases.
cfg.def.SonobuoyConfig.ResultType = cfg.def.SonobuoyConfig.PluginName

// Copy the validated value to the actual field.
cfg.def.SonobuoyConfig.Driver = cfg.driver.String()

Expand Down
1 change: 0 additions & 1 deletion cmd/sonobuoy/app/testdata/pluginDef-container.golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
sonobuoy-config:
driver: ""
plugin-name: ""
result-type: ""
spec:
command:
- /bin/sh
Expand Down
1 change: 0 additions & 1 deletion cmd/sonobuoy/app/testdata/pluginDef-default-podspec.golden
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ podSpec:
sonobuoy-config:
driver: ""
plugin-name: "n"
result-type: "n"
spec:
name: ""
resources: {}
1 change: 0 additions & 1 deletion cmd/sonobuoy/app/testdata/pluginDef-env.golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
sonobuoy-config:
driver: ""
plugin-name: ""
result-type: ""
spec:
env:
- name: FOO
Expand Down
1 change: 0 additions & 1 deletion cmd/sonobuoy/app/testdata/pluginDef-quotes.golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
sonobuoy-config:
driver: ""
plugin-name: "n"
result-type: "n"
spec:
command:
- /bin/sh
Expand Down
1 change: 0 additions & 1 deletion cmd/sonobuoy/app/testdata/pluginDef-sonoconfig.golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
sonobuoy-config:
driver: Job
plugin-name: "n"
result-type: "n"
spec:
name: ""
resources: {}
2 changes: 0 additions & 2 deletions pkg/client/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ func systemdLogsManifest(cfg *GenConfig) *manifest.Manifest {
SonobuoyConfig: manifest.SonobuoyConfig{
PluginName: "systemd-logs",
Driver: "DaemonSet",
ResultType: "systemd-logs",
ResultFormat: "raw",
},
Spec: manifest.Container{
Expand Down Expand Up @@ -293,7 +292,6 @@ func e2eManifest(cfg *GenConfig) *manifest.Manifest {
SonobuoyConfig: manifest.SonobuoyConfig{
PluginName: "e2e",
Driver: "Job",
ResultType: "e2e",
ResultFormat: "junit",
},
Spec: manifest.Container{
Expand Down
6 changes: 3 additions & 3 deletions pkg/client/results/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ func MustGetReader(path string, t *testing.T) *results.Reader {
}

var versions = []*version{
&version{0, 8},
&version{0, 9},
&version{0, 10},
{0, 8},
{0, 9},
{0, 10},
}

func TestServerGroup(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/client/testdata/default-plugins-via-nil-selection.golden
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ data:
driver: Job
plugin-name: e2e
result-format: junit
result-type: e2e
spec:
command:
- /run_e2e.sh
Expand All @@ -49,7 +48,6 @@ data:
driver: DaemonSet
plugin-name: systemd-logs
result-format: raw
result-type: systemd-logs
spec:
command:
- /bin/sh
Expand Down
2 changes: 0 additions & 2 deletions pkg/client/testdata/default-pod-spec.golden
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ data:
driver: Job
plugin-name: e2e
result-format: junit
result-type: e2e
spec:
command:
- /run_e2e.sh
Expand Down Expand Up @@ -72,7 +71,6 @@ data:
driver: DaemonSet
plugin-name: systemd-logs
result-format: raw
result-type: systemd-logs
spec:
command:
- /bin/sh
Expand Down
2 changes: 0 additions & 2 deletions pkg/client/testdata/default.golden
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ data:
driver: Job
plugin-name: e2e
result-format: junit
result-type: e2e
spec:
command:
- /run_e2e.sh
Expand All @@ -49,7 +48,6 @@ data:
driver: DaemonSet
plugin-name: systemd-logs
result-format: raw
result-type: systemd-logs
spec:
command:
- /bin/sh
Expand Down
1 change: 0 additions & 1 deletion pkg/client/testdata/e2e-default.golden
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ data:
driver: Job
plugin-name: e2e
result-format: junit
result-type: e2e
spec:
command:
- /run_e2e.sh
Expand Down
1 change: 0 additions & 1 deletion pkg/client/testdata/envoverrides.golden
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ data:
driver: Job
plugin-name: e2e
result-format: junit
result-type: e2e
spec:
command:
- /run_e2e.sh
Expand Down
1 change: 0 additions & 1 deletion pkg/client/testdata/imagePullSecrets.golden
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ data:
driver: Job
plugin-name: e2e
result-format: junit
result-type: e2e
spec:
command:
- /run_e2e.sh
Expand Down
2 changes: 0 additions & 2 deletions pkg/client/testdata/manual-custom-plugin-plus-e2e.golden
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ data:
driver: Job
plugin-name: e2e
result-format: junit
result-type: e2e
spec:
command:
- /run_e2e.sh
Expand All @@ -48,7 +47,6 @@ data:
sonobuoy-config:
driver: ""
plugin-name: foo
result-type: ""
spec:
name: ""
resources: {}
Expand Down
2 changes: 0 additions & 2 deletions pkg/client/testdata/manual-custom-plugin-plus-systemd.golden
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ data:
sonobuoy-config:
driver: ""
plugin-name: foo
result-type: ""
spec:
name: ""
resources: {}
Expand All @@ -39,7 +38,6 @@ data:
driver: DaemonSet
plugin-name: systemd-logs
result-format: raw
result-type: systemd-logs
spec:
command:
- /bin/sh
Expand Down
1 change: 0 additions & 1 deletion pkg/client/testdata/manual-custom-plugin.golden
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ data:
sonobuoy-config:
driver: ""
plugin-name: foo
result-type: ""
spec:
name: ""
resources: {}
Expand Down
1 change: 0 additions & 1 deletion pkg/client/testdata/manual-e2e.golden
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ data:
driver: Job
plugin-name: e2e
result-format: junit
result-type: e2e
spec:
command:
- /run_e2e.sh
Expand Down
2 changes: 0 additions & 2 deletions pkg/client/testdata/plugins-and-pluginSelection.golden
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ data:
sonobuoy-config:
driver: ""
plugin-name: a
result-type: ""
spec:
name: ""
resources: {}
plugin-1.yaml: |
sonobuoy-config:
driver: ""
plugin-name: b
result-type: ""
spec:
name: ""
resources: {}
Expand Down
1 change: 0 additions & 1 deletion pkg/client/testdata/ssh.golden
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ data:
driver: Job
plugin-name: e2e
result-format: junit
result-type: e2e
spec:
command:
- /run_e2e.sh
Expand Down
1 change: 0 additions & 1 deletion pkg/client/testdata/systemd-logs-default.golden
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ data:
driver: DaemonSet
plugin-name: systemd-logs
result-format: raw
result-type: systemd-logs
spec:
command:
- /bin/sh
Expand Down
1 change: 0 additions & 1 deletion pkg/client/testdata/use-existing-pod-spec.golden
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ data:
sonobuoy-config:
driver: ""
plugin-name: a
result-type: ""
spec:
name: ""
resources: {}
Expand Down
2 changes: 1 addition & 1 deletion pkg/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func Run(restConf *rest.Config, cfg *config.Config) (errCount int) {
// Update the plugin status with this post-processed information.
statusInfo := map[string]int{}
statusCounts(&item, statusInfo)
updatePluginStatus(kubeClient, cfg.Namespace, p.GetResultType(), item.Status, statusInfo)
updatePluginStatus(kubeClient, cfg.Namespace, p.GetName(), item.Status, statusInfo)
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/plugin/aggregation/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func (a *Aggregator) RunAndMonitorPlugin(ctx context.Context, p plugin.Interface
if err := p.Run(client, address, cert, aggregatorPod); err != nil {
err := errors.Wrapf(err, "error running plugin %v", p.GetName())
logrus.Error(err)
monitorCh <- utils.MakeErrorResult(p.GetResultType(), map[string]interface{}{"error": err.Error()}, "")
monitorCh <- utils.MakeErrorResult(p.GetName(), map[string]interface{}{"error": err.Error()}, "")
}

go p.Monitor(pCtx, client, nodes, monitorCh)
Expand Down Expand Up @@ -252,7 +252,7 @@ func (a *Aggregator) pluginHasResults(p plugin.Interface) bool {
a.resultsMutex.Lock()
defer a.resultsMutex.Unlock()

targetType := p.GetResultType()
targetType := p.GetName()
for expResultID, expResult := range a.ExpectedResults {
if expResult.ResultType != targetType {
continue
Expand Down
5 changes: 0 additions & 5 deletions pkg/plugin/aggregation/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func TestRunAndMonitorPlugin(t *testing.T) {
Definition: manifest.Manifest{
SonobuoyConfig: manifest.SonobuoyConfig{
PluginName: "myPlugin",
ResultType: "myPlugin",
},
},
Namespace: "testNS",
Expand Down Expand Up @@ -227,10 +226,6 @@ func (cp *MockCleanupPlugin) FillTemplate(_ string, _ *tls.Certificate) ([]byte,
return []byte{}, nil
}

func (cp *MockCleanupPlugin) GetResultType() string {
return "result-type"
}

func (cp *MockCleanupPlugin) GetName() string {
return "mock-cleanup-plugin"
}
Expand Down
7 changes: 1 addition & 6 deletions pkg/plugin/driver/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ func (b *Base) GetSecretName() string {
return fmt.Sprintf("sonobuoy-plugin-%s-%s", b.GetName(), b.GetSessionID())
}

// GetResultType returns the ResultType for this plugin (to adhere to plugin.Interface).
func (b *Base) GetResultType() string {
return b.Definition.SonobuoyConfig.ResultType
}

// GetDriver returns the Driver for this plugin.
func (b *Base) GetDriver() string {
return b.Definition.SonobuoyConfig.Driver
Expand Down Expand Up @@ -162,7 +157,7 @@ func (b *Base) workerEnvironment(hostname string, cert *tls.Certificate) []v1.En
},
{
Name: "RESULT_TYPE",
Value: b.GetResultType(),
Value: b.GetName(),
},
{
Name: "MASTER_URL",
Expand Down
3 changes: 1 addition & 2 deletions pkg/plugin/driver/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ func TestCreateWorkerContainerDefinition(t *testing.T) {
Definition: manifest.Manifest{
SonobuoyConfig: manifest.SonobuoyConfig{
PluginName: "test-plugin",
ResultType: "test-plugin",
},
},
SonobuoyImage: "sonobuoy:v1",
Expand Down Expand Up @@ -170,7 +169,7 @@ func TestCreateWorkerContainerDefinition(t *testing.T) {
},
{
Name: "RESULT_TYPE",
Value: b.GetResultType(),
Value: b.GetName(),
},
{
Name: "MASTER_URL",
Expand Down
11 changes: 5 additions & 6 deletions pkg/plugin/driver/daemonset/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (p *Plugin) ExpectedResults(nodes []v1.Node) []plugin.ExpectedResult {
for _, node := range nodes {
ret = append(ret, plugin.ExpectedResult{
NodeName: node.Name,
ResultType: p.GetResultType(),
ResultType: p.GetName(),
})
}

Expand All @@ -88,9 +88,8 @@ func getAggregatorAddress(hostname string) string {
func (p *Plugin) createDaemonSetDefinition(hostname string, cert *tls.Certificate, ownerPod *v1.Pod) appsv1.DaemonSet {
ds := appsv1.DaemonSet{}
annotations := map[string]string{
"sonobuoy-driver": p.GetDriver(),
"sonobuoy-plugin": p.GetName(),
"sonobuoy-result-type": p.GetResultType(),
"sonobuoy-driver": p.GetDriver(),
"sonobuoy-plugin": p.GetName(),
}
for k, v := range p.CustomAnnotations {
annotations[k] = v
Expand Down Expand Up @@ -291,7 +290,7 @@ func (p *Plugin) monitorOnce(kubeclient kubernetes.Interface, availableNodes []v
if isFailing, reason := utils.IsPodFailing(&pod); isFailing {
podsReported[nodeName] = true

retErrs = append(retErrs, utils.MakeErrorResult(p.GetResultType(), map[string]interface{}{
retErrs = append(retErrs, utils.MakeErrorResult(p.GetName(), map[string]interface{}{
"error": reason,
"pod": pod,
}, nodeName))
Expand All @@ -306,7 +305,7 @@ func (p *Plugin) monitorOnce(kubeclient kubernetes.Interface, availableNodes []v
for _, node := range availableNodes {
if !podsFound[node.Name] && !podsReported[node.Name] {
podsReported[node.Name] = true
retErrs = append(retErrs, utils.MakeErrorResult(p.GetResultType(), map[string]interface{}{
retErrs = append(retErrs, utils.MakeErrorResult(p.GetName(), map[string]interface{}{
"error": fmt.Sprintf(
"No pod was scheduled on node %v within %v. Check tolerations for plugin %v",
node.Name,
Expand Down
Loading

0 comments on commit 3b14025

Please sign in to comment.