-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ScalersCache to reuse scales unless they need changing
Closes #1121
- Loading branch information
1 parent
7e08fc6
commit 88c10a3
Showing
21 changed files
with
763 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
Copyright 2021 The KEDA Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package keda | ||
|
||
import ( | ||
"context" | ||
kedav1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1" | ||
"github.com/kedacore/keda/v2/pkg/scaling" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/builder" | ||
"sigs.k8s.io/controller-runtime/pkg/controller" | ||
"sigs.k8s.io/controller-runtime/pkg/predicate" | ||
) | ||
|
||
type MetricsScaledObjectReconciler struct { | ||
ScaleHandler scaling.ScaleHandler | ||
} | ||
|
||
func (r *MetricsScaledObjectReconciler) Reconcile(_ context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
r.ScaleHandler.ClearScalersCache(req.Name, req.Namespace, "ScaledObject") | ||
return ctrl.Result{}, nil | ||
} | ||
|
||
func (r *MetricsScaledObjectReconciler) SetupWithManager(mgr ctrl.Manager, options controller.Options) error { | ||
return ctrl.NewControllerManagedBy(mgr). | ||
For(&kedav1alpha1.ScaledObject{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). | ||
Owns(&kedav1alpha1.ScaledObject{}). | ||
WithOptions(options). | ||
Complete(r) | ||
} | ||
|
||
type MetricsScaledJobReconciler struct { | ||
ScaleHandler scaling.ScaleHandler | ||
} | ||
|
||
func (r *MetricsScaledJobReconciler) Reconcile(_ context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
r.ScaleHandler.ClearScalersCache(req.Name, req.Namespace, "ScaledJob") | ||
return ctrl.Result{}, nil | ||
} | ||
|
||
func (r *MetricsScaledJobReconciler) SetupWithManager(mgr ctrl.Manager, options controller.Options) error { | ||
return ctrl.NewControllerManagedBy(mgr). | ||
For(&kedav1alpha1.ScaledJob{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). | ||
Owns(&kedav1alpha1.ScaledJob{}). | ||
WithOptions(options). | ||
Complete(r) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.