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 CQLSH_PORT environment variable #1243

Merged
merged 1 commit into from
Oct 12, 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
9 changes: 9 additions & 0 deletions pkg/storage/cassandra_dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ func cassandraDeps(jaeger *v1.Jaeger) []batchv1.Job {
host = "cassandra" // this is the default in the image
}

port := jaeger.Spec.Storage.Options.Map()["cassandra.port"]
if port == "" {
jaeger.Logger().Info("Cassandra port not specified. Using '9042' for the cassandra-create-schema job.")
port = "9042" // this is the default in the image
}

keyspace := jaeger.Spec.Storage.Options.Map()["cassandra.keyspace"]
if keyspace == "" {
jaeger.Logger().Info("Cassandra keyspace not specified. Using 'jaeger_v1_test' for the cassandra-create-schema job.")
Expand Down Expand Up @@ -141,6 +147,9 @@ func cassandraDeps(jaeger *v1.Jaeger) []batchv1.Job {
Env: []corev1.EnvVar{{
Name: "CQLSH_HOST",
Value: host,
}, {
Name: "CQLSH_PORT",
Value: port,
}, {
Name: "MODE",
Value: jaeger.Spec.Storage.CassandraCreateSchema.Mode,
Expand Down
15 changes: 15 additions & 0 deletions pkg/storage/cassandra_dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ func TestCassandraCustomTraceTTLParseError(t *testing.T) {
assert.Equal(t, "172800", foundValue, "unexpected TRACE_TTL environment var value")
}

func TestCassandraDefaultPort(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "my-instance"})

b := cassandraDeps(jaeger)
assert.Len(t, b, 1)
assert.Len(t, b[0].Spec.Template.Spec.Containers, 1)
for _, e := range b[0].Spec.Template.Spec.Containers[0].Env {
if e.Name == "CQLSH_PORT" {
assert.Equal(t, "9042", e.Value, "unexpected CQLSH_PORT environment var value")
return
}
}
assert.Fail(t, "value for CQLSH_PORT environment var not found")
}

func TestDefaultImage(t *testing.T) {
viper.Set("jaeger-cassandra-schema-image", "jaegertracing/theimage")
defer viper.Reset()
Expand Down