diff --git a/lib-persistence-manager/persistencemgr/redis.go b/lib-persistence-manager/persistencemgr/redis.go index d62868ccb..65f342b20 100644 --- a/lib-persistence-manager/persistencemgr/redis.go +++ b/lib-persistence-manager/persistencemgr/redis.go @@ -781,12 +781,13 @@ func (c *Conn) UpdateTransaction(data map[string]interface{}) *errors.Error { // SetExpiryTimeForKeys will create the expiry time using pipelined transaction /* SetExpiryTimeForKeys takes the taskID as input: */ -func (c *Conn) SetExpiryTimeForKeys(taskKeys map[string]int64) *errors.Error { +func (c *Conn) SetExpiryTimeForKeys(taskKeys map[string]int64, keyExpiryInterval int) *errors.Error { var partialFailure bool = false c.WriteConn.Send("MULTI") members := getSortedMapKeys(taskKeys) for _, taskkey := range members { - createErr := c.WriteConn.Send("EXPIRE", taskkey, 86400) + + createErr := c.WriteConn.Send("EXPIRE", taskkey, keyExpiryInterval) if createErr != nil { c.WriteConn.Send("DISCARD") if isTimeOutError(createErr) { diff --git a/lib-utilities/config/config.go b/lib-utilities/config/config.go index 9461605fb..1f1882016 100644 --- a/lib-utilities/config/config.go +++ b/lib-utilities/config/config.go @@ -72,6 +72,7 @@ type configModel struct { LogLevel log.Level `json:"LogLevel"` LogFormat lgr.LogFormat `json:"LogFormat"` ImageRegistryAddress string `json:"ImageRegistryAddress,omitempty"` + KeyExpiryInterval int `json:"KeyExpiryInterval"` } // DBConf holds all DB related configurations diff --git a/lib-utilities/config/odimra_config.json b/lib-utilities/config/odimra_config.json index 4c4a64c87..cbe15711a 100644 --- a/lib-utilities/config/odimra_config.json +++ b/lib-utilities/config/odimra_config.json @@ -150,5 +150,6 @@ "RequestLimitPerSession":0, "SessionLimitPerUser":0, "LogLevel":"warn", - "ImageRegistryAddress":"" + "ImageRegistryAddress":"", + "KeyExpiryInterval":86400 } diff --git a/odim-controller/helmcharts/odimra-config/templates/configmaps.yaml b/odim-controller/helmcharts/odimra-config/templates/configmaps.yaml index d9412ae50..9cb0ba8b6 100755 --- a/odim-controller/helmcharts/odimra-config/templates/configmaps.yaml +++ b/odim-controller/helmcharts/odimra-config/templates/configmaps.yaml @@ -153,5 +153,6 @@ data: "LogFormat": {{ .Values.odimra.logFormat | quote }}, "ImageRegistryAddress": {{ .Values.odimra.imageRegistryAddress | quote }}, "RequestLimitCountPerSession": {{ .Values.odimra.requestLimitPerSession | default 0 }}, - "SessionLimitCountPerUser": {{ .Values.odimra.sessionLimitPerUser | default 0 }} + "SessionLimitCountPerUser": {{ .Values.odimra.sessionLimitPerUser | default 0 }}, + "KeyExpiryInterval": {{ .Values.odimra.keyExpiryInterval | default 86400 }} } diff --git a/odim-controller/helmcharts/odimra-config/values.yaml b/odim-controller/helmcharts/odimra-config/values.yaml index a7f5083e8..5fa10e42f 100644 --- a/odim-controller/helmcharts/odimra-config/values.yaml +++ b/odim-controller/helmcharts/odimra-config/values.yaml @@ -7,3 +7,4 @@ odimra: haDeploymentEnabled: logLevel: logFormat: + keyExpiryInterval: diff --git a/odim-controller/scripts/kube_deploy_nodes.yaml.tmpl b/odim-controller/scripts/kube_deploy_nodes.yaml.tmpl index 13e813e45..97f88eada 100644 --- a/odim-controller/scripts/kube_deploy_nodes.yaml.tmpl +++ b/odim-controller/scripts/kube_deploy_nodes.yaml.tmpl @@ -101,4 +101,5 @@ odimra: odimraEtcdServerKey: logLevel: warn logFormat: syslog - imageRegistryAddress: "" \ No newline at end of file + imageRegistryAddress: "" + keyExpiryInterval: 86400 \ No newline at end of file diff --git a/odim-controller/scripts/odim-controller.py b/odim-controller/scripts/odim-controller.py index 50f476512..3a16ccd65 100755 --- a/odim-controller/scripts/odim-controller.py +++ b/odim-controller/scripts/odim-controller.py @@ -196,7 +196,9 @@ def perform_checks(skip_opt_param_check=False): logger.critical("Log format value is invalid, allowed values are 'syslog', 'json'") exit(1) logger.info("Log format is %s ",CONTROLLER_CONF_DATA['odimra']['logFormat']) - + if 'keyExpiryInterval' not in CONTROLLER_CONF_DATA['odimra'] or CONTROLLER_CONF_DATA['odimra']['keyExpiryInterval'] == None or CONTROLLER_CONF_DATA['odimra']['keyExpiryInterval'] == 0: + logger.info("Key expiry is not set, Setting default value 86400") + CONTROLLER_CONF_DATA['odimra']['keyExpiryInterval']=86400 if not skip_opt_param_check: logger.debug("Checking if the local user matches with the configured nodes user") cur_user = os.getenv('USER') diff --git a/svc-task/tmodel/tmodel.go b/svc-task/tmodel/tmodel.go index 891907b43..ff88645cc 100644 --- a/svc-task/tmodel/tmodel.go +++ b/svc-task/tmodel/tmodel.go @@ -332,7 +332,7 @@ func (tick *Tick) ProcessTaskQueue(queue *chan *Task, conn *db.Conn) { if len(completedTasks) > 0 { i = 0 for i < MaxRetry { - if err := conn.SetExpiryTimeForKeys(completedTasks); err != nil { + if err := conn.SetExpiryTimeForKeys(completedTasks, config.Data.KeyExpiryInterval); err != nil { if err.ErrNo() == errors.TimeoutError || db.IsRetriable(err) { time.Sleep(retryInterval) conn = validateDBConnection(conn)