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

[redhat-3.11] hpa: Do not set replicas to 2 when override set to null (PROJQUAY-6474) #952

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
5 changes: 5 additions & 0 deletions apis/quay/v1/quayregistry_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"

quaycontext "github.com/quay/quay-operator/pkg/context"
Expand Down Expand Up @@ -762,6 +763,10 @@ func GetReplicasOverrideForComponent(quay *QuayRegistry, kind ComponentKind) *in
}

if cmp.Overrides == nil {
return ptr.To[int32](2)
}

if cmp.Overrides.Replicas == nil {
return nil
}

Expand Down
6 changes: 2 additions & 4 deletions pkg/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/yaml"

Expand Down Expand Up @@ -122,12 +121,11 @@ func Process(quay *v1.QuayRegistry, qctx *quaycontext.QuayRegistryContext, obj c
// if no number of replicas has been set in kustomization files
// we set its value to two or to the value provided by the user
// as an override (if provided).
desired := ptr.To[int32](2)

if r := v1.GetReplicasOverrideForComponent(quay, kind); r != nil {
desired = r
dep.Spec.Replicas = r
}

dep.Spec.Replicas = desired
break
}
}
Expand Down
Loading