Ability to retain specialised pods for poolmanager functions (#2830)
- added retainPods flag to take in the number of specialized pods to retain - add retainPods in both the create function and update function command - modify crd keys to be typed instead of string - keep track of function generation in case of update function operation - add delete handler function to make sure specialized pods are deleted in case function is deleted --------- Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> Signed-off-by: Pranoy Kundu <pranoy1998k@gmail.com> Co-authored-by: Pranoy Kundu <pranoy1998k@gmail.com>
This commit is contained in:
co-authored by
Pranoy Kundu
parent
657aee7cc2
commit
56b49dcee8
+3
-2
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
"github.com/robfig/cron/v3"
|
||||
"go.uber.org/zap"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
"github.com/fission/fission/pkg/publisher"
|
||||
@@ -36,7 +37,7 @@ const (
|
||||
type (
|
||||
Timer struct {
|
||||
logger *zap.Logger
|
||||
triggers map[string]*timerTriggerWithCron
|
||||
triggers map[types.UID]*timerTriggerWithCron
|
||||
publisher *publisher.Publisher
|
||||
}
|
||||
|
||||
@@ -49,7 +50,7 @@ type (
|
||||
func MakeTimer(logger *zap.Logger, publisher publisher.Publisher) *Timer {
|
||||
timer := &Timer{
|
||||
logger: logger.Named("timer"),
|
||||
triggers: make(map[string]*timerTriggerWithCron),
|
||||
triggers: make(map[types.UID]*timerTriggerWithCron),
|
||||
publisher: &publisher,
|
||||
}
|
||||
return timer
|
||||
|
||||
@@ -63,7 +63,7 @@ func (ws *TimerSync) AddUpdateTimeTrigger(timeTrigger *fv1.TimeTrigger) {
|
||||
|
||||
ws.logger.Debug("cron event")
|
||||
|
||||
if item, ok := ws.timer.triggers[crd.CacheKeyUID(&timeTrigger.ObjectMeta)]; ok {
|
||||
if item, ok := ws.timer.triggers[crd.CacheKeyUIDFromMeta(&timeTrigger.ObjectMeta)]; ok {
|
||||
if item.cron != nil {
|
||||
item.cron.Stop()
|
||||
}
|
||||
@@ -71,7 +71,7 @@ func (ws *TimerSync) AddUpdateTimeTrigger(timeTrigger *fv1.TimeTrigger) {
|
||||
item.cron = ws.timer.newCron(*timeTrigger)
|
||||
logger.Debug("cron updated")
|
||||
} else {
|
||||
ws.timer.triggers[crd.CacheKeyUID(&timeTrigger.ObjectMeta)] = &timerTriggerWithCron{
|
||||
ws.timer.triggers[crd.CacheKeyUIDFromMeta(&timeTrigger.ObjectMeta)] = &timerTriggerWithCron{
|
||||
trigger: *timeTrigger,
|
||||
cron: ws.timer.newCron(*timeTrigger),
|
||||
}
|
||||
@@ -82,12 +82,12 @@ func (ws *TimerSync) AddUpdateTimeTrigger(timeTrigger *fv1.TimeTrigger) {
|
||||
func (ws *TimerSync) DeleteTimeTrigger(timeTrigger *fv1.TimeTrigger) {
|
||||
logger := ws.logger.With(zap.String("trigger_name", timeTrigger.Name), zap.String("trigger_namespace", timeTrigger.Namespace))
|
||||
|
||||
if item, ok := ws.timer.triggers[crd.CacheKeyUID(&timeTrigger.ObjectMeta)]; ok {
|
||||
if item, ok := ws.timer.triggers[crd.CacheKeyUIDFromMeta(&timeTrigger.ObjectMeta)]; ok {
|
||||
if item.cron != nil {
|
||||
item.cron.Stop()
|
||||
logger.Info("cron for time trigger stopped")
|
||||
}
|
||||
delete(ws.timer.triggers, crd.CacheKeyUID(&timeTrigger.ObjectMeta))
|
||||
delete(ws.timer.triggers, crd.CacheKeyUIDFromMeta(&timeTrigger.ObjectMeta))
|
||||
logger.Debug("cron deleted")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user