Skip to content

Commit

Permalink
Allow to pass ES_TIME_RANGE var to Spark dependencies job (#1481)
Browse files Browse the repository at this point in the history
Signed-off-by: Nikita Grishko <[email protected]>
  • Loading branch information
Gr1N authored Jun 28, 2021
1 parent b9d1e02 commit bced782
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions deploy/crds/jaegertracing.io_jaegers_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7298,6 +7298,8 @@ spec:
type: boolean
elasticsearchNodesWanOnly:
type: boolean
elasticsearchTimeRange:
type: string
enabled:
type: boolean
image:
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/jaegertracing/v1/jaeger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,9 @@ type JaegerDependenciesSpec struct {
// +optional
ElasticsearchNodesWanOnly *bool `json:"elasticsearchNodesWanOnly,omitempty"`

// +optional
ElasticsearchTimeRange string `json:"elasticsearchTimeRange,omitempty"`

// +optional
TTLSecondsAfterFinished *int32 `json:"ttlSecondsAfterFinished,omitempty"`

Expand Down
6 changes: 6 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.

1 change: 1 addition & 0 deletions pkg/cronjob/spark_dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func getStorageEnvs(s v1.JaegerStorageSpec) []corev1.EnvVar {
{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_TIME_RANGE", Value: s.Dependencies.ElasticsearchTimeRange},
}
if s.Dependencies.ElasticsearchNodesWanOnly != nil {
vars = append(vars, corev1.EnvVar{Name: "ES_NODES_WAN_ONLY", Value: strconv.FormatBool(*s.Dependencies.ElasticsearchNodesWanOnly)})
Expand Down
13 changes: 13 additions & 0 deletions pkg/cronjob/spark_dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func TestStorageEnvs(t *testing.T) {
{Name: "ES_INDEX_PREFIX", Value: "haha"},
{Name: "ES_USERNAME", Value: "jdoe"},
{Name: "ES_PASSWORD", Value: "none"},
{Name: "ES_TIME_RANGE", Value: ""},
}},
{storage: v1.JaegerStorageSpec{Type: v1.JaegerESStorage,
Options: v1.NewOptions(map[string]interface{}{"es.server-urls": "lol:hol", "es.index-prefix": "haha",
Expand All @@ -62,9 +63,21 @@ func TestStorageEnvs(t *testing.T) {
{Name: "ES_INDEX_PREFIX", Value: "haha"},
{Name: "ES_USERNAME", Value: "jdoe"},
{Name: "ES_PASSWORD", Value: "none"},
{Name: "ES_TIME_RANGE", Value: ""},
{Name: "ES_NODES_WAN_ONLY", Value: "false"},
{Name: "ES_CLIENT_NODE_ONLY", Value: "true"},
}},
{storage: v1.JaegerStorageSpec{Type: v1.JaegerESStorage,
Options: v1.NewOptions(map[string]interface{}{"es.server-urls": "lol:hol", "es.index-prefix": "haha",
"es.username": "jdoe", "es.password": "none"}),
Dependencies: v1.JaegerDependenciesSpec{ElasticsearchTimeRange: "30m"}},
expected: []corev1.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_TIME_RANGE", Value: "30m"},
}},
}
for _, test := range tests {
envVars := getStorageEnvs(test.storage)
Expand Down

0 comments on commit bced782

Please sign in to comment.