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

add env var JAEGER_DISABLED #1285

Merged
merged 3 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions deploy/crds/jaegertracing.io_jaegers_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,8 @@ spec:
type: object
image:
type: string
jaegerDisabled:
type: boolean
labels:
additionalProperties:
type: string
Expand Down Expand Up @@ -5520,6 +5522,8 @@ spec:
type: object
image:
type: string
jaegerDisabled:
type: boolean
labels:
additionalProperties:
type: string
Expand Down
12 changes: 12 additions & 0 deletions pkg/apis/jaegertracing/v1/jaeger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ type JaegerQuerySpec struct {
// The default, if omitted, is ClusterIP.
// See https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
ServiceType v1.ServiceType `json:"serviceType,omitempty"`

// +optional
// JaegerDisabled adds the JAEGER_DISABLED environment flag to the
// query component to prevent it from adding its own traces.
// The default, if ommited, is false
JaegerDisabled *bool `json:"jaegerDisabled,omitempty"`
Copy link
Contributor

@objectiser objectiser Nov 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better calling it tracingEnabled - with a default of true?

}

// JaegerUISpec defines the options to be used to configure the UI
Expand Down Expand Up @@ -341,6 +347,12 @@ type JaegerAllInOneSpec struct {

// +optional
JaegerCommonSpec `json:",inline,omitempty"`

// +optional
// JaegerDisabled adds the JAEGER_DISABLED environment flag to the
// query component to prevent it from adding its own traces.
// The default, if ommited, is false
JaegerDisabled *bool `json:"jaegerDisabled,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

}

// AutoScaleSpec defines the common elements used for create HPAs
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/jaegertracing/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions pkg/apis/jaegertracing/v1/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions pkg/deployment/all_in_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ func (a *AllInOne) Get() *appsv1.Deployment {

adminPort := util.GetAdminPort(args, 14269)

jaegerDisabled := &falseVar
if a.jaeger.Spec.AllInOne.JaegerDisabled != nil {
jaegerDisabled = a.jaeger.Spec.AllInOne.JaegerDisabled
}

baseCommonSpec := v1.JaegerCommonSpec{
Annotations: map[string]string{
"prometheus.io/scrape": "true",
Expand Down Expand Up @@ -140,6 +145,10 @@ func (a *AllInOne) Get() *appsv1.Deployment {
Name: "COLLECTOR_ZIPKIN_HTTP_PORT",
Value: "9411",
},
{
Name: "JAEGER_DISABLED",
Value: strconv.FormatBool(*jaegerDisabled),
},
},
VolumeMounts: commonSpec.VolumeMounts,
EnvFrom: envFromSource,
Expand Down
22 changes: 22 additions & 0 deletions pkg/deployment/all_in_one_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func TestDefaultAllInOneImage(t *testing.T) {
Name: "COLLECTOR_ZIPKIN_HTTP_PORT",
Value: "9411",
},
{
Name: "JAEGER_DISABLED",
Value: "false",
},
}
assert.Equal(t, envvars, d.Spec.Template.Spec.Containers[0].Env)
}
Expand Down Expand Up @@ -352,3 +356,21 @@ func TestAllInOneServiceLinks(t *testing.T) {
falseVar := false
assert.Equal(t, &falseVar, dep.Spec.Template.Spec.EnableServiceLinks)
}

func TestAllInOneJaegerDisabled(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestAllInOneJaegerDisabled"})
trueVar := true
jaeger.Spec.AllInOne.JaegerDisabled = &trueVar
d := NewAllInOne(jaeger).Get()
assert.Equal(t, "true", getEnvVarByName(d.Spec.Template.Spec.Containers[0].Env, "JAEGER_DISABLED").Value)
}

func getEnvVarByName(vars []corev1.EnvVar, name string) corev1.EnvVar {
envVar := corev1.EnvVar{}
for _, v := range vars {
if v.Name == name {
envVar = v
}
}
return envVar
}
19 changes: 15 additions & 4 deletions pkg/deployment/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ func (q *Query) Get() *appsv1.Deployment {

adminPort := util.GetAdminPort(args, 16687)

jaegerDisabled := &falseVar
if q.jaeger.Spec.Query.JaegerDisabled != nil {
jaegerDisabled = q.jaeger.Spec.Query.JaegerDisabled
}

baseCommonSpec := v1.JaegerCommonSpec{
Annotations: map[string]string{
"prometheus.io/scrape": "true",
Expand Down Expand Up @@ -112,10 +117,16 @@ func (q *Query) Get() *appsv1.Deployment {
Image: util.ImageName(q.jaeger.Spec.Query.Image, "jaeger-query-image"),
Name: "jaeger-query",
Args: options,
Env: []corev1.EnvVar{{
Name: "SPAN_STORAGE_TYPE",
Value: string(q.jaeger.Spec.Storage.Type),
}},
Env: []corev1.EnvVar{
{
Name: "SPAN_STORAGE_TYPE",
Value: string(q.jaeger.Spec.Storage.Type),
},
{
Name: "JAEGER_DISABLED",
Value: strconv.FormatBool(*jaegerDisabled),
},
},
VolumeMounts: commonSpec.VolumeMounts,
EnvFrom: envFromSource,
Ports: []corev1.ContainerPort{
Expand Down
9 changes: 9 additions & 0 deletions pkg/deployment/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,12 @@ func TestQueryServiceLinks(t *testing.T) {
falseVar := false
assert.Equal(t, &falseVar, dep.Spec.Template.Spec.EnableServiceLinks)
}

func TestQueryJaegerDisabled(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestQueryJaegerDisabled"})
trueVar := true
jaeger.Spec.Query.JaegerDisabled = &trueVar
query := NewQuery(jaeger)
dep := query.Get()
assert.Equal(t, "true", getEnvVarByName(dep.Spec.Template.Spec.Containers[0].Env, "JAEGER_DISABLED").Value)
}