Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keyExpiryInterval is configurable from config #75

Merged
merged 2 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions lib-persistence-manager/persistencemgr/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions lib-utilities/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib-utilities/config/odimra_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,6 @@
"RequestLimitPerSession":0,
"SessionLimitPerUser":0,
"LogLevel":"warn",
"ImageRegistryAddress":""
"ImageRegistryAddress":"",
"KeyExpiryInterval":86400
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
}
1 change: 1 addition & 0 deletions odim-controller/helmcharts/odimra-config/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ odimra:
haDeploymentEnabled:
logLevel:
logFormat:
keyExpiryInterval:
3 changes: 2 additions & 1 deletion odim-controller/scripts/kube_deploy_nodes.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,5 @@ odimra:
odimraEtcdServerKey:
logLevel: warn
logFormat: syslog
imageRegistryAddress: ""
imageRegistryAddress: ""
keyExpiryInterval: 86400
4 changes: 3 additions & 1 deletion odim-controller/scripts/odim-controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion svc-task/tmodel/tmodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down