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

[release-1.14] For satefulset kafka dispatchers we ignore the replica #1890

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
2 changes: 1 addition & 1 deletion pkg/reconciler/common/ha.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func HighAvailabilityTransform(obj base.KComponent) mf.Transformer {
replicas := int64(*ha.Replicas)

// Transform deployments that support HA.
if u.GetKind() == "Deployment" && !haUnSupported(u.GetName()) && !hasHorizontalPodAutoscaler(u.GetName()) {
if u.GetKind() == "Deployment" && !haUnSupported(u.GetName()) && !hasHorizontalPodOrCustomAutoscaler(u.GetName()) {
if err := unstructured.SetNestedField(u.Object, replicas, "spec", "replicas"); err != nil {
return err
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/reconciler/common/hpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
)

// When a Podspecable has HPA, the replicas should be controlled by HPAs minReplicas instead of operator.
// When a Podspecable has HPA or a custom autoscaling, the replicas should be controlled by it instead of operator.
// Hence, skip changing the spec.replicas for these Podspecables.
func hasHorizontalPodAutoscaler(name string) bool {
func hasHorizontalPodOrCustomAutoscaler(name string) bool {
return sets.NewString(
"webhook",
"activator",
"3scale-kourier-gateway",
"eventing-webhook",
"mt-broker-ingress",
"mt-broker-filter",
"kafka-broker-dispatcher",
"kafka-source-dispatcher",
"kafka-channel-dispatcher",
).Has(name)
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/reconciler/common/hpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ func TestHpaTransform(t *testing.T) {
replicas: 5,
expected: makeUnstructuredDeployment(t, "not-a-hpa"),
err: nil,
}, {
name: "Kafka Dispatcher is custom autoscaler",
in: makeUnstructuredDeployment(t, "kafka-source-dispatcher"),
replicas: 5,
expected: makeUnstructuredDeploymentReplicas(t, "kafka-source-dispatcher", 1),
err: nil,
}, {
name: "minReplicas same as override",
in: makeUnstructuredHPA(t, "hpa", 1, 2),
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/common/workload_override.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func OverridesTransform(overrides []base.WorkloadOverride, log *zap.SugaredLogge
ps = &deployment.Spec.Template

// Do not set replicas, if this resource is controlled by a HPA
if override.Replicas != nil && !hasHorizontalPodAutoscaler(override.Name) {
if override.Replicas != nil && !hasHorizontalPodOrCustomAutoscaler(override.Name) {
deployment.Spec.Replicas = override.Replicas
}
}
Expand All @@ -62,7 +62,7 @@ func OverridesTransform(overrides []base.WorkloadOverride, log *zap.SugaredLogge
ps = &ss.Spec.Template

// Do not set replicas, if this resource is controlled by a HPA
if override.Replicas != nil && !hasHorizontalPodAutoscaler(override.Name) {
if override.Replicas != nil && !hasHorizontalPodOrCustomAutoscaler(override.Name) {
ss.Spec.Replicas = override.Replicas
}
}
Expand Down
Loading