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

Copy common spec to avoid touching persisted CR spec #1333

Merged
merged 1 commit into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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