Skip to content

Commit cc123ba

Browse files
committed
fix(unregister cron): key generation typo while previous refacto
1 parent 6909d2b commit cc123ba

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

pkg/config/strategy-config.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"k8s.io/klog/v2"
1212
)
1313

14-
func CreateStrategyConfig(configurable *Configurable) *StrategyConfig {
14+
func GetKey(configurable *Configurable) string {
1515
workloadName := configurable.GetName()
1616

1717
if strings.HasPrefix(workloadName, VpaPrefix) {
@@ -21,6 +21,14 @@ func CreateStrategyConfig(configurable *Configurable) *StrategyConfig {
2121
}
2222

2323
key := fmt.Sprintf("%s/%s", configurable.GetNamespace(), workloadName)
24+
25+
return key
26+
}
27+
28+
func CreateStrategyConfig(configurable *Configurable) *StrategyConfig {
29+
30+
key := GetKey(configurable)
31+
2432
cfg := &StrategyConfig{
2533
Key: key,
2634
LoadCfg: &LoadCfg{

pkg/watcher/watch-vpas.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package watcher
22

33
import (
44
"context"
5-
"fmt"
65
"math/rand"
76
"sync"
87
"time"
@@ -55,7 +54,10 @@ func WatchVPAs(ctx context.Context, kubeClients *client.KubeClients) {
5554
klog.Error("Could not cast to VPA object")
5655
return
5756
}
58-
key := fmt.Sprintf("%s/%s", vpa.Namespace, vpa.Name)
57+
58+
configurable := config.CreateConfigurable(vpa)
59+
key := config.GetKey(configurable)
60+
5961
if entryID, exists := cronJobs[key]; exists {
6062
CronScheduler.Remove(entryID)
6163
}

0 commit comments

Comments
 (0)