forked from kedacore/keda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v2] Implement the scaledjob controler for v2 (kedacore#945)
* [v2] Implement the scaledjob controler for v2 Signed-off-by: Tsuyoshi Ushio <[email protected]> * Scale Logic of the Azure Storage Queue for not scaling with invisible queue Signed-off-by: Tsuyoshi Ushio <[email protected]> * Update pkg/controller/scaledjob/scaledjob_controller.go Co-authored-by: Zbynek Roubalik <[email protected]> Signed-off-by: Tsuyoshi Ushio <[email protected]> * rollback the change for rabbit mq and fix the protocol on crd Signed-off-by: Tsuyoshi Ushio <[email protected]> * Add protocol for the scalejobs_crd Signed-off-by: Tsuyoshi Ushio <[email protected]> Co-authored-by: Zbynek Roubalik <[email protected]>
- Loading branch information
1 parent
dcaa94c
commit 73d676d
Showing
6 changed files
with
228 additions
and
67 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
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,51 @@ | ||
package scaledjob | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/go-logr/logr" | ||
kedav1alpha1 "github.com/kedacore/keda/pkg/apis/keda/v1alpha1" | ||
) | ||
|
||
const ( | ||
scaledJobFinalizer = "finalizer.keda.sh" | ||
) | ||
|
||
// finalizescaledJob is stopping ScaleLoop for the respective ScaleJob | ||
func (r *ReconcileScaledJob) finalizeScaledJob(logger logr.Logger, scaledJob *kedav1alpha1.ScaledJob) error { | ||
// TODO implement finalize logic for ScaledJob | ||
logger.Info("Successfully finalized ScaledJob") | ||
return nil | ||
} | ||
|
||
// addFinalizer adds finalizer to the scaledJob | ||
func (r *ReconcileScaledJob) addFinalizer(logger logr.Logger, scaledJob *kedav1alpha1.ScaledJob) error { | ||
logger.Info("Adding Finalizer for the ScaledJob") | ||
scaledJob.SetFinalizers(append(scaledJob.GetFinalizers(), scaledJobFinalizer)) | ||
|
||
// Update CR | ||
err := r.client.Update(context.TODO(), scaledJob) | ||
if err != nil { | ||
logger.Error(err, "Failed to update ScaledJob with finalizer") | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func contains(list []string, s string) bool { | ||
for _, v := range list { | ||
if v == s { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
func remove(list []string, s string) []string { | ||
for i, v := range list { | ||
if v == s { | ||
list = append(list[:i], list[i+1:]...) | ||
} | ||
} | ||
return list | ||
} |
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
Oops, something went wrong.