Skip to content

Commit

Permalink
hpa: Do not roll out HPA for unmanage componenets (PROJQUAY-5086)
Browse files Browse the repository at this point in the history
- Only roll out HPA component for managed components
  • Loading branch information
jonathankingfc authored and openshift-merge-bot[bot] committed Jan 29, 2024
1 parent f3169dc commit a8a0ab7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/kustomize/kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,19 @@ func Inflate(
resources[index] = obj
}

for index, resource := range resources {
resources[index] = v1.EnsureOwnerReference(quay, resource)
var filteredResources []client.Object
for _, resource := range resources {
if resource == nil {
continue
}
filteredResources = append(filteredResources, resource)
}

for index, resource := range filteredResources {
filteredResources[index] = v1.EnsureOwnerReference(quay, resource)
}

return resources, err
return filteredResources, err
}

func operatorServiceEndpoint() string {
Expand Down
15 changes: 15 additions & 0 deletions pkg/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
route "github.com/openshift/api/route/v1"
quaycontext "github.com/quay/quay-operator/pkg/context"
appsv1 "k8s.io/api/apps/v1"
autoscalingv1 "k8s.io/api/autoscaling/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
Expand Down Expand Up @@ -221,6 +222,20 @@ func Process(quay *v1.QuayRegistry, qctx *quaycontext.QuayRegistryContext, obj c
return pvc, nil
}

if _, ok := obj.(*autoscalingv1.HorizontalPodAutoscaler); ok {
componentMap := map[string]v1.ComponentKind{
"mirror": v1.ComponentMirror,
"clair": v1.ComponentClair,
}
// If the HPA is not for a managed component, return nil
if component, ok := componentMap[quayComponentLabel]; ok {
if !v1.ComponentIsManaged(quay.Spec.Components, component) {
return nil, nil
}
}
return obj, nil
}

if job, ok := obj.(*batchv1.Job); ok {
for _, oenv := range v1.GetEnvOverrideForComponent(quay, v1.ComponentQuay) {
for i := range job.Spec.Template.Spec.Containers {
Expand Down

0 comments on commit a8a0ab7

Please sign in to comment.