Skip to content

Commit

Permalink
Apply the securityContext to the cassandraCreateSchema job (#1167)
Browse files Browse the repository at this point in the history
Signed-off-by: chgl <[email protected]>
  • Loading branch information
chgl authored Aug 25, 2020
1 parent 2ea13b2 commit b2fcc57
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/storage/cassandra_dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func cassandraDeps(jaeger *v1.Jaeger) []batchv1.Job {
},
Spec: corev1.PodSpec{
ActiveDeadlineSeconds: podTimeout,
SecurityContext: jaeger.Spec.SecurityContext,
Containers: []corev1.Container{{
Image: util.ImageName(jaeger.Spec.Storage.CassandraCreateSchema.Image, "jaeger-cassandra-schema-image"),
Name: truncatedName,
Expand Down
14 changes: 14 additions & 0 deletions pkg/storage/cassandra_dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"

v1 "github.com/jaegertracing/jaeger-operator/pkg/apis/jaegertracing/v1"
Expand Down Expand Up @@ -120,3 +121,16 @@ func TestCassandraCreateSchemaInvalidTimeout(t *testing.T) {
assert.Len(t, b, 1)
assert.Equal(t, int64(86400), *b[0].Spec.ActiveDeadlineSeconds)
}

func TestCassandraCreateSchemaSecurityContext(t *testing.T) {
var user, group int64 = 111, 222
expectedSecurityContext := &corev1.PodSecurityContext{RunAsUser: &user, RunAsGroup: &group}

jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestCassandraCreateSchemaSecurityContext"})
jaeger.Spec.JaegerCommonSpec.SecurityContext = expectedSecurityContext

b := cassandraDeps(jaeger)

assert.Len(t, b, 1)
assert.Equal(t, b[0].Spec.Template.Spec.SecurityContext, expectedSecurityContext)
}

0 comments on commit b2fcc57

Please sign in to comment.