-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix memory leak by checking triggers uniqueness properly #1640
Changes from 7 commits
c45f41d
69c0db3
f3ac4aa
fa243e2
009221d
6914f97
eb315d4
d2ec27a
aac7880
b819c5e
265b737
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 | ||||
---|---|---|---|---|---|---|
|
@@ -15,6 +15,7 @@ import ( | |||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" | ||||||
|
||||||
kedav1alpha1 "github.com/kedacore/keda/v2/api/v1alpha1" | ||||||
"github.com/kedacore/keda/v2/controllers/util" | ||||||
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. The same is imported on the line below 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 is awkward. Fixed! :D |
||||||
kedacontrollerutil "github.com/kedacore/keda/v2/controllers/util" | ||||||
) | ||||||
|
||||||
|
@@ -156,11 +157,17 @@ func (r *ScaledObjectReconciler) getScaledObjectMetricSpecs(logger logr.Logger, | |||||
if metricSpec.Resource != nil { | ||||||
resourceMetricNames = append(resourceMetricNames, string(metricSpec.Resource.Name)) | ||||||
} | ||||||
|
||||||
if metricSpec.External != nil { | ||||||
externalMetricName := metricSpec.External.Metric.Name | ||||||
if util.Contains(externalMetricNames, externalMetricName) { | ||||||
return nil, fmt.Errorf("metricName %s defined multiple times in ScaledObject %s, please refer the documentation how to define metircName manually", externalMetricName, scaledObject.Name) | ||||||
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.
Suggested change
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. Fixed! Thank you! |
||||||
} | ||||||
|
||||||
// add the scaledObjectName label. This is how the MetricsAdapter will know which scaledobject a metric is for when the HPA queries it. | ||||||
metricSpec.External.Metric.Selector = &metav1.LabelSelector{MatchLabels: make(map[string]string)} | ||||||
metricSpec.External.Metric.Selector.MatchLabels["scaledObjectName"] = scaledObject.Name | ||||||
externalMetricNames = append(externalMetricNames, metricSpec.External.Metric.Name) | ||||||
externalMetricNames = append(externalMetricNames, externalMetricName) | ||||||
} | ||||||
} | ||||||
scaledObjectMetricSpecs = append(scaledObjectMetricSpecs, metricSpecs...) | ||||||
|
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.
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.
Changed! Good suggestion