Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
cleanup exclude dates
Signed-off-by: huiwq1990 <[email protected]>
  • Loading branch information
huiwq1990 committed May 22, 2023
commit e7d0a14f6e9bbde4d7dc3e210d0ae0748111ea56
17 changes: 4 additions & 13 deletions pkg/controller/cronhorizontalpodautoscaler_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets"
log "k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager"
Expand Down Expand Up @@ -232,20 +233,10 @@ func checkGlobalParamsChanges(status v1beta1.CronHorizontalPodAutoscalerStatus,
return true
}

excludeDatesMap := make(map[string]bool)
for _, date := range spec.ExcludeDates {
excludeDatesMap[date] = true
}
curExcludeDates := sets.NewString(spec.ExcludeDates...)
preExcludeDates := sets.NewString(status.ExcludeDates...)

for _, date := range status.ExcludeDates {
if excludeDatesMap[date] {
delete(excludeDatesMap, date)
} else {
return true
}
}
// excludeMap change
return len(excludeDatesMap) != 0
return !curExcludeDates.Equal(preExcludeDates)
}

func runOnce(job v1beta1.Job) bool {
Expand Down