From 6548a27ce39e0ae5dd864fe90999fe2bbb20c5af Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Thu, 29 Nov 2018 17:16:03 +0100 Subject: [PATCH 1/9] Add spark job Signed-off-by: Pavol Loffay --- deploy/role.yaml | 1 + pkg/apis/io/v1alpha1/jaeger_types.go | 31 +++-- pkg/apis/io/v1alpha1/zz_generated.deepcopy.go | 17 +++ pkg/cmd/start/main.go | 3 + pkg/cronjob/spark_dependencies.go | 125 ++++++++++++++++++ pkg/cronjob/spark_dependencies_test.go | 81 ++++++++++++ pkg/strategy/all-in-one.go | 5 + pkg/strategy/production.go | 6 +- test/e2e/jaeger_test.go | 2 + test/e2e/spark_dependencies_test.go | 86 ++++++++++++ test/e2e/wait_util.go | 54 ++++++++ 11 files changed, 402 insertions(+), 9 deletions(-) create mode 100644 pkg/cronjob/spark_dependencies.go create mode 100644 pkg/cronjob/spark_dependencies_test.go create mode 100644 test/e2e/spark_dependencies_test.go diff --git a/deploy/role.yaml b/deploy/role.yaml index b3f9211dd..8f13f135d 100644 --- a/deploy/role.yaml +++ b/deploy/role.yaml @@ -48,5 +48,6 @@ rules: - batch resources: - jobs + - cronjobs verbs: - "*" diff --git a/pkg/apis/io/v1alpha1/jaeger_types.go b/pkg/apis/io/v1alpha1/jaeger_types.go index b45dea788..ed67cad56 100644 --- a/pkg/apis/io/v1alpha1/jaeger_types.go +++ b/pkg/apis/io/v1alpha1/jaeger_types.go @@ -46,15 +46,16 @@ type Jaeger struct { // JaegerSpec defines the structure of the Jaeger JSON object from the CR type JaegerSpec struct { - Strategy string `json:"strategy"` - AllInOne JaegerAllInOneSpec `json:"allInOne"` - Query JaegerQuerySpec `json:"query"` - Collector JaegerCollectorSpec `json:"collector"` - Agent JaegerAgentSpec `json:"agent"` - UI JaegerUISpec `json:"ui"` + Strategy string `json:"strategy"` + AllInOne JaegerAllInOneSpec `json:"allInOne"` + Query JaegerQuerySpec `json:"query"` + Collector JaegerCollectorSpec `json:"collector"` + Agent JaegerAgentSpec `json:"agent"` + UI JaegerUISpec `json:"ui"` Sampling JaegerSamplingSpec `json:"sampling"` - Storage JaegerStorageSpec `json:"storage"` - Ingress JaegerIngressSpec `json:"ingress"` + Storage JaegerStorageSpec `json:"storage"` + Ingress JaegerIngressSpec `json:"ingress"` + SparkDependencies JaegerSparkDependenciesSpec `json:"sparkDependencies"` JaegerCommonSpec } @@ -135,6 +136,20 @@ type JaegerCassandraCreateSchemaSpec struct { Mode string `json:"mode"` } +// JaegerSparkDependenciesSpec defined options for running spark-dependencies. +type JaegerSparkDependenciesSpec struct { + Enabled bool `json:"enabled"` + SparkMaster string `json:"sparkMaster"` + Schedule string `json:"schedule"` + Image string `json:"image"` + JavaOpts string `json:"javaOpts"` + CassandraUseSsl bool `json:"cassandraUseSsl"` + CassandraLocalDc string `json:"cassandraLocalDc"` + CassandraClientAuthEnabled bool `json:"cassandraClientAuthEnabled"` + ElasticsearchClientNodeOnly bool `json:"elasticsearchClientNodeOnly"` + ElasticsearchNodesWanOnly bool `json:"elasticsearchNodesWanOnly"` +} + func init() { SchemeBuilder.Register(&Jaeger{}, &JaegerList{}) } diff --git a/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go index b45b9bbb6..769873537 100644 --- a/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go @@ -277,6 +277,22 @@ func (in *JaegerSamplingSpec) DeepCopy() *JaegerSamplingSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *JaegerSparkDependenciesSpec) DeepCopyInto(out *JaegerSparkDependenciesSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JaegerSparkDependenciesSpec. +func (in *JaegerSparkDependenciesSpec) DeepCopy() *JaegerSparkDependenciesSpec { + if in == nil { + return nil + } + out := new(JaegerSparkDependenciesSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *JaegerSpec) DeepCopyInto(out *JaegerSpec) { *out = *in @@ -288,6 +304,7 @@ func (in *JaegerSpec) DeepCopyInto(out *JaegerSpec) { in.Sampling.DeepCopyInto(&out.Sampling) in.Storage.DeepCopyInto(&out.Storage) in.Ingress.DeepCopyInto(&out.Ingress) + out.SparkDependencies = in.SparkDependencies in.JaegerCommonSpec.DeepCopyInto(&out.JaegerCommonSpec) return } diff --git a/pkg/cmd/start/main.go b/pkg/cmd/start/main.go index 258c5b499..ad60ab3a5 100644 --- a/pkg/cmd/start/main.go +++ b/pkg/cmd/start/main.go @@ -45,6 +45,9 @@ func NewStartCommand() *cobra.Command { cmd.Flags().String("jaeger-cassandra-schema-image", "jaegertracing/jaeger-cassandra-schema", "The Docker image for the Jaeger Cassandra Schema") viper.BindPFlag("jaeger-cassandra-schema-image", cmd.Flags().Lookup("jaeger-cassandra-schema-image")) + cmd.Flags().String("jaeger-spark-dependencies-image", "jaegertracing/spark-dependencies", "The Docker image for the Spark Dependencies Job") + viper.BindPFlag("jaeger-spark-dependencies-image", cmd.Flags().Lookup("jaeger-spark-dependencies-image")) + cmd.Flags().String("openshift-oauth-proxy-image", "openshift/oauth-proxy:latest", "The Docker image location definition for the OpenShift OAuth Proxy") viper.BindPFlag("openshift-oauth-proxy-image", cmd.Flags().Lookup("openshift-oauth-proxy-image")) diff --git a/pkg/cronjob/spark_dependencies.go b/pkg/cronjob/spark_dependencies.go new file mode 100644 index 000000000..122ad0f1b --- /dev/null +++ b/pkg/cronjob/spark_dependencies.go @@ -0,0 +1,125 @@ +package cronjob + +import ( + "fmt" + "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" + "github.com/jaegertracing/jaeger-operator/pkg/storage" + "github.com/spf13/viper" + batchv1 "k8s.io/api/batch/v1" + batchv1beta1 "k8s.io/api/batch/v1beta1" + "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "strconv" +) + +var supportedStorageTypes = map[string]bool{"elasticsearch": true, "cassandra": true} + +func Create(jaeger *v1alpha1.Jaeger) *batchv1beta1.CronJob { + if ok := supportedStorageTypes[jaeger.Spec.Storage.Type]; !ok { + return nil + } + + applyDefaults(jaeger) + trueVar := true + name := fmt.Sprintf("%s-spark-dependencies", jaeger.Name) + + envVars := []v1.EnvVar{ + {Name: "STORAGE", Value: jaeger.Spec.Storage.Type}, + {Name: "SPARK_MASTER", Value: jaeger.Spec.SparkDependencies.SparkMaster}, + {Name: "JAVA_OPTS", Value: jaeger.Spec.SparkDependencies.JavaOpts}, + } + envVars = append(envVars, getStorageEnvs(jaeger.Spec.Storage, jaeger.Spec.SparkDependencies)...) + + return &batchv1beta1.CronJob{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: jaeger.Namespace, + OwnerReferences: []metav1.OwnerReference{ + { + APIVersion: jaeger.APIVersion, + Kind: jaeger.Kind, + Name: jaeger.Name, + UID: jaeger.UID, + Controller: &trueVar, + }, + }, + }, + Spec: batchv1beta1.CronJobSpec{ + Schedule: jaeger.Spec.SparkDependencies.Schedule, + JobTemplate: batchv1beta1.JobTemplateSpec{ + Spec: batchv1.JobSpec{ + Template: v1.PodTemplateSpec{ + Spec: v1.PodSpec{ + Containers: []v1.Container{ + { + Image: jaeger.Spec.SparkDependencies.Image, + Name: name, + // let spark job use its default values + Env: removeEmptyVars(envVars), + }, + }, + RestartPolicy: v1.RestartPolicyNever, + }, + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{ + "prometheus.io/scrape": "false", + "sidecar.istio.io/inject": "false", + }, + }, + }, + }, + }, + }, + } +} + +func getStorageEnvs(s v1alpha1.JaegerStorageSpec, sj v1alpha1.JaegerSparkDependenciesSpec) []v1.EnvVar { + sFlags := s.Options.Filter(storage.OptionsPrefix(s.Type)) + sFlagsMap := sFlags.Map() + keyspace := sFlagsMap["cassandra.keyspace"] + if keyspace == "" { + keyspace = "jaeger_v1_test" + } + switch s.Type { + case "cassandra": + return []v1.EnvVar{ + {Name: "CASSANDRA_CONTACT_POINTS", Value: sFlagsMap["cassandra.servers"]}, + {Name: "CASSANDRA_KEYSPACE", Value: keyspace}, + {Name: "CASSANDRA_USERNAME", Value: sFlagsMap["cassandra.username"]}, + {Name: "CASSANDRA_PASSWORD", Value: sFlagsMap["cassandra.password"]}, + {Name: "CASSANDRA_USE_SSL", Value: strconv.FormatBool(sj.CassandraUseSsl)}, + {Name: "CASSANDRA_LOCAL_DC", Value: sj.CassandraLocalDc}, + {Name: "CASSANDRA_CLIENT_AUTH_ENABLED", Value: strconv.FormatBool(sj.CassandraClientAuthEnabled)}, + } + case "elasticsearch": + return []v1.EnvVar{ + {Name: "ES_NODES", Value: sFlagsMap["es.server-urls"]}, + {Name: "ES_INDEX_PREFIX", Value: sFlagsMap["es.index-prefix"]}, + {Name: "ES_USERNAME", Value: sFlagsMap["es.username"]}, + {Name: "ES_PASSWORD", Value: sFlagsMap["es.password"]}, + {Name: "ES_CLIENT_NODE_ONLY", Value: strconv.FormatBool(sj.ElasticsearchClientNodeOnly)}, + {Name: "ES_NODES_WAN_ONLY", Value: strconv.FormatBool(sj.ElasticsearchNodesWanOnly)}, + } + default: + return nil + } +} + +func applyDefaults(jaeger *v1alpha1.Jaeger) { + if jaeger.Spec.SparkDependencies.Image == "" { + jaeger.Spec.SparkDependencies.Image = fmt.Sprintf("%s", viper.GetString("jaeger-spark-dependencies-image")) + } + if jaeger.Spec.SparkDependencies.Schedule == "" { + jaeger.Spec.SparkDependencies.Schedule = "55 23 * * *" + } +} + +func removeEmptyVars(envVars []v1.EnvVar) []v1.EnvVar { + var notEmpty []v1.EnvVar + for _, v := range envVars { + if v.Value != "" || v.ValueFrom != nil { + notEmpty = append(notEmpty, v) + } + } + return notEmpty +} diff --git a/pkg/cronjob/spark_dependencies_test.go b/pkg/cronjob/spark_dependencies_test.go new file mode 100644 index 000000000..7f6329efe --- /dev/null +++ b/pkg/cronjob/spark_dependencies_test.go @@ -0,0 +1,81 @@ +package cronjob + +import ( + "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" + "github.com/stretchr/testify/assert" + "k8s.io/api/core/v1" + "testing" +) + +func TestApplyDefaults(t *testing.T) { + tests := []struct { + underTest *v1alpha1.Jaeger + expected *v1alpha1.Jaeger + }{ + {underTest: &v1alpha1.Jaeger{}, expected: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "55 23 * * *"}}}}, + {underTest: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "foo"}}}, expected: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "foo"}}}}, + } + for _, test := range tests { + applyDefaults(test.underTest) + assert.Equal(t, test.expected, test.underTest) + } +} + +func TestRemoveEmptyVars(t *testing.T) { + tests := []struct { + underTest []v1.EnvVar + expected []v1.EnvVar + }{ + {}, + {underTest: []v1.EnvVar{{Name: "foo", Value: "bar"}, {Name: "foo3"}, {Name: "foo2", ValueFrom: &v1.EnvVarSource{}}}, + expected: []v1.EnvVar{{Name: "foo", Value: "bar"}, {Name: "foo2", ValueFrom: &v1.EnvVarSource{}}}}, + {underTest: []v1.EnvVar{{Name: "foo"}}}, + } + for _, test := range tests { + exp := removeEmptyVars(test.underTest) + assert.Equal(t, test.expected, exp) + } +} + +func TestStorageEnvs(t *testing.T) { + tests := []struct { + storage v1alpha1.JaegerStorageSpec + deps v1alpha1.JaegerSparkDependenciesSpec + expected []v1.EnvVar + }{ + {storage: v1alpha1.JaegerStorageSpec{Type: "foo"}}, + {storage: v1alpha1.JaegerStorageSpec{Type: "cassandra", + Options: v1alpha1.NewOptions(map[string]interface{}{"cassandra.servers": "lol:hol", "cassandra.keyspace": "haha", + "cassandra.username": "jdoe", "cassandra.password": "none"})}, + expected: []v1.EnvVar{ + {Name: "CASSANDRA_CONTACT_POINTS", Value: "lol:hol"}, + {Name: "CASSANDRA_KEYSPACE", Value: "haha"}, + {Name: "CASSANDRA_USERNAME", Value: "jdoe"}, + {Name: "CASSANDRA_PASSWORD", Value: "none"}, + {Name: "CASSANDRA_USE_SSL", Value: "false"}, + {Name: "CASSANDRA_LOCAL_DC", Value: ""}, + {Name: "CASSANDRA_CLIENT_AUTH_ENABLED", Value: "false"}, + }}, + {storage: v1alpha1.JaegerStorageSpec{Type: "elasticsearch", + Options: v1alpha1.NewOptions(map[string]interface{}{"es.server-urls": "lol:hol", "es.index-prefix": "haha", + "es.username": "jdoe", "es.password": "none"})}, + expected: []v1.EnvVar{ + {Name: "ES_NODES", Value: "lol:hol"}, + {Name: "ES_INDEX_PREFIX", Value: "haha"}, + {Name: "ES_USERNAME", Value: "jdoe"}, + {Name: "ES_PASSWORD", Value: "none"}, + {Name: "ES_CLIENT_NODE_ONLY", Value: "false"}, + {Name: "ES_NODES_WAN_ONLY", Value: "false"}, + }}, + } + for _, test := range tests { + envVars := getStorageEnvs(test.storage, test.deps) + assert.Equal(t, test.expected, envVars) + } +} + +func TestCreate(t *testing.T) { + assert.Nil(t, Create(&v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{Storage: v1alpha1.JaegerStorageSpec{Type: "foo"}}})) + assert.NotNil(t, Create(&v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{Storage: v1alpha1.JaegerStorageSpec{Type: "elasticsearch"}}})) + assert.NotNil(t, Create(&v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{Storage: v1alpha1.JaegerStorageSpec{Type: "cassandra"}}})) +} diff --git a/pkg/strategy/all-in-one.go b/pkg/strategy/all-in-one.go index 9b2421f7e..ec4263466 100644 --- a/pkg/strategy/all-in-one.go +++ b/pkg/strategy/all-in-one.go @@ -2,6 +2,7 @@ package strategy import ( "context" + "github.com/jaegertracing/jaeger-operator/pkg/cronjob" "github.com/sirupsen/logrus" "github.com/spf13/viper" @@ -78,6 +79,10 @@ func (c *allInOneStrategy) Create() []runtime.Object { } } + if c.jaeger.Spec.SparkDependencies.Enabled { + os = append(os, cronjob.Create(c.jaeger)) + } + return os } diff --git a/pkg/strategy/production.go b/pkg/strategy/production.go index f7f876247..ec8d33493 100644 --- a/pkg/strategy/production.go +++ b/pkg/strategy/production.go @@ -2,7 +2,7 @@ package strategy import ( "context" - + "github.com/jaegertracing/jaeger-operator/pkg/cronjob" "github.com/sirupsen/logrus" "github.com/spf13/viper" batchv1 "k8s.io/api/batch/v1" @@ -84,6 +84,10 @@ func (c *productionStrategy) Create() []runtime.Object { } } + if c.jaeger.Spec.SparkDependencies.Enabled { + os = append(os, cronjob.Create(c.jaeger)) + } + return os } diff --git a/test/e2e/jaeger_test.go b/test/e2e/jaeger_test.go index 336855d91..5644002f9 100644 --- a/test/e2e/jaeger_test.go +++ b/test/e2e/jaeger_test.go @@ -40,6 +40,8 @@ func TestJaeger(t *testing.T) { t.Run("daemonset", DaemonSet) t.Run("sidecar", Sidecar) t.Run("cassandra", Cassandra) + t.Run("spark-dependencies-es", SparkDependenciesElasticsearch) + t.Run("spark-dependencies-cass", SparkDependenciesCassandra) }) } diff --git a/test/e2e/spark_dependencies_test.go b/test/e2e/spark_dependencies_test.go new file mode 100644 index 000000000..87d274fde --- /dev/null +++ b/test/e2e/spark_dependencies_test.go @@ -0,0 +1,86 @@ +package e2e + +import ( + "context" + "fmt" + "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" + framework "github.com/operator-framework/operator-sdk/pkg/test" + "github.com/operator-framework/operator-sdk/pkg/test/e2eutil" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "testing" +) + +func SparkDependenciesElasticsearch(t *testing.T) { + testCtx := prepare(t) + defer testCtx.Cleanup() + storage := v1alpha1.JaegerStorageSpec{ + Type: "elasticsearch", + Options: v1alpha1.NewOptions(map[string]interface{}{ + "es.server-urls": "http://elasticsearch.default.svc:9200", + "es.username": "elastic", + "es.password": "changeme"}), + } + if err := sparkTest(t, framework.Global, testCtx, storage); err != nil { + t.Fatal(err) + } +} + +func SparkDependenciesCassandra(t *testing.T) { + testCtx := prepare(t) + defer testCtx.Cleanup() + + storage := v1alpha1.JaegerStorageSpec{ + Type: "cassandra", + Options: v1alpha1.NewOptions(map[string]interface{}{"cassandra.servers": "cassandra.default.svc", "cassandra.keyspace": "jaeger_v1_datacenter1"}), + CassandraCreateSchema:v1alpha1.JaegerCassandraCreateSchemaSpec{Datacenter:"datacenter1", Mode: "prod"}, + } + if err := sparkTest(t, framework.Global, testCtx, storage); err != nil { + t.Fatal(err) + } +} + +func sparkTest(t *testing.T, f *framework.Framework, testCtx *framework.TestCtx, storage v1alpha1.JaegerStorageSpec) error { + namespace, err := testCtx.GetNamespace() + if err != nil { + return fmt.Errorf("could not get namespace: %v", err) + } + + name := "test-spark-deps" + j := &v1alpha1.Jaeger{ + TypeMeta: metav1.TypeMeta{ + Kind: "Jaeger", + APIVersion: "io.jaegertracing/v1alpha1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + }, + Spec: v1alpha1.JaegerSpec{ + Strategy: "allInOne", + AllInOne: v1alpha1.JaegerAllInOneSpec{}, + Storage: storage, + SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{ + Enabled: true, + // run immediately + Schedule: "*/1 * * * *", + }, + }, + } + + err = f.Client.Create(context.Background(), j, &framework.CleanupOptions{TestContext: testCtx, Timeout: timeout, RetryInterval: retryInterval}) + if err != nil { + return err + } + + err = WaitForCronJob(t, f.KubeClient, namespace, fmt.Sprintf("%s-spark-dependencies", name), retryInterval, timeout) + if err != nil { + return err + } + + err = WaitForJobOfAnOwner(t, f.KubeClient, namespace, fmt.Sprintf("%s-spark-dependencies", name), retryInterval, timeout) + if err != nil { + return err + } + + return e2eutil.WaitForDeployment(t, f.KubeClient, namespace, name, 1, retryInterval, timeout) +} diff --git a/test/e2e/wait_util.go b/test/e2e/wait_util.go index 39d286c8a..fafe9b007 100644 --- a/test/e2e/wait_util.go +++ b/test/e2e/wait_util.go @@ -113,3 +113,57 @@ func WaitForJob(t *testing.T, kubeclient kubernetes.Interface, namespace, name s t.Logf("Jobs succeeded\n") return nil } + +// WaitForJobOfAnOwner checks to see if a given job has completed successfully +// See #WaitForDeployment for the full semantics +func WaitForJobOfAnOwner(t *testing.T, kubeclient kubernetes.Interface, namespace, ownerName string, retryInterval, timeout time.Duration) error { + err := wait.Poll(retryInterval, timeout, func() (done bool, err error) { + jobList, err := kubeclient.BatchV1().Jobs(namespace).List(metav1.ListOptions{IncludeUninitialized: true}) + if err != nil { + if apierrors.IsNotFound(err) { + t.Logf("Waiting for availability of %s job owner\n", ownerName) + return false, nil + } + return false, err + } + for _, j := range jobList.Items { + for _, r := range j.OwnerReferences { + if ownerName == r.Name && j.Status.Succeeded > 0 && j.Status.Failed == 0 && j.Status.Active == 0 { + return true, nil + } + } + } + t.Logf("Waiting for job of owner %s to succeed.", ownerName) + return false, nil + }) + if err != nil { + return err + } + t.Logf("Jobs succeeded\n") + return nil +} + +// WaitForCronJob checks to see if a given cron job scheduled a job +// See #WaitForDeployment for the full semantics +func WaitForCronJob(t *testing.T, kubeclient kubernetes.Interface, namespace, name string, retryInterval, timeout time.Duration) error { + err := wait.Poll(retryInterval, timeout, func() (done bool, err error) { + cronJob, err := kubeclient.BatchV1beta1().CronJobs(namespace).Get(name, metav1.GetOptions{IncludeUninitialized: true}) + if err != nil { + if apierrors.IsNotFound(err) { + t.Logf("Waiting for availability of %s cronjob\n", name) + return false, nil + } + return false, err + } + if cronJob.Status.LastScheduleTime != nil { + return true, nil + } + t.Logf("Waiting for conjob %s to have scheduled", name) + return false, nil + }) + if err != nil { + return err + } + t.Logf("CronJob succeeded\n") + return nil +} From ca1c98aadddcdb5bd5afc854ca2786fe635f1fbb Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Thu, 29 Nov 2018 17:27:51 +0100 Subject: [PATCH 2/9] Add generate Signed-off-by: Pavol Loffay --- pkg/apis/io/v1alpha1/zz_generated.deepcopy.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go index 769873537..f2430a622 100644 --- a/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go @@ -261,6 +261,7 @@ func (in *JaegerQuerySpec) DeepCopy() *JaegerQuerySpec { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +<<<<<<< HEAD func (in *JaegerSamplingSpec) DeepCopyInto(out *JaegerSamplingSpec) { *out = *in in.Options.DeepCopyInto(&out.Options) @@ -278,6 +279,8 @@ func (in *JaegerSamplingSpec) DeepCopy() *JaegerSamplingSpec { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +======= +>>>>>>> Add generate func (in *JaegerSparkDependenciesSpec) DeepCopyInto(out *JaegerSparkDependenciesSpec) { *out = *in return From 44275bc891e4bcef0612f221e245ddc8defe9c47 Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Fri, 30 Nov 2018 14:15:49 +0100 Subject: [PATCH 3/9] Increase coverage Signed-off-by: Pavol Loffay --- deploy/examples/simple-prod.yaml | 4 ++- deploy/examples/simplest.yaml | 10 +++++++ pkg/cronjob/spark_dependencies.go | 12 ++++---- pkg/cronjob/spark_dependencies_test.go | 2 -- pkg/strategy/all-in-one.go | 2 +- pkg/strategy/all-in-one_test.go | 41 ++++++++++++++++++++++++++ pkg/strategy/controller_test.go | 20 +++++++++++-- pkg/strategy/production.go | 2 +- pkg/strategy/production_test.go | 6 ++++ 9 files changed, 86 insertions(+), 13 deletions(-) diff --git a/deploy/examples/simple-prod.yaml b/deploy/examples/simple-prod.yaml index 2233d186a..fdc341d0c 100644 --- a/deploy/examples/simple-prod.yaml +++ b/deploy/examples/simple-prod.yaml @@ -4,7 +4,7 @@ kind: Jaeger metadata: name: simple-prod spec: - strategy: production + strategy: allInOne storage: type: elasticsearch options: @@ -12,3 +12,5 @@ spec: server-urls: http://elasticsearch:9200 username: elastic password: changeme + sparkDependencies: + enabled: true diff --git a/deploy/examples/simplest.yaml b/deploy/examples/simplest.yaml index 0e78189cc..cbe9fe830 100644 --- a/deploy/examples/simplest.yaml +++ b/deploy/examples/simplest.yaml @@ -2,3 +2,13 @@ apiVersion: io.jaegertracing/v1alpha1 kind: Jaeger metadata: name: simplest + strategy: allInOne + storage: + type: elasticsearch + options: + es: + server-urls: http://elasticsearch:9200 + username: elastic + password: changeme + sparkDependencies: + enabled: true diff --git a/pkg/cronjob/spark_dependencies.go b/pkg/cronjob/spark_dependencies.go index 122ad0f1b..f8324bad6 100644 --- a/pkg/cronjob/spark_dependencies.go +++ b/pkg/cronjob/spark_dependencies.go @@ -14,14 +14,12 @@ import ( var supportedStorageTypes = map[string]bool{"elasticsearch": true, "cassandra": true} -func Create(jaeger *v1alpha1.Jaeger) *batchv1beta1.CronJob { - if ok := supportedStorageTypes[jaeger.Spec.Storage.Type]; !ok { - return nil - } +func SupportedStorage(storage string) bool { + return supportedStorageTypes[storage] +} +func Create(jaeger *v1alpha1.Jaeger) *batchv1beta1.CronJob { applyDefaults(jaeger) - trueVar := true - name := fmt.Sprintf("%s-spark-dependencies", jaeger.Name) envVars := []v1.EnvVar{ {Name: "STORAGE", Value: jaeger.Spec.Storage.Type}, @@ -30,6 +28,8 @@ func Create(jaeger *v1alpha1.Jaeger) *batchv1beta1.CronJob { } envVars = append(envVars, getStorageEnvs(jaeger.Spec.Storage, jaeger.Spec.SparkDependencies)...) + trueVar := true + name := fmt.Sprintf("%s-spark-dependencies", jaeger.Name) return &batchv1beta1.CronJob{ ObjectMeta: metav1.ObjectMeta{ Name: name, diff --git a/pkg/cronjob/spark_dependencies_test.go b/pkg/cronjob/spark_dependencies_test.go index 7f6329efe..f49e9a7e8 100644 --- a/pkg/cronjob/spark_dependencies_test.go +++ b/pkg/cronjob/spark_dependencies_test.go @@ -75,7 +75,5 @@ func TestStorageEnvs(t *testing.T) { } func TestCreate(t *testing.T) { - assert.Nil(t, Create(&v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{Storage: v1alpha1.JaegerStorageSpec{Type: "foo"}}})) assert.NotNil(t, Create(&v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{Storage: v1alpha1.JaegerStorageSpec{Type: "elasticsearch"}}})) - assert.NotNil(t, Create(&v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{Storage: v1alpha1.JaegerStorageSpec{Type: "cassandra"}}})) } diff --git a/pkg/strategy/all-in-one.go b/pkg/strategy/all-in-one.go index ec4263466..2f0388e58 100644 --- a/pkg/strategy/all-in-one.go +++ b/pkg/strategy/all-in-one.go @@ -79,7 +79,7 @@ func (c *allInOneStrategy) Create() []runtime.Object { } } - if c.jaeger.Spec.SparkDependencies.Enabled { + if c.jaeger.Spec.SparkDependencies.Enabled && cronjob.SupportedStorage(c.jaeger.Spec.Storage.Type) { os = append(os, cronjob.Create(c.jaeger)) } diff --git a/pkg/strategy/all-in-one_test.go b/pkg/strategy/all-in-one_test.go index 6f7b6178a..d2058e273 100644 --- a/pkg/strategy/all-in-one_test.go +++ b/pkg/strategy/all-in-one_test.go @@ -3,6 +3,7 @@ package strategy import ( "context" "fmt" + "reflect" "testing" "github.com/spf13/viper" @@ -11,6 +12,7 @@ import ( "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" "github.com/jaegertracing/jaeger-operator/pkg/storage" + batchv1beta1 "k8s.io/api/batch/v1beta1" ) func init() { @@ -131,3 +133,42 @@ func assertDeploymentsAndServicesForAllInOne(t *testing.T, name string, objs []r } assertHasAllObjects(t, name, objs, deployments, daemonsets, services, ingresses, routes, serviceAccounts, configMaps) } + +func TestSparkDependenciesAllInOne(t *testing.T) { + testSparkDependencies(t, func(jaeger *v1alpha1.Jaeger) S { + return &allInOneStrategy{jaeger: jaeger} + }) +} + +func testSparkDependencies(t *testing.T, fce func(jaeger *v1alpha1.Jaeger) S) { + tests := []struct { + jaeger *v1alpha1.Jaeger + sparkCronJobEnabled bool + }{ + {jaeger: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{ + Storage: v1alpha1.JaegerStorageSpec{Type: "elasticsearch"}, + SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Enabled: true}, + }}, sparkCronJobEnabled: true}, + {jaeger: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{ + Storage: v1alpha1.JaegerStorageSpec{Type: "cassandra"}, + SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Enabled: true}, + }}, sparkCronJobEnabled: true}, + {jaeger: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{ + Storage: v1alpha1.JaegerStorageSpec{Type: "kafka"}, + SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Enabled: true}, + }}, sparkCronJobEnabled: false}, + {jaeger: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{ + Storage: v1alpha1.JaegerStorageSpec{Type: "elasticsearch"}, + }}, sparkCronJobEnabled: false}, + } + for _, test := range tests { + s := fce(test.jaeger) + objs := s.Create() + cronJobs := getTypesOf(objs, reflect.TypeOf(&batchv1beta1.CronJob{})) + if test.sparkCronJobEnabled { + assert.Equal(t, 1, len(cronJobs)) + } else { + assert.Equal(t, 0, len(cronJobs)) + } + } +} diff --git a/pkg/strategy/controller_test.go b/pkg/strategy/controller_test.go index 53ad21ee0..7b56d3b8b 100644 --- a/pkg/strategy/controller_test.go +++ b/pkg/strategy/controller_test.go @@ -2,8 +2,11 @@ package strategy import ( "context" + "fmt" + "reflect" "testing" + "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" osv1 "github.com/openshift/api/route/v1" "github.com/spf13/viper" "github.com/stretchr/testify/assert" @@ -11,8 +14,6 @@ import ( "k8s.io/api/core/v1" "k8s.io/api/extensions/v1beta1" "k8s.io/apimachinery/pkg/runtime" - - "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" ) func TestNewControllerForAllInOneAsDefault(t *testing.T) { @@ -229,3 +230,18 @@ func assertHasAllObjects(t *testing.T, name string, objs []runtime.Object, deplo assert.True(t, v, "Expected %s to have been returned from the list of config maps", k) } } + +func getTypesOf( + objs []runtime.Object, + typ reflect.Type, +) []runtime.Object { + var theTypes []runtime.Object + for _, obj := range objs { + if typ == reflect.TypeOf(obj) { + fmt.Println("appending") + fmt.Println(reflect.TypeOf(obj)) + theTypes = append(theTypes, obj) + } + } + return theTypes +} diff --git a/pkg/strategy/production.go b/pkg/strategy/production.go index ec8d33493..54c54f8e8 100644 --- a/pkg/strategy/production.go +++ b/pkg/strategy/production.go @@ -84,7 +84,7 @@ func (c *productionStrategy) Create() []runtime.Object { } } - if c.jaeger.Spec.SparkDependencies.Enabled { + if c.jaeger.Spec.SparkDependencies.Enabled && cronjob.SupportedStorage(c.jaeger.Spec.Storage.Type) { os = append(os, cronjob.Create(c.jaeger)) } diff --git a/pkg/strategy/production_test.go b/pkg/strategy/production_test.go index d477caba3..5f5e5e7bf 100644 --- a/pkg/strategy/production_test.go +++ b/pkg/strategy/production_test.go @@ -172,3 +172,9 @@ func assertDeploymentsAndServicesForProduction(t *testing.T, name string, objs [ } assertHasAllObjects(t, name, objs, deployments, daemonsets, services, ingresses, routes, serviceAccounts, configMaps) } + +func TestSparkDependenciesProduction(t *testing.T) { + testSparkDependencies(t, func(jaeger *v1alpha1.Jaeger) S { + return &productionStrategy{jaeger: jaeger} + }) +} From 0021f238676ab78e9cc46dfb1a92268f741e2bc2 Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Mon, 3 Dec 2018 16:51:03 +0100 Subject: [PATCH 4/9] Fix some review comments Signed-off-by: Pavol Loffay --- pkg/apis/io/v1alpha1/zz_generated.deepcopy.go | 3 --- pkg/cronjob/spark_dependencies_test.go | 6 ++++-- pkg/strategy/controller_test.go | 4 ---- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go index f2430a622..769873537 100644 --- a/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go @@ -261,7 +261,6 @@ func (in *JaegerQuerySpec) DeepCopy() *JaegerQuerySpec { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -<<<<<<< HEAD func (in *JaegerSamplingSpec) DeepCopyInto(out *JaegerSamplingSpec) { *out = *in in.Options.DeepCopyInto(&out.Options) @@ -279,8 +278,6 @@ func (in *JaegerSamplingSpec) DeepCopy() *JaegerSamplingSpec { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -======= ->>>>>>> Add generate func (in *JaegerSparkDependenciesSpec) DeepCopyInto(out *JaegerSparkDependenciesSpec) { *out = *in return diff --git a/pkg/cronjob/spark_dependencies_test.go b/pkg/cronjob/spark_dependencies_test.go index f49e9a7e8..0ea96f01f 100644 --- a/pkg/cronjob/spark_dependencies_test.go +++ b/pkg/cronjob/spark_dependencies_test.go @@ -12,8 +12,10 @@ func TestApplyDefaults(t *testing.T) { underTest *v1alpha1.Jaeger expected *v1alpha1.Jaeger }{ - {underTest: &v1alpha1.Jaeger{}, expected: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "55 23 * * *"}}}}, - {underTest: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "foo"}}}, expected: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "foo"}}}}, + {underTest: &v1alpha1.Jaeger{}, expected: + &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "55 23 * * *"}}}}, + {underTest: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "foo"}}}, + expected: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "foo"}}}}, } for _, test := range tests { applyDefaults(test.underTest) diff --git a/pkg/strategy/controller_test.go b/pkg/strategy/controller_test.go index 7b56d3b8b..6c52063f3 100644 --- a/pkg/strategy/controller_test.go +++ b/pkg/strategy/controller_test.go @@ -2,7 +2,6 @@ package strategy import ( "context" - "fmt" "reflect" "testing" @@ -176,7 +175,6 @@ func getDeployments(objs []runtime.Object) []*appsv1.Deployment { deps = append(deps, obj.(*appsv1.Deployment)) } } - return deps } @@ -238,8 +236,6 @@ func getTypesOf( var theTypes []runtime.Object for _, obj := range objs { if typ == reflect.TypeOf(obj) { - fmt.Println("appending") - fmt.Println(reflect.TypeOf(obj)) theTypes = append(theTypes, obj) } } From 75e1c950b8e41be8a5c685cbdb25968b2d7b1606 Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Mon, 3 Dec 2018 17:01:06 +0100 Subject: [PATCH 5/9] Fix format Signed-off-by: Pavol Loffay --- pkg/apis/io/v1alpha1/jaeger_types.go | 2 +- pkg/cronjob/spark_dependencies_test.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/apis/io/v1alpha1/jaeger_types.go b/pkg/apis/io/v1alpha1/jaeger_types.go index ed67cad56..0ee6f271a 100644 --- a/pkg/apis/io/v1alpha1/jaeger_types.go +++ b/pkg/apis/io/v1alpha1/jaeger_types.go @@ -52,7 +52,7 @@ type JaegerSpec struct { Collector JaegerCollectorSpec `json:"collector"` Agent JaegerAgentSpec `json:"agent"` UI JaegerUISpec `json:"ui"` - Sampling JaegerSamplingSpec `json:"sampling"` + Sampling JaegerSamplingSpec `json:"sampling"` Storage JaegerStorageSpec `json:"storage"` Ingress JaegerIngressSpec `json:"ingress"` SparkDependencies JaegerSparkDependenciesSpec `json:"sparkDependencies"` diff --git a/pkg/cronjob/spark_dependencies_test.go b/pkg/cronjob/spark_dependencies_test.go index 0ea96f01f..43ff506a1 100644 --- a/pkg/cronjob/spark_dependencies_test.go +++ b/pkg/cronjob/spark_dependencies_test.go @@ -12,8 +12,7 @@ func TestApplyDefaults(t *testing.T) { underTest *v1alpha1.Jaeger expected *v1alpha1.Jaeger }{ - {underTest: &v1alpha1.Jaeger{}, expected: - &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "55 23 * * *"}}}}, + {underTest: &v1alpha1.Jaeger{}, expected: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "55 23 * * *"}}}}, {underTest: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "foo"}}}, expected: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "foo"}}}}, } From 0d6d2f0dc0eafdfe784ccd60bb0883de6c6495d6 Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Mon, 3 Dec 2018 17:14:15 +0100 Subject: [PATCH 6/9] Fix review comments Signed-off-by: Pavol Loffay --- deploy/examples/simple-prod.yaml | 4 +-- deploy/examples/simplest.yaml | 10 ------- pkg/apis/io/v1alpha1/jaeger_types.go | 20 ++++++------- pkg/apis/io/v1alpha1/zz_generated.deepcopy.go | 2 +- pkg/cronjob/spark_dependencies.go | 30 +++++++++---------- pkg/cronjob/spark_dependencies_test.go | 12 ++++---- pkg/strategy/all-in-one.go | 8 +++-- pkg/strategy/all-in-one_test.go | 12 ++++---- pkg/strategy/production.go | 8 +++-- test/e2e/spark_dependencies_test.go | 11 +++---- 10 files changed, 59 insertions(+), 58 deletions(-) diff --git a/deploy/examples/simple-prod.yaml b/deploy/examples/simple-prod.yaml index fdc341d0c..a18a07121 100644 --- a/deploy/examples/simple-prod.yaml +++ b/deploy/examples/simple-prod.yaml @@ -12,5 +12,5 @@ spec: server-urls: http://elasticsearch:9200 username: elastic password: changeme - sparkDependencies: - enabled: true + sparkDependencies: + enabled: true diff --git a/deploy/examples/simplest.yaml b/deploy/examples/simplest.yaml index cbe9fe830..0e78189cc 100644 --- a/deploy/examples/simplest.yaml +++ b/deploy/examples/simplest.yaml @@ -2,13 +2,3 @@ apiVersion: io.jaegertracing/v1alpha1 kind: Jaeger metadata: name: simplest - strategy: allInOne - storage: - type: elasticsearch - options: - es: - server-urls: http://elasticsearch:9200 - username: elastic - password: changeme - sparkDependencies: - enabled: true diff --git a/pkg/apis/io/v1alpha1/jaeger_types.go b/pkg/apis/io/v1alpha1/jaeger_types.go index 0ee6f271a..057c1e3ae 100644 --- a/pkg/apis/io/v1alpha1/jaeger_types.go +++ b/pkg/apis/io/v1alpha1/jaeger_types.go @@ -46,16 +46,15 @@ type Jaeger struct { // JaegerSpec defines the structure of the Jaeger JSON object from the CR type JaegerSpec struct { - Strategy string `json:"strategy"` - AllInOne JaegerAllInOneSpec `json:"allInOne"` - Query JaegerQuerySpec `json:"query"` - Collector JaegerCollectorSpec `json:"collector"` - Agent JaegerAgentSpec `json:"agent"` - UI JaegerUISpec `json:"ui"` - Sampling JaegerSamplingSpec `json:"sampling"` - Storage JaegerStorageSpec `json:"storage"` - Ingress JaegerIngressSpec `json:"ingress"` - SparkDependencies JaegerSparkDependenciesSpec `json:"sparkDependencies"` + Strategy string `json:"strategy"` + AllInOne JaegerAllInOneSpec `json:"allInOne"` + Query JaegerQuerySpec `json:"query"` + Collector JaegerCollectorSpec `json:"collector"` + Agent JaegerAgentSpec `json:"agent"` + UI JaegerUISpec `json:"ui"` + Sampling JaegerSamplingSpec `json:"sampling"` + Storage JaegerStorageSpec `json:"storage"` + Ingress JaegerIngressSpec `json:"ingress"` JaegerCommonSpec } @@ -126,6 +125,7 @@ type JaegerStorageSpec struct { SecretName string `json:"secretName"` Options Options `json:"options"` CassandraCreateSchema JaegerCassandraCreateSchemaSpec `json:"cassandraCreateSchema"` + SparkDependencies JaegerSparkDependenciesSpec `json:"sparkDependencies"` } // JaegerCassandraCreateSchemaSpec holds the options related to the create-schema batch job diff --git a/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go index 769873537..2f01e1e32 100644 --- a/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go @@ -304,7 +304,6 @@ func (in *JaegerSpec) DeepCopyInto(out *JaegerSpec) { in.Sampling.DeepCopyInto(&out.Sampling) in.Storage.DeepCopyInto(&out.Storage) in.Ingress.DeepCopyInto(&out.Ingress) - out.SparkDependencies = in.SparkDependencies in.JaegerCommonSpec.DeepCopyInto(&out.JaegerCommonSpec) return } @@ -340,6 +339,7 @@ func (in *JaegerStorageSpec) DeepCopyInto(out *JaegerStorageSpec) { *out = *in in.Options.DeepCopyInto(&out.Options) in.CassandraCreateSchema.DeepCopyInto(&out.CassandraCreateSchema) + out.SparkDependencies = in.SparkDependencies return } diff --git a/pkg/cronjob/spark_dependencies.go b/pkg/cronjob/spark_dependencies.go index f8324bad6..cdd6630f4 100644 --- a/pkg/cronjob/spark_dependencies.go +++ b/pkg/cronjob/spark_dependencies.go @@ -23,10 +23,10 @@ func Create(jaeger *v1alpha1.Jaeger) *batchv1beta1.CronJob { envVars := []v1.EnvVar{ {Name: "STORAGE", Value: jaeger.Spec.Storage.Type}, - {Name: "SPARK_MASTER", Value: jaeger.Spec.SparkDependencies.SparkMaster}, - {Name: "JAVA_OPTS", Value: jaeger.Spec.SparkDependencies.JavaOpts}, + {Name: "SPARK_MASTER", Value: jaeger.Spec.Storage.SparkDependencies.SparkMaster}, + {Name: "JAVA_OPTS", Value: jaeger.Spec.Storage.SparkDependencies.JavaOpts}, } - envVars = append(envVars, getStorageEnvs(jaeger.Spec.Storage, jaeger.Spec.SparkDependencies)...) + envVars = append(envVars, getStorageEnvs(jaeger.Spec.Storage)...) trueVar := true name := fmt.Sprintf("%s-spark-dependencies", jaeger.Name) @@ -45,14 +45,14 @@ func Create(jaeger *v1alpha1.Jaeger) *batchv1beta1.CronJob { }, }, Spec: batchv1beta1.CronJobSpec{ - Schedule: jaeger.Spec.SparkDependencies.Schedule, + Schedule: jaeger.Spec.Storage.SparkDependencies.Schedule, JobTemplate: batchv1beta1.JobTemplateSpec{ Spec: batchv1.JobSpec{ Template: v1.PodTemplateSpec{ Spec: v1.PodSpec{ Containers: []v1.Container{ { - Image: jaeger.Spec.SparkDependencies.Image, + Image: jaeger.Spec.Storage.SparkDependencies.Image, Name: name, // let spark job use its default values Env: removeEmptyVars(envVars), @@ -73,7 +73,7 @@ func Create(jaeger *v1alpha1.Jaeger) *batchv1beta1.CronJob { } } -func getStorageEnvs(s v1alpha1.JaegerStorageSpec, sj v1alpha1.JaegerSparkDependenciesSpec) []v1.EnvVar { +func getStorageEnvs(s v1alpha1.JaegerStorageSpec) []v1.EnvVar { sFlags := s.Options.Filter(storage.OptionsPrefix(s.Type)) sFlagsMap := sFlags.Map() keyspace := sFlagsMap["cassandra.keyspace"] @@ -87,9 +87,9 @@ func getStorageEnvs(s v1alpha1.JaegerStorageSpec, sj v1alpha1.JaegerSparkDepende {Name: "CASSANDRA_KEYSPACE", Value: keyspace}, {Name: "CASSANDRA_USERNAME", Value: sFlagsMap["cassandra.username"]}, {Name: "CASSANDRA_PASSWORD", Value: sFlagsMap["cassandra.password"]}, - {Name: "CASSANDRA_USE_SSL", Value: strconv.FormatBool(sj.CassandraUseSsl)}, - {Name: "CASSANDRA_LOCAL_DC", Value: sj.CassandraLocalDc}, - {Name: "CASSANDRA_CLIENT_AUTH_ENABLED", Value: strconv.FormatBool(sj.CassandraClientAuthEnabled)}, + {Name: "CASSANDRA_USE_SSL", Value: strconv.FormatBool(s.SparkDependencies.CassandraUseSsl)}, + {Name: "CASSANDRA_LOCAL_DC", Value: s.SparkDependencies.CassandraLocalDc}, + {Name: "CASSANDRA_CLIENT_AUTH_ENABLED", Value: strconv.FormatBool(s.SparkDependencies.CassandraClientAuthEnabled)}, } case "elasticsearch": return []v1.EnvVar{ @@ -97,8 +97,8 @@ func getStorageEnvs(s v1alpha1.JaegerStorageSpec, sj v1alpha1.JaegerSparkDepende {Name: "ES_INDEX_PREFIX", Value: sFlagsMap["es.index-prefix"]}, {Name: "ES_USERNAME", Value: sFlagsMap["es.username"]}, {Name: "ES_PASSWORD", Value: sFlagsMap["es.password"]}, - {Name: "ES_CLIENT_NODE_ONLY", Value: strconv.FormatBool(sj.ElasticsearchClientNodeOnly)}, - {Name: "ES_NODES_WAN_ONLY", Value: strconv.FormatBool(sj.ElasticsearchNodesWanOnly)}, + {Name: "ES_CLIENT_NODE_ONLY", Value: strconv.FormatBool(s.SparkDependencies.ElasticsearchClientNodeOnly)}, + {Name: "ES_NODES_WAN_ONLY", Value: strconv.FormatBool(s.SparkDependencies.ElasticsearchNodesWanOnly)}, } default: return nil @@ -106,11 +106,11 @@ func getStorageEnvs(s v1alpha1.JaegerStorageSpec, sj v1alpha1.JaegerSparkDepende } func applyDefaults(jaeger *v1alpha1.Jaeger) { - if jaeger.Spec.SparkDependencies.Image == "" { - jaeger.Spec.SparkDependencies.Image = fmt.Sprintf("%s", viper.GetString("jaeger-spark-dependencies-image")) + if jaeger.Spec.Storage.SparkDependencies.Image == "" { + jaeger.Spec.Storage.SparkDependencies.Image = fmt.Sprintf("%s", viper.GetString("jaeger-spark-dependencies-image")) } - if jaeger.Spec.SparkDependencies.Schedule == "" { - jaeger.Spec.SparkDependencies.Schedule = "55 23 * * *" + if jaeger.Spec.Storage.SparkDependencies.Schedule == "" { + jaeger.Spec.Storage.SparkDependencies.Schedule = "55 23 * * *" } } diff --git a/pkg/cronjob/spark_dependencies_test.go b/pkg/cronjob/spark_dependencies_test.go index 43ff506a1..380621cbe 100644 --- a/pkg/cronjob/spark_dependencies_test.go +++ b/pkg/cronjob/spark_dependencies_test.go @@ -12,9 +12,12 @@ func TestApplyDefaults(t *testing.T) { underTest *v1alpha1.Jaeger expected *v1alpha1.Jaeger }{ - {underTest: &v1alpha1.Jaeger{}, expected: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "55 23 * * *"}}}}, - {underTest: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "foo"}}}, - expected: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "foo"}}}}, + {underTest: &v1alpha1.Jaeger{}, expected: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{Storage: v1alpha1.JaegerStorageSpec{ + SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "55 23 * * *"}}}}}, + {underTest: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{Storage: v1alpha1.JaegerStorageSpec{ + SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "foo"}}}}, + expected: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{Storage: v1alpha1.JaegerStorageSpec{ + SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "foo"}}}}}, } for _, test := range tests { applyDefaults(test.underTest) @@ -41,7 +44,6 @@ func TestRemoveEmptyVars(t *testing.T) { func TestStorageEnvs(t *testing.T) { tests := []struct { storage v1alpha1.JaegerStorageSpec - deps v1alpha1.JaegerSparkDependenciesSpec expected []v1.EnvVar }{ {storage: v1alpha1.JaegerStorageSpec{Type: "foo"}}, @@ -70,7 +72,7 @@ func TestStorageEnvs(t *testing.T) { }}, } for _, test := range tests { - envVars := getStorageEnvs(test.storage, test.deps) + envVars := getStorageEnvs(test.storage) assert.Equal(t, test.expected, envVars) } } diff --git a/pkg/strategy/all-in-one.go b/pkg/strategy/all-in-one.go index 2f0388e58..838e5c8e7 100644 --- a/pkg/strategy/all-in-one.go +++ b/pkg/strategy/all-in-one.go @@ -79,8 +79,12 @@ func (c *allInOneStrategy) Create() []runtime.Object { } } - if c.jaeger.Spec.SparkDependencies.Enabled && cronjob.SupportedStorage(c.jaeger.Spec.Storage.Type) { - os = append(os, cronjob.Create(c.jaeger)) + if cronjob.SupportedStorage(c.jaeger.Spec.Storage.Type) { + if c.jaeger.Spec.Storage.SparkDependencies.Enabled { + os = append(os, cronjob.Create(c.jaeger)) + } else { + logrus.Info("Spark dependencies are disabled - need to be enabled explicitly") + } } return os diff --git a/pkg/strategy/all-in-one_test.go b/pkg/strategy/all-in-one_test.go index d2058e273..c5ee0137d 100644 --- a/pkg/strategy/all-in-one_test.go +++ b/pkg/strategy/all-in-one_test.go @@ -146,16 +146,16 @@ func testSparkDependencies(t *testing.T, fce func(jaeger *v1alpha1.Jaeger) S) { sparkCronJobEnabled bool }{ {jaeger: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{ - Storage: v1alpha1.JaegerStorageSpec{Type: "elasticsearch"}, - SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Enabled: true}, + Storage: v1alpha1.JaegerStorageSpec{Type: "elasticsearch", + SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Enabled: true}}, }}, sparkCronJobEnabled: true}, {jaeger: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{ - Storage: v1alpha1.JaegerStorageSpec{Type: "cassandra"}, - SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Enabled: true}, + Storage: v1alpha1.JaegerStorageSpec{Type: "cassandra", + SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Enabled: true}}, }}, sparkCronJobEnabled: true}, {jaeger: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{ - Storage: v1alpha1.JaegerStorageSpec{Type: "kafka"}, - SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Enabled: true}, + Storage: v1alpha1.JaegerStorageSpec{Type: "kafka", + SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Enabled: true}}, }}, sparkCronJobEnabled: false}, {jaeger: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{ Storage: v1alpha1.JaegerStorageSpec{Type: "elasticsearch"}, diff --git a/pkg/strategy/production.go b/pkg/strategy/production.go index 54c54f8e8..590505068 100644 --- a/pkg/strategy/production.go +++ b/pkg/strategy/production.go @@ -84,8 +84,12 @@ func (c *productionStrategy) Create() []runtime.Object { } } - if c.jaeger.Spec.SparkDependencies.Enabled && cronjob.SupportedStorage(c.jaeger.Spec.Storage.Type) { - os = append(os, cronjob.Create(c.jaeger)) + if cronjob.SupportedStorage(c.jaeger.Spec.Storage.Type) { + if c.jaeger.Spec.Storage.SparkDependencies.Enabled { + os = append(os, cronjob.Create(c.jaeger)) + } else { + logrus.Info("Do not installing spark dependencies - need to be enabled explicitly") + } } return os diff --git a/test/e2e/spark_dependencies_test.go b/test/e2e/spark_dependencies_test.go index 87d274fde..d80c2fc2b 100644 --- a/test/e2e/spark_dependencies_test.go +++ b/test/e2e/spark_dependencies_test.go @@ -45,6 +45,12 @@ func sparkTest(t *testing.T, f *framework.Framework, testCtx *framework.TestCtx, return fmt.Errorf("could not get namespace: %v", err) } + storage.SparkDependencies = v1alpha1.JaegerSparkDependenciesSpec{ + Enabled: true, + // run immediately + Schedule: "*/1 * * * *", + } + name := "test-spark-deps" j := &v1alpha1.Jaeger{ TypeMeta: metav1.TypeMeta{ @@ -59,11 +65,6 @@ func sparkTest(t *testing.T, f *framework.Framework, testCtx *framework.TestCtx, Strategy: "allInOne", AllInOne: v1alpha1.JaegerAllInOneSpec{}, Storage: storage, - SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{ - Enabled: true, - // run immediately - Schedule: "*/1 * * * *", - }, }, } From e07a7ca9917a3476d0bcdd942b9b922933ca330d Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Tue, 4 Dec 2018 13:14:48 +0100 Subject: [PATCH 7/9] Use production in prod example Signed-off-by: Pavol Loffay --- deploy/examples/simple-prod.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/examples/simple-prod.yaml b/deploy/examples/simple-prod.yaml index a18a07121..ebe2dd3e4 100644 --- a/deploy/examples/simple-prod.yaml +++ b/deploy/examples/simple-prod.yaml @@ -4,7 +4,7 @@ kind: Jaeger metadata: name: simple-prod spec: - strategy: allInOne + strategy: production storage: type: elasticsearch options: From ce78f19db1c09aaeaa54d6c2876fc74c962b69db Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Tue, 4 Dec 2018 13:17:08 +0100 Subject: [PATCH 8/9] Rename sparkDependencies to dependencies Signed-off-by: Pavol Loffay --- deploy/examples/simple-prod.yaml | 2 +- pkg/apis/io/v1alpha1/jaeger_types.go | 6 ++-- pkg/apis/io/v1alpha1/zz_generated.deepcopy.go | 32 +++++++++---------- pkg/cronjob/spark_dependencies_test.go | 6 ++-- pkg/strategy/all-in-one_test.go | 6 ++-- test/e2e/spark_dependencies_test.go | 2 +- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/deploy/examples/simple-prod.yaml b/deploy/examples/simple-prod.yaml index ebe2dd3e4..1745f732d 100644 --- a/deploy/examples/simple-prod.yaml +++ b/deploy/examples/simple-prod.yaml @@ -12,5 +12,5 @@ spec: server-urls: http://elasticsearch:9200 username: elastic password: changeme - sparkDependencies: + dependencies: enabled: true diff --git a/pkg/apis/io/v1alpha1/jaeger_types.go b/pkg/apis/io/v1alpha1/jaeger_types.go index 057c1e3ae..29b925119 100644 --- a/pkg/apis/io/v1alpha1/jaeger_types.go +++ b/pkg/apis/io/v1alpha1/jaeger_types.go @@ -125,7 +125,7 @@ type JaegerStorageSpec struct { SecretName string `json:"secretName"` Options Options `json:"options"` CassandraCreateSchema JaegerCassandraCreateSchemaSpec `json:"cassandraCreateSchema"` - SparkDependencies JaegerSparkDependenciesSpec `json:"sparkDependencies"` + SparkDependencies JaegerDependenciesSpec `json:"dependencies"` } // JaegerCassandraCreateSchemaSpec holds the options related to the create-schema batch job @@ -136,8 +136,8 @@ type JaegerCassandraCreateSchemaSpec struct { Mode string `json:"mode"` } -// JaegerSparkDependenciesSpec defined options for running spark-dependencies. -type JaegerSparkDependenciesSpec struct { +// JaegerDependenciesSpec defined options for running spark-dependencies. +type JaegerDependenciesSpec struct { Enabled bool `json:"enabled"` SparkMaster string `json:"sparkMaster"` Schedule string `json:"schedule"` diff --git a/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go index 2f01e1e32..74413a814 100644 --- a/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go @@ -187,6 +187,22 @@ func (in *JaegerCommonSpec) DeepCopy() *JaegerCommonSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *JaegerDependenciesSpec) DeepCopyInto(out *JaegerDependenciesSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JaegerDependenciesSpec. +func (in *JaegerDependenciesSpec) DeepCopy() *JaegerDependenciesSpec { + if in == nil { + return nil + } + out := new(JaegerDependenciesSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *JaegerIngressSpec) DeepCopyInto(out *JaegerIngressSpec) { *out = *in @@ -277,22 +293,6 @@ func (in *JaegerSamplingSpec) DeepCopy() *JaegerSamplingSpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JaegerSparkDependenciesSpec) DeepCopyInto(out *JaegerSparkDependenciesSpec) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JaegerSparkDependenciesSpec. -func (in *JaegerSparkDependenciesSpec) DeepCopy() *JaegerSparkDependenciesSpec { - if in == nil { - return nil - } - out := new(JaegerSparkDependenciesSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *JaegerSpec) DeepCopyInto(out *JaegerSpec) { *out = *in diff --git a/pkg/cronjob/spark_dependencies_test.go b/pkg/cronjob/spark_dependencies_test.go index 380621cbe..41e34eb2f 100644 --- a/pkg/cronjob/spark_dependencies_test.go +++ b/pkg/cronjob/spark_dependencies_test.go @@ -13,11 +13,11 @@ func TestApplyDefaults(t *testing.T) { expected *v1alpha1.Jaeger }{ {underTest: &v1alpha1.Jaeger{}, expected: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{Storage: v1alpha1.JaegerStorageSpec{ - SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "55 23 * * *"}}}}}, + SparkDependencies: v1alpha1.JaegerDependenciesSpec{Schedule: "55 23 * * *"}}}}}, {underTest: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{Storage: v1alpha1.JaegerStorageSpec{ - SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "foo"}}}}, + SparkDependencies: v1alpha1.JaegerDependenciesSpec{Schedule: "foo"}}}}, expected: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{Storage: v1alpha1.JaegerStorageSpec{ - SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Schedule: "foo"}}}}}, + SparkDependencies: v1alpha1.JaegerDependenciesSpec{Schedule: "foo"}}}}}, } for _, test := range tests { applyDefaults(test.underTest) diff --git a/pkg/strategy/all-in-one_test.go b/pkg/strategy/all-in-one_test.go index c5ee0137d..b20974cbe 100644 --- a/pkg/strategy/all-in-one_test.go +++ b/pkg/strategy/all-in-one_test.go @@ -147,15 +147,15 @@ func testSparkDependencies(t *testing.T, fce func(jaeger *v1alpha1.Jaeger) S) { }{ {jaeger: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{ Storage: v1alpha1.JaegerStorageSpec{Type: "elasticsearch", - SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Enabled: true}}, + SparkDependencies: v1alpha1.JaegerDependenciesSpec{Enabled: true}}, }}, sparkCronJobEnabled: true}, {jaeger: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{ Storage: v1alpha1.JaegerStorageSpec{Type: "cassandra", - SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Enabled: true}}, + SparkDependencies: v1alpha1.JaegerDependenciesSpec{Enabled: true}}, }}, sparkCronJobEnabled: true}, {jaeger: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{ Storage: v1alpha1.JaegerStorageSpec{Type: "kafka", - SparkDependencies: v1alpha1.JaegerSparkDependenciesSpec{Enabled: true}}, + SparkDependencies: v1alpha1.JaegerDependenciesSpec{Enabled: true}}, }}, sparkCronJobEnabled: false}, {jaeger: &v1alpha1.Jaeger{Spec: v1alpha1.JaegerSpec{ Storage: v1alpha1.JaegerStorageSpec{Type: "elasticsearch"}, diff --git a/test/e2e/spark_dependencies_test.go b/test/e2e/spark_dependencies_test.go index d80c2fc2b..a2619a163 100644 --- a/test/e2e/spark_dependencies_test.go +++ b/test/e2e/spark_dependencies_test.go @@ -45,7 +45,7 @@ func sparkTest(t *testing.T, f *framework.Framework, testCtx *framework.TestCtx, return fmt.Errorf("could not get namespace: %v", err) } - storage.SparkDependencies = v1alpha1.JaegerSparkDependenciesSpec{ + storage.SparkDependencies = v1alpha1.JaegerDependenciesSpec{ Enabled: true, // run immediately Schedule: "*/1 * * * *", From 3be05eae2de15decc638b0dca5abf6db5c3989d2 Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Tue, 4 Dec 2018 13:18:13 +0100 Subject: [PATCH 9/9] Format code Signed-off-by: Pavol Loffay --- pkg/cronjob/spark_dependencies.go | 8 +++++--- pkg/cronjob/spark_dependencies_test.go | 6 ++++-- pkg/strategy/all-in-one.go | 2 +- pkg/strategy/all-in-one_test.go | 2 +- pkg/strategy/controller_test.go | 3 ++- pkg/strategy/production.go | 3 ++- test/e2e/spark_dependencies_test.go | 6 ++++-- 7 files changed, 19 insertions(+), 11 deletions(-) diff --git a/pkg/cronjob/spark_dependencies.go b/pkg/cronjob/spark_dependencies.go index cdd6630f4..c484c7559 100644 --- a/pkg/cronjob/spark_dependencies.go +++ b/pkg/cronjob/spark_dependencies.go @@ -2,14 +2,16 @@ package cronjob import ( "fmt" - "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" - "github.com/jaegertracing/jaeger-operator/pkg/storage" + "strconv" + "github.com/spf13/viper" batchv1 "k8s.io/api/batch/v1" batchv1beta1 "k8s.io/api/batch/v1beta1" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "strconv" + + "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" + "github.com/jaegertracing/jaeger-operator/pkg/storage" ) var supportedStorageTypes = map[string]bool{"elasticsearch": true, "cassandra": true} diff --git a/pkg/cronjob/spark_dependencies_test.go b/pkg/cronjob/spark_dependencies_test.go index 41e34eb2f..1a16de85f 100644 --- a/pkg/cronjob/spark_dependencies_test.go +++ b/pkg/cronjob/spark_dependencies_test.go @@ -1,10 +1,12 @@ package cronjob import ( - "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" + "testing" + "github.com/stretchr/testify/assert" "k8s.io/api/core/v1" - "testing" + + "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" ) func TestApplyDefaults(t *testing.T) { diff --git a/pkg/strategy/all-in-one.go b/pkg/strategy/all-in-one.go index 838e5c8e7..0252cffe4 100644 --- a/pkg/strategy/all-in-one.go +++ b/pkg/strategy/all-in-one.go @@ -2,7 +2,6 @@ package strategy import ( "context" - "github.com/jaegertracing/jaeger-operator/pkg/cronjob" "github.com/sirupsen/logrus" "github.com/spf13/viper" @@ -13,6 +12,7 @@ import ( "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" "github.com/jaegertracing/jaeger-operator/pkg/config/sampling" "github.com/jaegertracing/jaeger-operator/pkg/config/ui" + "github.com/jaegertracing/jaeger-operator/pkg/cronjob" "github.com/jaegertracing/jaeger-operator/pkg/deployment" "github.com/jaegertracing/jaeger-operator/pkg/ingress" "github.com/jaegertracing/jaeger-operator/pkg/inject" diff --git a/pkg/strategy/all-in-one_test.go b/pkg/strategy/all-in-one_test.go index b20974cbe..d237e7c71 100644 --- a/pkg/strategy/all-in-one_test.go +++ b/pkg/strategy/all-in-one_test.go @@ -8,11 +8,11 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/assert" + batchv1beta1 "k8s.io/api/batch/v1beta1" "k8s.io/apimachinery/pkg/runtime" "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" "github.com/jaegertracing/jaeger-operator/pkg/storage" - batchv1beta1 "k8s.io/api/batch/v1beta1" ) func init() { diff --git a/pkg/strategy/controller_test.go b/pkg/strategy/controller_test.go index 6c52063f3..57da3c1c7 100644 --- a/pkg/strategy/controller_test.go +++ b/pkg/strategy/controller_test.go @@ -5,7 +5,6 @@ import ( "reflect" "testing" - "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" osv1 "github.com/openshift/api/route/v1" "github.com/spf13/viper" "github.com/stretchr/testify/assert" @@ -13,6 +12,8 @@ import ( "k8s.io/api/core/v1" "k8s.io/api/extensions/v1beta1" "k8s.io/apimachinery/pkg/runtime" + + "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" ) func TestNewControllerForAllInOneAsDefault(t *testing.T) { diff --git a/pkg/strategy/production.go b/pkg/strategy/production.go index 590505068..3421e7f05 100644 --- a/pkg/strategy/production.go +++ b/pkg/strategy/production.go @@ -2,7 +2,7 @@ package strategy import ( "context" - "github.com/jaegertracing/jaeger-operator/pkg/cronjob" + "github.com/sirupsen/logrus" "github.com/spf13/viper" batchv1 "k8s.io/api/batch/v1" @@ -12,6 +12,7 @@ import ( "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" "github.com/jaegertracing/jaeger-operator/pkg/config/sampling" "github.com/jaegertracing/jaeger-operator/pkg/config/ui" + "github.com/jaegertracing/jaeger-operator/pkg/cronjob" "github.com/jaegertracing/jaeger-operator/pkg/deployment" "github.com/jaegertracing/jaeger-operator/pkg/ingress" "github.com/jaegertracing/jaeger-operator/pkg/inject" diff --git a/test/e2e/spark_dependencies_test.go b/test/e2e/spark_dependencies_test.go index a2619a163..f4f355cb2 100644 --- a/test/e2e/spark_dependencies_test.go +++ b/test/e2e/spark_dependencies_test.go @@ -3,11 +3,13 @@ package e2e import ( "context" "fmt" - "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" + "testing" + framework "github.com/operator-framework/operator-sdk/pkg/test" "github.com/operator-framework/operator-sdk/pkg/test/e2eutil" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "testing" + + "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" ) func SparkDependenciesElasticsearch(t *testing.T) {