-
Notifications
You must be signed in to change notification settings - Fork 459
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
Change horizontal pod autoscaler to use otelcol scale subresource #941
Change horizontal pod autoscaler to use otelcol scale subresource #941
Conversation
Signed-off-by: Kevin Earls <kearls@redhat.com>
@@ -37,6 +37,10 @@ type OpenTelemetryCollectorSpec struct { | |||
// +optional | |||
Replicas *int32 `json:"replicas,omitempty"` | |||
|
|||
// MinReplicas sets a lower bound to the autoscaling feature | |||
// +optional | |||
MinReplicas int32 `json:"minReplicas,omitempty"` |
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.
What is the relationship between MinReplicas
and Replicas
? Which one should be used when? This is something that should be documented.
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.
With that we probably need to add some checks to the webhook
opentelemetry-operator/apis/v1alpha1/opentelemetrycollector_webhook.go
Lines 120 to 122 in b77c89d
if r.Spec.Replicas != nil && *r.Spec.Replicas > *r.Spec.MaxReplicas { | |
return fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, replicas must not be greater than maxReplicas") | |
} |
to test the minreplicas or any relationship between replicas, minreplias and maxreplicas.
@@ -35,18 +35,18 @@ func HorizontalPodAutoscaler(cfg config.Config, logger logr.Logger, otelcol v1al | |||
|
|||
return autoscalingv1.HorizontalPodAutoscaler{ | |||
ObjectMeta: metav1.ObjectMeta{ | |||
Name: naming.Collector(otelcol), | |||
Name: otelcol.Name, |
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.
What is the rationale for the name change? Could this produce an invalid name?
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.
We are now scaling on the OpenTelemetryCollector rather than the deployment. If the otelcol.Name is "simple" we append "-collector" to the deployment name.
If you think it's a good idea I could add a function to naming which just does
return DNSName(Truncate("%s", 63, otelcol.Name))
I would like to see e2e test for this functionality. It can be actually two tests - scaling up and down with the HPA. |
Signed-off-by: Kevin Earls <kearls@redhat.com>
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.
Please fix the lint.
…ntelemetry-operator into hpa-use-scale-subresource
Signed-off-by: Kevin Earls <kearls@redhat.com>
Signed-off-by: Kevin Earls <kearls@redhat.com>
Signed-off-by: Kevin Earls <kearls@redhat.com>
Signed-off-by: Kevin Earls <kearls@redhat.com>
Signed-off-by: Kevin Earls <kearls@redhat.com>
Signed-off-by: Kevin Earls <kearls@redhat.com>
Signed-off-by: Kevin Earls <kearls@redhat.com>
Signed-off-by: Kevin Earls <kearls@redhat.com>
Signed-off-by: Kevin Earls <kearls@redhat.com>
@pavolloffay Please review. I think I've covered all of the things we discussed. @yuriolisa lint now passes |
// +optional | ||
MaxReplicas *int32 `json:"maxReplicas,omitempty"` |
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.
I am not sure if we can change the CRD. In this case, a field is removed.
Signed-off-by: Kevin Earls <kearls@redhat.com>
Signed-off-by: Kevin Earls <kearls@redhat.com>
Signed-off-by: Kevin Earls <kearls@redhat.com>
Signed-off-by: Kevin Earls <kearls@redhat.com>
Signed-off-by: Kevin Earls <kearls@redhat.com>
@pavolloffay Can you please review this, re-running the checks first if needed? (The 1.24 e2e tests are failing in a place I didn't touch.) I have reverted to using autoscaling v1 and removed the AutoScaleSpec changes (I can do both later) so I think that covers everything we've discussed. |
hack/install-metrics-server.sh
Outdated
@@ -0,0 +1,6 @@ | |||
#!/bin/bash | |||
|
|||
# Install metrics-server for autoscale tests |
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.
Is this needed for mimikube as well or only for kind? It should be documented.
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.
No, with minikube you can just add --addons "metrics-server" to the start command.
Where should I document this? In this script? In the Makefile?
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.
Probably closer to the source - script
Signed-off-by: Kevin Earls <kearls@redhat.com>
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.
@kevinearls could you please confirm that the change of HPA implementation will not disrupt existing instances provisioned by the previous version of the operator?
Signed-off-by: Kevin Earls <kearls@redhat.com>
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.
@kevinearls, please ensure that change will not disrupt the existing instances like @pavolloffay mentioned above. LGTM.
Signed-off-by: Kevin Earls <kearls@redhat.com>
Signed-off-by: Kevin Earls <kearls@redhat.com>
Signed-off-by: Kevin Earls <kearls@redhat.com>
Signed-off-by: Kevin Earls <kearls@redhat.com>
@yuriolisa @pavolloffay I have added code that takes care of the upgrade. Please review and merge if it looks ok. |
@@ -52,6 +52,7 @@ func TestExpectedHPA(t *testing.T) { | |||
maxReplicas := int32(3) | |||
updateParms := paramsWithHPA() | |||
updateParms.Instance.Spec.Replicas = &minReplicas | |||
updateParms.Instance.Spec.Replicas = &minReplicas |
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.
Please fix this duplicated code.
} | ||
|
||
if r.Spec.MinReplicas != nil && *r.Spec.MinReplicas < int32(1) { | ||
return fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, minReplicas should be more than one") |
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.
I consider MinReplicas should be at least one, correct?
@@ -223,6 +223,10 @@ spec: | |||
If MaxReplicas is set autoscaling is enabled. | |||
format: int32 | |||
type: integer | |||
minReplicas: | |||
description: MinReplicas sets a lower bound to the autoscaling feature. |
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.
Could you please add here the lowest value?
@@ -221,6 +221,10 @@ spec: | |||
If MaxReplicas is set autoscaling is enabled. | |||
format: int32 | |||
type: integer | |||
minReplicas: | |||
description: MinReplicas sets a lower bound to the autoscaling feature. |
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.
Could you please add here the lowest value?
docs/api.md
Outdated
<td><b>minReplicas</b></td> | ||
<td>integer</td> | ||
<td> | ||
MinReplicas sets a lower bound to the autoscaling feature.<br/> |
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.
Also here.
tests/e2e/autoscale/00-install.yaml
Outdated
metadata: | ||
name: simplest | ||
spec: | ||
replicas: 1 |
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.
Should this field be automatically filled, once the minReplicas is the default lower bound of that instance?
Signed-off-by: Kevin Earls <kearls@redhat.com>
Signed-off-by: Kevin Earls <kearls@redhat.com>
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.
LGTM.
Closing this in favor of #984 as I managed to get myself into rebase hell. |
Signed-off-by: Kevin Earls kearls@redhat.com
This fixes #801 so that the HPA is created on an OpenTelemetryCollector rather than a Deployment.
I believe it also fixes #922
I believe it also fixes #906 but will confirm