Skip to content

Commit

Permalink
Add badger to supported list of storage types (#616)
Browse files Browse the repository at this point in the history
Signed-off-by: Gary Brown <[email protected]>
  • Loading branch information
objectiser authored and jpkrohling committed Aug 27, 2019
1 parent 1985254 commit dcd7873
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 7 deletions.
25 changes: 25 additions & 0 deletions deploy/examples/with-badger-and-volume.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: jaegertracing.io/v1
kind: Jaeger
metadata:
name: with-badger-and-volume
spec:
allInOne:
volumeMounts:
- name: data
mountPath: /badger
volumes:
- name: data
emptyDir: {}
storage:
type: badger
options:
badger:
ephemeral: false
directory-key: "/badger/key"
directory-value: "/badger/data"
volumeMounts:
- name: data
mountPath: /badger
volumes:
- name: data
emptyDir: {}
7 changes: 7 additions & 0 deletions deploy/examples/with-badger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: jaegertracing.io/v1
kind: Jaeger
metadata:
name: with-badger
spec:
storage:
type: badger
2 changes: 1 addition & 1 deletion pkg/apis/jaegertracing/v1/jaeger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ type JaegerAgentSpec struct {
// JaegerStorageSpec defines the common storage options to be used for the query and collector
// +k8s:openapi-gen=true
type JaegerStorageSpec struct {
// Type can be `memory` (default), `cassandra`, `elasticsearch`, `kafka` or `managed`
// Type can be `memory` (default), `cassandra`, `elasticsearch`, `kafka` or `badger`
// +optional
Type string `json:"type,omitempty"`

Expand Down
1 change: 1 addition & 0 deletions pkg/storage/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func ValidTypes() []string {
"kafka",
"elasticsearch",
"cassandra",
"badger",
}
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/storage/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ func TestElasticsearchPrefix(t *testing.T) {
}

func TestValidTypes(t *testing.T) {
assert.Len(t, ValidTypes(), 4)
assert.Len(t, ValidTypes(), 5)
assert.Contains(t, ValidTypes(), "memory")
assert.Contains(t, ValidTypes(), "elasticsearch")
assert.Contains(t, ValidTypes(), "cassandra")
assert.Contains(t, ValidTypes(), "kafka")
assert.Contains(t, ValidTypes(), "badger")
}
6 changes: 5 additions & 1 deletion pkg/strategy/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func normalize(jaeger *v1.Jaeger) {

// check for incompatible options
// if the storage is `memory`, then the only possible strategy is `all-in-one`
if strings.EqualFold(jaeger.Spec.Storage.Type, "memory") && !strings.EqualFold(jaeger.Spec.Strategy, "allinone") {
if !distributedStorage(jaeger.Spec.Storage.Type) && !strings.EqualFold(jaeger.Spec.Strategy, "allinone") {
jaeger.Logger().WithField("storage", jaeger.Spec.Storage.Type).Warn("No suitable storage provided. Falling back to all-in-one")
jaeger.Spec.Strategy = "allInOne"
}
Expand All @@ -100,6 +100,10 @@ func normalize(jaeger *v1.Jaeger) {
normalizeUI(&jaeger.Spec)
}

func distributedStorage(storage string) bool {
return !strings.EqualFold(storage, "memory") && !strings.EqualFold(storage, "badger")
}

func normalizeSparkDependencies(spec *v1.JaegerStorageSpec) {
// auto enable only for supported storages
if cronjob.SupportedStorage(spec.Type) &&
Expand Down
15 changes: 14 additions & 1 deletion pkg/strategy/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestDefaultName(t *testing.T) {
assert.NotEmpty(t, jaeger.Name)
}

func TestIncompatibleStorageForProduction(t *testing.T) {
func TestIncompatibleMemoryStorageForProduction(t *testing.T) {
jaeger := &v1.Jaeger{
Spec: v1.JaegerSpec{
Strategy: "production",
Expand All @@ -85,6 +85,19 @@ func TestIncompatibleStorageForProduction(t *testing.T) {
assert.Equal(t, "allInOne", jaeger.Spec.Strategy)
}

func TestIncompatibleBadgerStorageForProduction(t *testing.T) {
jaeger := &v1.Jaeger{
Spec: v1.JaegerSpec{
Strategy: "production",
Storage: v1.JaegerStorageSpec{
Type: "badger",
},
},
}
normalize(jaeger)
assert.Equal(t, "allInOne", jaeger.Spec.Strategy)
}

func TestIncompatibleStorageForStreaming(t *testing.T) {
jaeger := &v1.Jaeger{
Spec: v1.JaegerSpec{
Expand Down
13 changes: 10 additions & 3 deletions test/e2e/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package e2e

import (
goctx "context"
"context"
"encoding/json"
"io/ioutil"
"net/http"
Expand All @@ -16,7 +16,6 @@ import (
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"golang.org/x/net/context"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -86,6 +85,14 @@ func (suite *ExamplesTestSuite) TestSimplestExample() {
smokeTestAllInOneExample("simplest", "../../deploy/examples/simplest.yaml")
}

func (suite *ExamplesTestSuite) TestWithBadgerExample() {
smokeTestAllInOneExample("with-badger", "../../deploy/examples/with-badger.yaml")
}

func (suite *ExamplesTestSuite) TestWithBadgerAndVolumeExample() {
smokeTestAllInOneExample("with-badger-and-volume", "../../deploy/examples/with-badger-and-volume.yaml")
}

func (suite *ExamplesTestSuite) TestSimpleProdDeployEsExample() {
if !isOpenShift(t) {
t.Skip("Only applies to openshift")
Expand Down Expand Up @@ -174,7 +181,7 @@ func (suite *ExamplesTestSuite) TestBusinessApp() {
// Add a liveliness probe to create some traces
vertxDeployment := &appsv1.Deployment{}
key := types.NamespacedName{Name: "myapp", Namespace: namespace}
err = fw.Client.Get(goctx.Background(), key, vertxDeployment)
err = fw.Client.Get(context.Background(), key, vertxDeployment)
require.NoError(t, err)

vertxPort := intstr.IntOrString{IntVal: 8080}
Expand Down

0 comments on commit dcd7873

Please sign in to comment.