-
Notifications
You must be signed in to change notification settings - Fork 344
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
Prevent operator from overriding .Spec.Replicas #979
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,15 +27,15 @@ func TestNegativeReplicas(t *testing.T) { | |
|
||
collector := NewCollector(jaeger) | ||
dep := collector.Get() | ||
assert.Equal(t, int32(1), *dep.Spec.Replicas) | ||
assert.Equal(t, size, *dep.Spec.Replicas) | ||
} | ||
|
||
func TestDefaultSize(t *testing.T) { | ||
jaeger := v1.NewJaeger(types.NamespacedName{Name: "my-instance"}) | ||
|
||
collector := NewCollector(jaeger) | ||
dep := collector.Get() | ||
assert.Equal(t, int32(1), *dep.Spec.Replicas) | ||
assert.Nil(t, dep.Spec.Replicas) // we let Kubernetes define the default | ||
} | ||
|
||
func TestReplicaSize(t *testing.T) { | ||
|
@@ -488,6 +488,21 @@ func TestAutoscalersDisabledByExplicitOption(t *testing.T) { | |
assert.Len(t, a, 0) | ||
} | ||
|
||
func TestAutoscalersSetMaxReplicas(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what is going on. Could you please explain this test and is the name of the test correct? Does the autoscaler set the number of replicas? The replicas are set directly in the CR and then autoscaler has the same value. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is covering a hole in coverage that I found when working on this PR. Basically, when Replicas set directly in the deployment CR are seen as "initial replicas", which are then overridden by the autoscaler as needed. So, it's possible to have the autoscaler set for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this func test all replica fields It would help me to understand the behavior if we had all combinations in the single test via:
replicas int, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I should have mentioned that the behavior I described is the |
||
// prepare | ||
maxReplicas := int32(2) | ||
jaeger := v1.NewJaeger(types.NamespacedName{Name: "my-instance"}) | ||
jaeger.Spec.Collector.MaxReplicas = &maxReplicas | ||
c := NewCollector(jaeger) | ||
|
||
// test | ||
a := c.Autoscalers() | ||
|
||
// verify | ||
assert.Len(t, a, 1) | ||
assert.Equal(t, maxReplicas, a[0].Spec.MaxReplicas) | ||
} | ||
|
||
func TestCollectoArgumentsOpenshiftTLS(t *testing.T) { | ||
viper.Set("platform", v1.FlagPlatformOpenShift) | ||
defer viper.Reset() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we no longer have to check on nill. We might remove the pointer and use plain int.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand your comment. The Deployment's
Spec.Replica
has the same type as our.Spec.Collector.Replicas
, and nil means "not set".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c.jaeger.Spec.Collector.Replicas
is a pointer. The question is whether we can change it to plainint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deployment's
.Spec.Replicas
is also a pointer. If we change our side to plainint
, it suddenly has a value, like0
, which is not the same asnil
. Once we get this ambiguity, our fix in theinventory
package won't work anymore.jaeger-operator/pkg/inventory/deployment.go
Lines 30 to 35 in 009b087