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

Breaking change - removed 'Size' property from components #850

Merged
merged 1 commit into from
Jan 16, 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
12 changes: 0 additions & 12 deletions deploy/crds/jaegertracing.io_jaegers_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5457,10 +5457,6 @@ spec:
type: object
serviceAccount:
type: string
size:
description: Size represents the number of replicas to create for
this service. DEPRECATED, use `Replicas` instead.
type: integer
tolerations:
items:
description: The pod this Toleration is attached to tolerates
Expand Down Expand Up @@ -7508,10 +7504,6 @@ spec:
type: object
serviceAccount:
type: string
size:
description: Size represents the number of replicas to create for
this service. DEPRECATED, use `Replicas` instead.
type: integer
tolerations:
items:
description: The pod this Toleration is attached to tolerates
Expand Down Expand Up @@ -11637,10 +11629,6 @@ spec:
type: object
serviceAccount:
type: string
size:
description: Size represents the number of replicas to create for
this service. DEPRECATED, use `Replicas` instead.
type: integer
tolerations:
items:
description: The pod this Toleration is attached to tolerates
Expand Down
12 changes: 0 additions & 12 deletions pkg/apis/jaegertracing/v1/jaeger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ type JaegerCommonSpec struct {
// JaegerQuerySpec defines the options to be used when deploying the query
// +k8s:openapi-gen=true
type JaegerQuerySpec struct {
// Size represents the number of replicas to create for this service. DEPRECATED, use `Replicas` instead.
// +optional
Size int `json:"size,omitempty"`

// Replicas represents the number of replicas to create for this service.
// +optional
Replicas *int32 `json:"replicas,omitempty"`
Expand Down Expand Up @@ -283,10 +279,6 @@ type JaegerAllInOneSpec struct {
// JaegerCollectorSpec defines the options to be used when deploying the collector
// +k8s:openapi-gen=true
type JaegerCollectorSpec struct {
// Size represents the number of replicas to create for this service. DEPRECATED, use `Replicas` instead.
// +optional
Size int `json:"size,omitempty"`

// Replicas represents the number of replicas to create for this service.
// +optional
Replicas *int32 `json:"replicas,omitempty"`
Expand All @@ -304,10 +296,6 @@ type JaegerCollectorSpec struct {
// JaegerIngesterSpec defines the options to be used when deploying the ingester
// +k8s:openapi-gen=true
type JaegerIngesterSpec struct {
// Size represents the number of replicas to create for this service. DEPRECATED, use `Replicas` instead.
// +optional
Size int `json:"size,omitempty"`

// Replicas represents the number of replicas to create for this service.
// +optional
Replicas *int32 `json:"replicas,omitempty"`
Expand Down
21 changes: 0 additions & 21 deletions pkg/apis/jaegertracing/v1/zz_generated.openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,6 @@ func schema_pkg_apis_jaegertracing_v1_JaegerCollectorSpec(ref common.ReferenceCa
Description: "JaegerCollectorSpec defines the options to be used when deploying the collector",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"size": {
SchemaProps: spec.SchemaProps{
Description: "Size represents the number of replicas to create for this service. DEPRECATED, use `Replicas` instead.",
Type: []string{"integer"},
Format: "int32",
},
},
"replicas": {
SchemaProps: spec.SchemaProps{
Description: "Replicas represents the number of replicas to create for this service.",
Expand Down Expand Up @@ -1031,13 +1024,6 @@ func schema_pkg_apis_jaegertracing_v1_JaegerIngesterSpec(ref common.ReferenceCal
Description: "JaegerIngesterSpec defines the options to be used when deploying the ingester",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"size": {
SchemaProps: spec.SchemaProps{
Description: "Size represents the number of replicas to create for this service. DEPRECATED, use `Replicas` instead.",
Type: []string{"integer"},
Format: "int32",
},
},
"replicas": {
SchemaProps: spec.SchemaProps{
Description: "Replicas represents the number of replicas to create for this service.",
Expand Down Expand Up @@ -1413,13 +1399,6 @@ func schema_pkg_apis_jaegertracing_v1_JaegerQuerySpec(ref common.ReferenceCallba
Description: "JaegerQuerySpec defines the options to be used when deploying the query",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"size": {
SchemaProps: spec.SchemaProps{
Description: "Size represents the number of replicas to create for this service. DEPRECATED, use `Replicas` instead.",
Type: []string{"integer"},
Format: "int32",
},
},
"replicas": {
SchemaProps: spec.SchemaProps{
Description: "Replicas represents the number of replicas to create for this service.",
Expand Down
18 changes: 7 additions & 11 deletions pkg/deployment/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ type Collector struct {

// NewCollector builds a new Collector struct based on the given spec
func NewCollector(jaeger *v1.Jaeger) *Collector {
if jaeger.Spec.Collector.Replicas == nil || *jaeger.Spec.Collector.Replicas < 0 {
replicaSize := int32(1)
if jaeger.Spec.Collector.Size > 0 {
jaeger.Logger().Warn("The 'size' property for the collector is deprecated. Use 'replicas' instead.")
replicaSize = int32(jaeger.Spec.Collector.Size)
}

jaeger.Spec.Collector.Replicas = &replicaSize
}

return &Collector{jaeger: jaeger}
}

Expand Down Expand Up @@ -87,6 +77,12 @@ func (c *Collector) Get() *appsv1.Deployment {
// see https://github.com/jaegertracing/jaeger-operator/issues/334
sort.Strings(options)

replicaSize := c.jaeger.Spec.Collector.Replicas
if replicaSize == nil || *replicaSize < 0 {
s := int32(1)
replicaSize = &s
}

return &appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Expand All @@ -108,7 +104,7 @@ func (c *Collector) Get() *appsv1.Deployment {
},
},
Spec: appsv1.DeploymentSpec{
Replicas: c.jaeger.Spec.Collector.Replicas,
Replicas: replicaSize,
Selector: &metav1.LabelSelector{
MatchLabels: labels,
},
Expand Down
29 changes: 0 additions & 29 deletions pkg/deployment/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ func init() {
viper.SetDefault("jaeger-collector-image", "jaegertracing/all-in-one")
}

func TestNegativeSize(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestNegativeSize"})
jaeger.Spec.Collector.Size = -1

collector := NewCollector(jaeger)
dep := collector.Get()
assert.Equal(t, int32(1), *dep.Spec.Replicas)
}

func TestNegativeReplicas(t *testing.T) {
size := int32(-1)
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestNegativeReplicas"})
Expand Down Expand Up @@ -56,26 +47,6 @@ func TestReplicaSize(t *testing.T) {
assert.Equal(t, int32(0), *dep.Spec.Replicas)
}

func TestSize(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestSize"})
jaeger.Spec.Collector.Size = 2

collector := NewCollector(jaeger)
dep := collector.Get()
assert.Equal(t, int32(2), *dep.Spec.Replicas)
}

func TestReplicaWinsOverSize(t *testing.T) {
size := int32(3)
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestReplicaWinsOverSize"})
jaeger.Spec.Collector.Size = 2
jaeger.Spec.Collector.Replicas = &size

collector := NewCollector(jaeger)
dep := collector.Get()
assert.Equal(t, int32(3), *dep.Spec.Replicas)
}

func TestName(t *testing.T) {
collector := NewCollector(v1.NewJaeger(types.NamespacedName{Name: "TestName"}))
dep := collector.Get()
Expand Down
18 changes: 7 additions & 11 deletions pkg/deployment/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ type Ingester struct {

// NewIngester builds a new Ingester struct based on the given spec
func NewIngester(jaeger *v1.Jaeger) *Ingester {
if jaeger.Spec.Ingester.Replicas == nil || *jaeger.Spec.Ingester.Replicas < 0 {
replicaSize := int32(1)
if jaeger.Spec.Ingester.Size > 0 {
jaeger.Logger().Warn("The 'size' property for the ingester is deprecated. Use 'replicas' instead.")
replicaSize = int32(jaeger.Spec.Ingester.Size)
}

jaeger.Spec.Ingester.Replicas = &replicaSize
}

return &Ingester{jaeger: jaeger}
}

Expand Down Expand Up @@ -81,6 +71,12 @@ func (i *Ingester) Get() *appsv1.Deployment {
// see https://github.com/jaegertracing/jaeger-operator/issues/334
sort.Strings(options)

replicaSize := i.jaeger.Spec.Ingester.Replicas
if replicaSize == nil || *replicaSize < 0 {
s := int32(1)
replicaSize = &s
}

return &appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Expand All @@ -101,7 +97,7 @@ func (i *Ingester) Get() *appsv1.Deployment {
},
},
Spec: appsv1.DeploymentSpec{
Replicas: i.jaeger.Spec.Ingester.Replicas,
Replicas: replicaSize,
Selector: &metav1.LabelSelector{
MatchLabels: labels,
},
Expand Down
29 changes: 0 additions & 29 deletions pkg/deployment/ingester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ func TestIngesterNotDefined(t *testing.T) {
assert.Nil(t, ingester.Get())
}

func TestIngesterNegativeSize(t *testing.T) {
jaeger := newIngesterJaeger("TestIngesterNegativeSize")
jaeger.Spec.Ingester.Size = -1

ingester := NewIngester(jaeger)
dep := ingester.Get()
assert.Equal(t, int32(1), *dep.Spec.Replicas)
}

func TestIngesterNegativeReplicas(t *testing.T) {
size := int32(-1)
jaeger := newIngesterJaeger("TestIngesterNegativeReplicas")
Expand Down Expand Up @@ -63,26 +54,6 @@ func TestIngesterReplicaSize(t *testing.T) {
assert.Equal(t, int32(0), *dep.Spec.Replicas)
}

func TestIngesterSize(t *testing.T) {
jaeger := newIngesterJaeger("TestIngesterSize")
jaeger.Spec.Ingester.Size = 2

ingester := NewIngester(jaeger)
dep := ingester.Get()
assert.Equal(t, int32(2), *dep.Spec.Replicas)
}

func TestIngesterReplicaWinsOverSize(t *testing.T) {
size := int32(3)
jaeger := newIngesterJaeger("TestIngesterReplicaWinsOverSize")
jaeger.Spec.Ingester.Size = 2
jaeger.Spec.Ingester.Replicas = &size

ingester := NewIngester(jaeger)
dep := ingester.Get()
assert.Equal(t, int32(3), *dep.Spec.Replicas)
}

func TestIngesterName(t *testing.T) {
jaeger := newIngesterJaeger("TestIngesterName")
ingester := NewIngester(jaeger)
Expand Down
18 changes: 7 additions & 11 deletions pkg/deployment/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ type Query struct {

// NewQuery builds a new Query struct based on the given spec
func NewQuery(jaeger *v1.Jaeger) *Query {
if jaeger.Spec.Query.Replicas == nil || *jaeger.Spec.Query.Replicas < 0 {
replicaSize := int32(1)
if jaeger.Spec.Query.Size > 0 {
jaeger.Logger().Warn("The 'size' property for the query is deprecated. Use 'replicas' instead.")
replicaSize = int32(jaeger.Spec.Query.Size)
}

jaeger.Spec.Query.Replicas = &replicaSize
}

return &Query{jaeger: jaeger}
}

Expand Down Expand Up @@ -86,6 +76,12 @@ func (q *Query) Get() *appsv1.Deployment {
// see https://github.com/jaegertracing/jaeger-operator/issues/334
sort.Strings(options)

replicaSize := q.jaeger.Spec.Query.Replicas
if replicaSize == nil || *replicaSize < 0 {
s := int32(1)
replicaSize = &s
}

return &appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Expand All @@ -107,7 +103,7 @@ func (q *Query) Get() *appsv1.Deployment {
},
},
Spec: appsv1.DeploymentSpec{
Replicas: q.jaeger.Spec.Query.Replicas,
Replicas: replicaSize,
Selector: &metav1.LabelSelector{
MatchLabels: labels,
},
Expand Down
29 changes: 0 additions & 29 deletions pkg/deployment/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ func init() {
viper.SetDefault("jaeger-query-image", "jaegertracing/all-in-one")
}

func TestQueryNegativeSize(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestQueryNegativeSize"})
jaeger.Spec.Query.Size = -1

query := NewQuery(jaeger)
dep := query.Get()
assert.Equal(t, int32(1), *dep.Spec.Replicas)
}

func TestQueryNegativeReplicas(t *testing.T) {
size := int32(-1)
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestQueryNegativeReplicas"})
Expand Down Expand Up @@ -55,26 +46,6 @@ func TestQueryReplicaSize(t *testing.T) {
assert.Equal(t, int32(0), *dep.Spec.Replicas)
}

func TestQuerySize(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestQuerySize"})
jaeger.Spec.Query.Size = 2

query := NewQuery(jaeger)
dep := query.Get()
assert.Equal(t, int32(2), *dep.Spec.Replicas)
}

func TestQueryReplicaWinsOverSize(t *testing.T) {
size := int32(3)
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestQueryReplicaWinsOverSize"})
jaeger.Spec.Query.Size = 2
jaeger.Spec.Query.Replicas = &size

query := NewQuery(jaeger)
dep := query.Get()
assert.Equal(t, int32(3), *dep.Spec.Replicas)
}

func TestDefaultQueryImage(t *testing.T) {
viper.Set("jaeger-query-image", "org/custom-query-image")
defer viper.Reset()
Expand Down