Skip to content

Commit

Permalink
Limit some properties to use at most 63 chars (#904)
Browse files Browse the repository at this point in the history
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
  • Loading branch information
jpkrohling authored Feb 19, 2020
1 parent 95781e7 commit fc99304
Show file tree
Hide file tree
Showing 34 changed files with 237 additions and 305 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ JAEGER_VERSION ?= "$(shell grep jaeger= versions.txt | awk -F= '{print $$2}')"
OPERATOR_VERSION ?= "$(shell git describe --tags)"
STORAGE_NAMESPACE ?= "${shell kubectl get sa default -o jsonpath='{.metadata.namespace}' || oc project -q}"
KAFKA_NAMESPACE ?= "kafka"
KAFKA_EXAMPLE ?= "https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/0.14.0/examples/kafka/kafka-persistent-single.yaml"
KAFKA_YAML ?= "https://github.com/strimzi/strimzi-kafka-operator/releases/download/0.14.0/strimzi-cluster-operator-0.14.0.yaml"
KAFKA_EXAMPLE ?= "https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/0.16.2/examples/kafka/kafka-persistent-single.yaml"
KAFKA_YAML ?= "https://github.com/strimzi/strimzi-kafka-operator/releases/download/0.16.2/strimzi-cluster-operator-0.16.2.yaml"
ES_OPERATOR_NAMESPACE ?= openshift-logging
ES_OPERATOR_BRANCH ?= release-4.3
PROMETHEUS_OPERATOR_TAG ?= v0.34.0
Expand Down Expand Up @@ -147,7 +147,7 @@ run: crd

.PHONY: run-debug
run-debug: run
run-debug: CLI_FLAGS = "--log-level=debug"
run-debug: CLI_FLAGS = --log-level=debug --tracing-enabled=true

.PHONY: set-max-map-count
set-max-map-count:
Expand Down
9 changes: 1 addition & 8 deletions pkg/account/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,7 @@ func getMain(jaeger *v1.Jaeger) *corev1.ServiceAccount {
ObjectMeta: metav1.ObjectMeta{
Name: JaegerServiceAccountFor(jaeger, ""),
Namespace: jaeger.Namespace,
Labels: map[string]string{
"app": "jaeger",
"app.kubernetes.io/name": JaegerServiceAccountFor(jaeger, ""),
"app.kubernetes.io/instance": jaeger.Name,
"app.kubernetes.io/component": "service-account",
"app.kubernetes.io/part-of": "jaeger",
"app.kubernetes.io/managed-by": "jaeger-operator",
},
Labels: util.Labels(JaegerServiceAccountFor(jaeger, ""), "service-account", *jaeger),
OwnerReferences: []metav1.OwnerReference{
{
APIVersion: jaeger.APIVersion,
Expand Down
9 changes: 1 addition & 8 deletions pkg/account/oauth_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,7 @@ func OAuthProxy(jaeger *v1.Jaeger) *corev1.ServiceAccount {
ObjectMeta: metav1.ObjectMeta{
Name: OAuthProxyAccountNameFor(jaeger),
Namespace: jaeger.Namespace,
Labels: map[string]string{
"app": "jaeger",
"app.kubernetes.io/name": OAuthProxyAccountNameFor(jaeger),
"app.kubernetes.io/instance": jaeger.Name,
"app.kubernetes.io/component": "service-account-oauth-proxy",
"app.kubernetes.io/part-of": "jaeger",
"app.kubernetes.io/managed-by": "jaeger-operator",
},
Labels: util.Labels(OAuthProxyAccountNameFor(jaeger), "service-account-oauth-proxy", *jaeger),
Annotations: map[string]string{
"serviceaccounts.openshift.io/oauth-redirectreference.primary": getOAuthRedirectReference(jaeger),
},
Expand Down
11 changes: 2 additions & 9 deletions pkg/clusterrolebinding/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,8 @@ func oauthProxyAuthDelegator(jaeger *v1.Jaeger) rbac.ClusterRoleBinding {

return rbac.ClusterRoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: map[string]string{
"app": "jaeger",
"app.kubernetes.io/name": name,
"app.kubernetes.io/instance": jaeger.Name,
"app.kubernetes.io/component": "service-account",
"app.kubernetes.io/part-of": "jaeger",
"app.kubernetes.io/managed-by": "jaeger-operator",
},
Name: name,
Labels: util.Labels(name, "service-account", *jaeger),
OwnerReferences: []metav1.OwnerReference{
{
APIVersion: jaeger.APIVersion,
Expand Down
11 changes: 2 additions & 9 deletions pkg/config/sampling/sampling.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,7 @@ func (u *Config) Get() *corev1.ConfigMap {
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-sampling-configuration", u.jaeger.Name),
Namespace: u.jaeger.Namespace,
Labels: map[string]string{
"app": "jaeger",
"app.kubernetes.io/name": fmt.Sprintf("%s-sampling-configuration", u.jaeger.Name),
"app.kubernetes.io/instance": u.jaeger.Name,
"app.kubernetes.io/component": "sampling-configuration",
"app.kubernetes.io/part-of": "jaeger",
"app.kubernetes.io/managed-by": "jaeger-operator",
},
Labels: util.Labels(fmt.Sprintf("%s-sampling-configuration", u.jaeger.Name), "sampling-configuration", *u.jaeger),
OwnerReferences: []metav1.OwnerReference{
metav1.OwnerReference{
APIVersion: u.jaeger.APIVersion,
Expand Down Expand Up @@ -136,5 +129,5 @@ func Update(jaeger *v1.Jaeger, commonSpec *v1.JaegerCommonSpec, options *[]strin
}

func samplingConfigVolumeName(jaeger *v1.Jaeger) string {
return util.DNSName(fmt.Sprintf("%s-sampling-configuration-volume", jaeger.Name))
return util.DNSName(util.Truncate("%s-sampling-configuration-volume", 63, jaeger.Name))
}
11 changes: 2 additions & 9 deletions pkg/config/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,7 @@ func (u *UIConfig) Get() *corev1.ConfigMap {
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-ui-configuration", u.jaeger.Name),
Namespace: u.jaeger.Namespace,
Labels: map[string]string{
"app": "jaeger",
"app.kubernetes.io/name": fmt.Sprintf("%s-ui-configuration", u.jaeger.Name),
"app.kubernetes.io/instance": u.jaeger.Name,
"app.kubernetes.io/component": "ui-configuration",
"app.kubernetes.io/part-of": "jaeger",
"app.kubernetes.io/managed-by": "jaeger-operator",
},
Labels: util.Labels(fmt.Sprintf("%s-ui-configuration", u.jaeger.Name), "ui-configuration", *u.jaeger),
OwnerReferences: []metav1.OwnerReference{
metav1.OwnerReference{
APIVersion: u.jaeger.APIVersion,
Expand Down Expand Up @@ -103,5 +96,5 @@ func Update(jaeger *v1.Jaeger, commonSpec *v1.JaegerCommonSpec, options *[]strin
}

func configurationVolumeName(jaeger *v1.Jaeger) string {
return util.DNSName(fmt.Sprintf("%s-ui-configuration-volume", jaeger.Name))
return util.DNSName(util.Truncate("%s-ui-configuration-volume", 63, jaeger.Name))
}
6 changes: 2 additions & 4 deletions pkg/controller/jaeger/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ func (r *ReconcileJaeger) applyKafkas(ctx context.Context, jaeger v1.Jaeger, des
opts := []client.ListOption{
client.InNamespace(jaeger.Namespace),
client.MatchingLabels(map[string]string{
"app.kubernetes.io/instance": jaeger.Name,

// workaround for https://github.com/strimzi/strimzi-kafka-operator/issues/2107
"app.kubernetes.io/managed---by": "jaeger-operator",
"app.kubernetes.io/instance": jaeger.Name,
"app.kubernetes.io/managed-by": "jaeger-operator",
}),
}
list := &kafkav1beta1.KafkaList{}
Expand Down
36 changes: 12 additions & 24 deletions pkg/controller/jaeger/kafka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ func TestKafkaCreate(t *testing.T) {
Name: jaeger.Name,
Namespace: jaeger.Namespace,
Labels: map[string]string{
"app.kubernetes.io/instance": nsn.Name,

// workaround for https://github.com/strimzi/strimzi-kafka-operator/issues/2107
"app.kubernetes.io/managed---by": "jaeger-operator",
"app.kubernetes.io/instance": nsn.Name,
"app.kubernetes.io/managed-by": "jaeger-operator",
},
},
Status: kafkav1beta1.KafkaStatus{
Expand Down Expand Up @@ -91,10 +89,8 @@ func TestKafkaUpdate(t *testing.T) {
Namespace: nsn.Namespace,
Annotations: map[string]string{"key": "value"},
Labels: map[string]string{
"app.kubernetes.io/instance": nsn.Name,

// workaround for https://github.com/strimzi/strimzi-kafka-operator/issues/2107
"app.kubernetes.io/managed---by": "jaeger-operator",
"app.kubernetes.io/instance": nsn.Name,
"app.kubernetes.io/managed-by": "jaeger-operator",
},
},
Status: kafkav1beta1.KafkaStatus{
Expand All @@ -118,10 +114,8 @@ func TestKafkaUpdate(t *testing.T) {
Namespace: nsn.Namespace,
Annotations: map[string]string{"key": "new-value"},
Labels: map[string]string{
"app.kubernetes.io/instance": nsn.Name,

// workaround for https://github.com/strimzi/strimzi-kafka-operator/issues/2107
"app.kubernetes.io/managed---by": "jaeger-operator",
"app.kubernetes.io/instance": nsn.Name,
"app.kubernetes.io/managed-by": "jaeger-operator",
},
},
Status: kafkav1beta1.KafkaStatus{
Expand Down Expand Up @@ -168,10 +162,8 @@ func TestKafkaDelete(t *testing.T) {
Name: nsn.Name,
Namespace: nsn.Namespace,
Labels: map[string]string{
"app.kubernetes.io/instance": nsn.Name,

// workaround for https://github.com/strimzi/strimzi-kafka-operator/issues/2107
"app.kubernetes.io/managed---by": "jaeger-operator",
"app.kubernetes.io/instance": nsn.Name,
"app.kubernetes.io/managed-by": "jaeger-operator",
},
},
}
Expand Down Expand Up @@ -223,10 +215,8 @@ func TestKafkaCreateExistingNameInAnotherNamespace(t *testing.T) {
Name: nsnExisting.Name,
Namespace: nsnExisting.Namespace,
Labels: map[string]string{
"app.kubernetes.io/instance": nsnExisting.Name,

// workaround for https://github.com/strimzi/strimzi-kafka-operator/issues/2107
"app.kubernetes.io/managed---by": "jaeger-operator",
"app.kubernetes.io/instance": nsnExisting.Name,
"app.kubernetes.io/managed-by": "jaeger-operator",
},
},
Status: kafkav1beta1.KafkaStatus{
Expand All @@ -249,10 +239,8 @@ func TestKafkaCreateExistingNameInAnotherNamespace(t *testing.T) {
Name: nsn.Name,
Namespace: nsn.Namespace,
Labels: map[string]string{
"app.kubernetes.io/instance": nsn.Name,

// workaround for https://github.com/strimzi/strimzi-kafka-operator/issues/2107
"app.kubernetes.io/managed---by": "jaeger-operator",
"app.kubernetes.io/instance": nsn.Name,
"app.kubernetes.io/managed-by": "jaeger-operator",
},
},
Status: kafkav1beta1.KafkaStatus{
Expand Down
6 changes: 2 additions & 4 deletions pkg/controller/jaeger/kafkauser.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ func (r *ReconcileJaeger) applyKafkaUsers(ctx context.Context, jaeger v1.Jaeger,
opts := []client.ListOption{
client.InNamespace(jaeger.Namespace),
client.MatchingLabels(map[string]string{
"app.kubernetes.io/instance": jaeger.Name,

// workaround for https://github.com/strimzi/strimzi-kafka-operator/issues/2107
"app.kubernetes.io/managed---by": "jaeger-operator",
"app.kubernetes.io/instance": jaeger.Name,
"app.kubernetes.io/managed-by": "jaeger-operator",
}),
}
list := &kafkav1beta1.KafkaUserList{}
Expand Down
36 changes: 12 additions & 24 deletions pkg/controller/jaeger/kafkauser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ func TestKafkaUserCreate(t *testing.T) {
Name: jaeger.Name,
Namespace: jaeger.Namespace,
Labels: map[string]string{
"app.kubernetes.io/instance": nsn.Name,

// workaround for https://github.com/strimzi/strimzi-kafka-operator/issues/2107
"app.kubernetes.io/managed---by": "jaeger-operator",
"app.kubernetes.io/instance": nsn.Name,
"app.kubernetes.io/managed-by": "jaeger-operator",
},
},
Status: kafkav1beta1.KafkaUserStatus{
Expand Down Expand Up @@ -91,10 +89,8 @@ func TestKafkaUserUpdate(t *testing.T) {
Namespace: nsn.Namespace,
Annotations: map[string]string{"key": "value"},
Labels: map[string]string{
"app.kubernetes.io/instance": nsn.Name,

// workaround for https://github.com/strimzi/strimzi-kafka-operator/issues/2107
"app.kubernetes.io/managed---by": "jaeger-operator",
"app.kubernetes.io/instance": nsn.Name,
"app.kubernetes.io/managed-by": "jaeger-operator",
},
},
Status: kafkav1beta1.KafkaUserStatus{
Expand All @@ -118,10 +114,8 @@ func TestKafkaUserUpdate(t *testing.T) {
Namespace: nsn.Namespace,
Annotations: map[string]string{"key": "new-value"},
Labels: map[string]string{
"app.kubernetes.io/instance": nsn.Name,

// workaround for https://github.com/strimzi/strimzi-kafka-operator/issues/2107
"app.kubernetes.io/managed---by": "jaeger-operator",
"app.kubernetes.io/instance": nsn.Name,
"app.kubernetes.io/managed-by": "jaeger-operator",
},
},
Status: kafkav1beta1.KafkaUserStatus{
Expand Down Expand Up @@ -167,10 +161,8 @@ func TestKafkaUserDelete(t *testing.T) {
Name: nsn.Name,
Namespace: nsn.Namespace,
Labels: map[string]string{
"app.kubernetes.io/instance": nsn.Name,

// workaround for https://github.com/strimzi/strimzi-kafka-operator/issues/2107
"app.kubernetes.io/managed---by": "jaeger-operator",
"app.kubernetes.io/instance": nsn.Name,
"app.kubernetes.io/managed-by": "jaeger-operator",
},
},
}
Expand Down Expand Up @@ -222,10 +214,8 @@ func TestKafkaUserCreateExistingNameInAnotherNamespace(t *testing.T) {
Name: nsnExisting.Name,
Namespace: nsnExisting.Namespace,
Labels: map[string]string{
"app.kubernetes.io/instance": nsnExisting.Name,

// workaround for https://github.com/strimzi/strimzi-kafka-operator/issues/2107
"app.kubernetes.io/managed---by": "jaeger-operator",
"app.kubernetes.io/instance": nsnExisting.Name,
"app.kubernetes.io/managed-by": "jaeger-operator",
},
},
Status: kafkav1beta1.KafkaUserStatus{
Expand All @@ -248,10 +238,8 @@ func TestKafkaUserCreateExistingNameInAnotherNamespace(t *testing.T) {
Name: nsn.Name,
Namespace: nsn.Namespace,
Labels: map[string]string{
"app.kubernetes.io/instance": nsn.Name,

// workaround for https://github.com/strimzi/strimzi-kafka-operator/issues/2107
"app.kubernetes.io/managed---by": "jaeger-operator",
"app.kubernetes.io/instance": nsn.Name,
"app.kubernetes.io/managed-by": "jaeger-operator",
},
},
Status: kafkav1beta1.KafkaUserStatus{
Expand Down
16 changes: 5 additions & 11 deletions pkg/cronjob/es_index_cleaner.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cronjob

import (
"fmt"
"strconv"
"strings"

Expand All @@ -22,7 +21,9 @@ func CreateEsIndexCleaner(jaeger *v1.Jaeger) *batchv1beta1.CronJob {
esUrls := util.GetEsHostname(jaeger.Spec.Storage.Options.Map())
trueVar := true
one := int32(1)
name := fmt.Sprintf("%s-es-index-cleaner", jaeger.Name)

// CronJob names are restricted to 52 chars
name := util.Truncate("%s-es-index-cleaner", 52, jaeger.Name)

envFromSource := util.CreateEnvsFromSecret(jaeger.Spec.Storage.SecretName)
envs := EsScriptEnvVars(jaeger.Spec.Storage.Options)
Expand All @@ -36,14 +37,7 @@ func CreateEsIndexCleaner(jaeger *v1.Jaeger) *batchv1beta1.CronJob {
"sidecar.istio.io/inject": "false",
"linkerd.io/inject": "disabled",
},
Labels: map[string]string{
"app": "jaeger",
"app.kubernetes.io/name": name,
"app.kubernetes.io/instance": jaeger.Name,
"app.kubernetes.io/component": "cronjob-es-index-cleaner",
"app.kubernetes.io/part-of": "jaeger",
"app.kubernetes.io/managed-by": "jaeger-operator",
},
Labels: util.Labels(name, "cronjob-es-index-cleaner", *jaeger),
}

commonSpec := util.Merge([]v1.JaegerCommonSpec{jaeger.Spec.Storage.EsIndexCleaner.JaegerCommonSpec, jaeger.Spec.JaegerCommonSpec, baseCommonSpec})
Expand Down Expand Up @@ -75,7 +69,7 @@ func CreateEsIndexCleaner(jaeger *v1.Jaeger) *batchv1beta1.CronJob {
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: name,
Name: util.Truncate(name, 63),
Image: jaeger.Spec.Storage.EsIndexCleaner.Image,
Args: []string{strconv.Itoa(*jaeger.Spec.Storage.EsIndexCleaner.NumberOfDays), esUrls},
Env: util.RemoveEmptyVars(envs),
Expand Down
7 changes: 4 additions & 3 deletions pkg/cronjob/es_rollover.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cronjob

import (
"fmt"
"math/big"
"strconv"
"time"
Expand Down Expand Up @@ -30,7 +29,8 @@ func CreateRollover(jaeger *v1.Jaeger) []batchv1beta1.CronJob {
}

func rollover(jaeger *v1.Jaeger) batchv1beta1.CronJob {
name := fmt.Sprintf("%s-es-rollover", jaeger.Name)
// CronJob names are restricted to 52 chars
name := util.Truncate("%s-es-rollover", 52, jaeger.Name)
envs := EsScriptEnvVars(jaeger.Spec.Storage.Options)
if jaeger.Spec.Storage.EsRollover.Conditions != "" {
envs = append(envs, corev1.EnvVar{Name: "CONDITIONS", Value: jaeger.Spec.Storage.EsRollover.Conditions})
Expand Down Expand Up @@ -98,7 +98,8 @@ func createTemplate(name, action string, jaeger *v1.Jaeger, envs []corev1.EnvVar
}

func lookback(jaeger *v1.Jaeger) batchv1beta1.CronJob {
name := fmt.Sprintf("%s-es-lookback", jaeger.Name)
// CronJob names are restricted to 52 chars
name := util.Truncate("%s-es-lookback", 52, jaeger.Name)
envs := EsScriptEnvVars(jaeger.Spec.Storage.Options)
if jaeger.Spec.Storage.EsRollover.ReadTTL != "" {
dur, err := time.ParseDuration(jaeger.Spec.Storage.EsRollover.ReadTTL)
Expand Down
Loading

0 comments on commit fc99304

Please sign in to comment.