diff --git a/cmd/sonobuoy/app/gen_plugin_def.go b/cmd/sonobuoy/app/gen_plugin_def.go index 1eb1d313b..717d3fa77 100644 --- a/cmd/sonobuoy/app/gen_plugin_def.go +++ b/cmd/sonobuoy/app/gen_plugin_def.go @@ -21,6 +21,7 @@ import ( "os" "github.com/heptio/sonobuoy/pkg/errlog" + "github.com/heptio/sonobuoy/pkg/plugin" "github.com/heptio/sonobuoy/pkg/plugin/manifest" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -32,7 +33,6 @@ import ( const ( defaultPluginName = "plugin" defaultPluginDriver = "Job" - defaultMountPath = "/tmp/results" defaultMountName = "results" defaultMountReadOnly = false ) @@ -107,7 +107,7 @@ func defaultManifest() manifest.Manifest { m.SonobuoyConfig.Driver = defaultPluginDriver m.Spec.VolumeMounts = []v1.VolumeMount{ v1.VolumeMount{ - MountPath: defaultMountPath, + MountPath: plugin.ResultsDir, Name: defaultMountName, ReadOnly: defaultMountReadOnly, }, diff --git a/pkg/client/gen.go b/pkg/client/gen.go index 5eb9e4d1a..8e3e4e01c 100644 --- a/pkg/client/gen.go +++ b/pkg/client/gen.go @@ -37,9 +37,8 @@ import ( ) const ( - e2ePluginName = "e2e" - systemdLogsName = "systemd-logs" - pluginResultsDir = "/tmp/results" + e2ePluginName = "e2e" + systemdLogsName = "systemd-logs" ) // templateValues are used for direct template substitution for manifest generation. @@ -257,7 +256,7 @@ func systemdLogsManifest(cfg *GenConfig) *manifest.Manifest { ImagePullPolicy: corev1.PullPolicy(cfg.ImagePullPolicy), Env: []corev1.EnvVar{ {Name: "CHROOT_DIR", Value: "/node"}, - {Name: "RESULTS_DIR", Value: pluginResultsDir}, + {Name: "RESULTS_DIR", Value: plugin.ResultsDir}, {Name: "NODE_NAME", ValueFrom: &corev1.EnvVarSource{ FieldRef: &corev1.ObjectFieldSelector{FieldPath: "spec.nodeName"}, @@ -271,7 +270,7 @@ func systemdLogsManifest(cfg *GenConfig) *manifest.Manifest { { ReadOnly: false, Name: "results", - MountPath: pluginResultsDir, + MountPath: plugin.ResultsDir, }, { ReadOnly: false, Name: "root", @@ -306,7 +305,7 @@ func e2eManifest(cfg *GenConfig) *manifest.Manifest { { ReadOnly: false, Name: "results", - MountPath: pluginResultsDir, + MountPath: plugin.ResultsDir, }, }, }, diff --git a/pkg/plugin/constants.go b/pkg/plugin/constants.go index 7d547eadf..7aa7526f3 100644 --- a/pkg/plugin/constants.go +++ b/pkg/plugin/constants.go @@ -19,4 +19,7 @@ package plugin const ( // GracefulShutdownPeriod is how long plugins have to cleanly finish before they are terminated. GracefulShutdownPeriod = 60 + + // ResultsDir is the diectory where results will be available in Sonobuoy plugin containers. + ResultsDir = "/tmp/results" ) diff --git a/pkg/plugin/driver/base.go b/pkg/plugin/driver/base.go index 50bedf5ff..e8019c3ec 100644 --- a/pkg/plugin/driver/base.go +++ b/pkg/plugin/driver/base.go @@ -23,16 +23,13 @@ import ( "encoding/pem" "fmt" + "github.com/heptio/sonobuoy/pkg/plugin" "github.com/heptio/sonobuoy/pkg/plugin/manifest" "github.com/pkg/errors" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -const ( - resultsDir = "/tmp/results" -) - // Base is the struct that stores state for plugin drivers and contains helper methods. type Base struct { Definition manifest.Manifest @@ -155,7 +152,7 @@ func (b *Base) workerEnvironment(hostname string, cert *tls.Certificate) []v1.En }, { Name: "RESULTS_DIR", - Value: resultsDir, + Value: plugin.ResultsDir, }, { Name: "RESULT_TYPE", @@ -208,7 +205,7 @@ func (b *Base) CreateWorkerContainerDefintion(hostname string, cert *tls.Certifi { Name: "results", ReadOnly: false, - MountPath: resultsDir, + MountPath: plugin.ResultsDir, }, }, } diff --git a/pkg/plugin/driver/daemonset/daemonset_test.go b/pkg/plugin/driver/daemonset/daemonset_test.go index 162b4c2ae..58ca52918 100644 --- a/pkg/plugin/driver/daemonset/daemonset_test.go +++ b/pkg/plugin/driver/daemonset/daemonset_test.go @@ -141,7 +141,7 @@ func TestCreateDaemonSetDefintion(t *testing.T) { } if len(daemonSet.Spec.Template.Spec.Volumes) != 4 { - t.Errorf("Expected 2 volumes defined, got %d", len(daemonSet.Spec.Template.Spec.Volumes)) + t.Errorf("Expected 4 volumes defined, got %d", len(daemonSet.Spec.Template.Spec.Volumes)) } pullSecrets := daemonSet.Spec.Template.Spec.ImagePullSecrets diff --git a/pkg/worker/config.go b/pkg/worker/config.go index 28b9bf0a9..e241ad376 100644 --- a/pkg/worker/config.go +++ b/pkg/worker/config.go @@ -25,7 +25,7 @@ import ( ) func setConfigDefaults(ac *plugin.WorkerConfig) { - ac.ResultsDir = "/tmp/results" + ac.ResultsDir = plugin.ResultsDir } // LoadConfig loads the configuration for the sonobuoy worker from environment