Skip to content

Commit

Permalink
Copy common spec to avoid touching persisted CR spec
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Vargas Palma <ruben.vp8510@gmail.com>
  • Loading branch information
rubenvp8510 committed Dec 9, 2020
1 parent 3160523 commit 8b76555
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/inject/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,18 @@ func container(jaeger *v1.Jaeger, dep *appsv1.Deployment, agentIdx int) corev1.C

// Use only the agent common spec for volumes and mounts.
// We don't want to mount all Jaeger internal volumes into user's deployments
volumesAndMountsSpec := &jaeger.Spec.Agent.JaegerCommonSpec
volumesAndMountsSpec := jaeger.Spec.Agent.JaegerCommonSpec
otelConf, err := jaeger.Spec.Agent.Config.GetMap()
if err != nil {
jaeger.Logger().WithField("error", err).
WithField("component", "agent").
Errorf("Could not parse OTEL config, config map will not be created")
} else {
otelconfig.Sync(jaeger, "agent", jaeger.Spec.Agent.Options, otelConf, volumesAndMountsSpec, &args)
otelconfig.Sync(jaeger, "agent", jaeger.Spec.Agent.Options, otelConf, &volumesAndMountsSpec, &args)
}

ca.Update(jaeger, volumesAndMountsSpec)
ca.AddServiceCA(jaeger, volumesAndMountsSpec)
ca.Update(jaeger, &volumesAndMountsSpec)
ca.AddServiceCA(jaeger, &volumesAndMountsSpec)

// ensure we have a consistent order of the arguments
// see https://github.com/jaegertracing/jaeger-operator/issues/334
Expand Down
7 changes: 7 additions & 0 deletions pkg/inject/sidecar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func TestInjectSidecarOpenShift(t *testing.T) {
defer reset()

jaeger := v1.NewJaeger(types.NamespacedName{Name: "my-instance"})
assert.Len(t, jaeger.Spec.Agent.VolumeMounts, 0)
assert.Len(t, jaeger.Spec.Agent.Volumes, 0)

dep := dep(map[string]string{}, map[string]string{})
dep = Sidecar(jaeger, dep)
assert.Equal(t, dep.Labels[Label], jaeger.Name)
Expand All @@ -57,6 +60,10 @@ func TestInjectSidecarOpenShift(t *testing.T) {
assert.Len(t, dep.Spec.Template.Spec.Containers[0].Env, 0)
assert.Len(t, dep.Spec.Template.Spec.Containers[1].VolumeMounts, 2)
assert.Len(t, dep.Spec.Template.Spec.Volumes, 2)

// CR should not be touched.
assert.Len(t, jaeger.Spec.Agent.VolumeMounts, 0)
assert.Len(t, jaeger.Spec.Agent.Volumes, 0)
}

func TestInjectSidecarWithEnvVars(t *testing.T) {
Expand Down

0 comments on commit 8b76555

Please sign in to comment.