Skip to content

Commit

Permalink
Add CQLSH_PORT environment variable (#1243)
Browse files Browse the repository at this point in the history
Signed-off-by: Ashmita Bohara <[email protected]>

Since jaegertracing/jaeger#2472 is merged, adding support for custom port here.

Partially Fixes: #1179
  • Loading branch information
Ashmita152 authored Oct 12, 2020
1 parent 729d8aa commit c69e666
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
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

0 comments on commit c69e666

Please sign in to comment.