From ade909b19cc98533effa9ba459307537ba1256bd Mon Sep 17 00:00:00 2001 From: daniel-davidd Date: Tue, 18 Jul 2023 13:07:26 +0300 Subject: [PATCH 1/5] save changes --- server/background_tasks.go | 2 +- server/memphis_helper.go | 3 +++ server/opts.go | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/server/background_tasks.go b/server/background_tasks.go index d296b3f0b..7aacc566c 100644 --- a/server/background_tasks.go +++ b/server/background_tasks.go @@ -539,7 +539,7 @@ func (s *Server) RemoveOldDlsMsgs() { func (s *Server) RemoveOldProducersAndConsumers() { ticker := time.NewTicker(15 * time.Minute) for range ticker.C { - timeInterval := time.Now().Add(time.Duration(time.Hour * -2)) + timeInterval := time.Now().Add(time.Duration(time.Hour * -time.Duration(s.opts.GCProducersConsumersRetention))) deletedCGs, err := db.DeleteOldProducersAndConsumers(timeInterval) if err != nil { serv.Errorf("RemoveOldProducersAndConsumers at DeleteOldProducersAndConsumers : %v", err.Error()) diff --git a/server/memphis_helper.go b/server/memphis_helper.go index 160fd3c72..419e9deef 100644 --- a/server/memphis_helper.go +++ b/server/memphis_helper.go @@ -1227,6 +1227,9 @@ func GetMemphisOpts(opts *Options) (*Options, error) { case "max_msg_size_mb": v, _ := strconv.Atoi(conf.Value) opts.MaxPayload = int32(v * 1024 * 1024) + case "gc_producer_consumer_retention": + v, _ := strconv.Atoi(conf.Value) + opts.GCProducersConsumersRetention = v } } diff --git a/server/opts.go b/server/opts.go index 458f79940..0c0887b0e 100644 --- a/server/opts.go +++ b/server/opts.go @@ -292,6 +292,7 @@ type Options struct { LogsRetentionDays int `json:"-"` TieredStorageUploadIntervalSec int `json:"-"` DlsRetentionHours map[string]int `json:"-"` + GCProducersConsumersRetention int `json:"-"` UiHost string `json:"-"` RestGwHost string `json:"-"` BrokerHost string `json:"-"` From 2b82352e200ab2c289c0f1d74cc9de2f5aad4e4d Mon Sep 17 00:00:00 2001 From: daniel-davidd Date: Tue, 18 Jul 2023 16:31:07 +0300 Subject: [PATCH 2/5] save changes --- models/configurations.go | 15 ++++----- server/memphis_cloud.go | 38 ++++++++++++++--------- server/memphis_handlers_configurations.go | 8 +++++ server/opts.go | 11 +++++++ server/reload.go | 13 ++++++++ 5 files changed, 64 insertions(+), 21 deletions(-) diff --git a/models/configurations.go b/models/configurations.go index 5ba207d20..ed16da497 100644 --- a/models/configurations.go +++ b/models/configurations.go @@ -12,13 +12,14 @@ package models type EditClusterConfigSchema struct { - DlsRetention int `json:"dls_retention" binding:"required"` - LogsRetention int `json:"logs_retention" binding:"required"` - BrokerHost string `json:"broker_host"` - UiHost string `json:"ui_host"` - RestGWHost string `json:"rest_gw_host"` - TSTimeSec int `json:"tiered_storage_time_sec"` - MaxMsgSizeMb int `json:"max_msg_size_mb"` + DlsRetention int `json:"dls_retention" binding:"required"` + LogsRetention int `json:"logs_retention" binding:"required"` + BrokerHost string `json:"broker_host"` + UiHost string `json:"ui_host"` + RestGWHost string `json:"rest_gw_host"` + TSTimeSec int `json:"tiered_storage_time_sec"` + MaxMsgSizeMb int `json:"max_msg_size_mb"` + GCProducersConsumersRetention int `json:"gc_producer_consumer_retention"` } type GlobalConfigurationsUpdate struct { diff --git a/server/memphis_cloud.go b/server/memphis_cloud.go index d1cdd1369..4c0d73c6a 100644 --- a/server/memphis_cloud.go +++ b/server/memphis_cloud.go @@ -980,6 +980,14 @@ func (ch ConfigurationsHandler) EditClusterConfig(c *gin.Context) { return } } + if ch.S.opts.GCProducersConsumersRetention != body.GCProducersConsumersRetention { + err := changeGCProducersConsumersRetention(body.DlsRetention, user.TenantName) //change to gc + if err != nil { + serv.Errorf("[tenant: %v][user: %v]EditConfigurations at changeGCProducersConsumersRetention: %v", user.TenantName, user.Username, err.Error()) + c.AbortWithStatusJSON(500, gin.H{"message": "Server error"}) + return + } + } if ch.S.opts.LogsRetentionDays != body.LogsRetention { err := changeLogsRetention(body.LogsRetention) if err != nil { @@ -1057,13 +1065,14 @@ func (ch ConfigurationsHandler) EditClusterConfig(c *gin.Context) { } c.IndentedJSON(200, gin.H{ - "dls_retention": ch.S.opts.DlsRetentionHours[user.TenantName], - "logs_retention": ch.S.opts.LogsRetentionDays, - "broker_host": ch.S.opts.BrokerHost, - "ui_host": ch.S.opts.UiHost, - "rest_gw_host": ch.S.opts.RestGwHost, - "tiered_storage_time_sec": ch.S.opts.TieredStorageUploadIntervalSec, - "max_msg_size_mb": ch.S.opts.MaxPayload / 1024 / 1024, + "dls_retention": ch.S.opts.DlsRetentionHours[user.TenantName], + "logs_retention": ch.S.opts.LogsRetentionDays, + "broker_host": ch.S.opts.BrokerHost, + "ui_host": ch.S.opts.UiHost, + "rest_gw_host": ch.S.opts.RestGwHost, + "tiered_storage_time_sec": ch.S.opts.TieredStorageUploadIntervalSec, + "max_msg_size_mb": ch.S.opts.MaxPayload / 1024 / 1024, + "gc_producer_consumer_retention": body.GCProducersConsumersRetention, }) } @@ -1081,13 +1090,14 @@ func (ch ConfigurationsHandler) GetClusterConfig(c *gin.Context) { analytics.SendEvent(user.TenantName, user.Username, analyticsParams, "user-enter-cluster-config-page") } c.IndentedJSON(200, gin.H{ - "dls_retention": ch.S.opts.DlsRetentionHours[user.TenantName], - "logs_retention": ch.S.opts.LogsRetentionDays, - "broker_host": ch.S.opts.BrokerHost, - "ui_host": ch.S.opts.UiHost, - "rest_gw_host": ch.S.opts.RestGwHost, - "tiered_storage_time_sec": ch.S.opts.TieredStorageUploadIntervalSec, - "max_msg_size_mb": ch.S.opts.MaxPayload / 1024 / 1024, + "dls_retention": ch.S.opts.DlsRetentionHours[user.TenantName], + "logs_retention": ch.S.opts.LogsRetentionDays, + "broker_host": ch.S.opts.BrokerHost, + "ui_host": ch.S.opts.UiHost, + "rest_gw_host": ch.S.opts.RestGwHost, + "tiered_storage_time_sec": ch.S.opts.TieredStorageUploadIntervalSec, + "max_msg_size_mb": ch.S.opts.MaxPayload / 1024 / 1024, + "gc_producer_consumer_retention": ch.S.opts.GCProducersConsumersRetention, }) } diff --git a/server/memphis_handlers_configurations.go b/server/memphis_handlers_configurations.go index 9ac9efa9a..c5781795a 100644 --- a/server/memphis_handlers_configurations.go +++ b/server/memphis_handlers_configurations.go @@ -28,6 +28,14 @@ func changeDlsRetention(dlsRetention int, tenantName string) error { return nil } +func changeGCProducersConsumersRetention(retention int, tenantName string) error { + err := db.UpsertConfiguration("gc_producer_consumer_retention", strconv.Itoa(retention), tenantName) + if err != nil { + return err + } + return nil +} + func changeLogsRetention(logsRetention int) error { err := db.UpsertConfiguration("logs_retention", strconv.Itoa(logsRetention), serv.MemphisGlobalAccountString()) if err != nil { diff --git a/server/opts.go b/server/opts.go index 0c0887b0e..4d0682576 100644 --- a/server/opts.go +++ b/server/opts.go @@ -1444,6 +1444,14 @@ func (o *Options) processConfigFileLine(k string, v interface{}, errors *[]error } o.DlsRetentionHours = make(map[string]int) o.DlsRetentionHours[conf.MemphisGlobalAccountName] = value + case "gc_producer_consumer_retention": + value := int(v.(int64)) + if value < 1 || value > 48 { + *errors = append(*errors, &configErr{tk, "error gc_producer_consumer_retention config: has to be positive and not more than 48"}) + return + } + o.GCProducersConsumersRetention = value + case "ui_host": value := v.(string) if value == _EMPTY_ { @@ -4746,6 +4754,9 @@ func setBaselineOptions(opts *Options) { if opts.LogsRetentionDays == 0 { opts.LogsRetentionDays = 7 } + if opts.GCProducersConsumersRetention == 0 { + opts.GCProducersConsumersRetention = 2 + } if opts.TieredStorageUploadIntervalSec == 0 { opts.TieredStorageUploadIntervalSec = DEFAULT_TIERED_STORAGE_UPLOAD_INTERVAL_SEC } diff --git a/server/reload.go b/server/reload.go index de7ae9837..76cd38c8d 100644 --- a/server/reload.go +++ b/server/reload.go @@ -717,12 +717,22 @@ type dlsRetentionHoursOption struct { newValue map[string]int } +type GCProducersConsumersRetentionOption struct { + noopOption + newValue int +} + // Apply the setting by updating the server info and each client. func (o *dlsRetentionHoursOption) Apply(server *Server) { // no need to update anything since it happens on the edit cluster configuration endpoint server.Noticef("Reloaded: dls_retention_hours = %v", o.newValue) } +func (o *GCProducersConsumersRetentionOption) Apply(server *Server) { + // no need to update anything since it happens on the edit cluster configuration endpoint + server.Noticef("Reloaded: gc_producer_consumer_retention = %d", o.newValue) +} + // logsRetentionDaysOption implements the option interface for the `logs_retention_days` // setting. type logsRetentionDaysOption struct { @@ -1452,6 +1462,9 @@ func (s *Server) diffOptions(newOpts *Options) ([]option, error) { diffOpts = append(diffOpts, &brokerHostOption{newValue: newValue.(string)}) case "restgwhost": diffOpts = append(diffOpts, &restGwOption{newValue: newValue.(string)}) + case "gcproducerconsumerretention": + diffOpts = append(diffOpts, &GCProducersConsumersRetentionOption{newValue: newValue.(int)}) + default: // TODO(ik): Implement String() on those options to have a nice print. // %v is difficult to figure what's what, %+v print private fields and From 083745897586aec0639e067da2e04179cc5947e6 Mon Sep 17 00:00:00 2001 From: daniel-davidd Date: Tue, 18 Jul 2023 23:31:23 +0300 Subject: [PATCH 3/5] added to the ui edit conf and checked --- server/memphis_cloud.go | 2 +- server/reload.go | 2 +- .../administration/clusterConfiguration/index.js | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/server/memphis_cloud.go b/server/memphis_cloud.go index 4c0d73c6a..601e39852 100644 --- a/server/memphis_cloud.go +++ b/server/memphis_cloud.go @@ -981,7 +981,7 @@ func (ch ConfigurationsHandler) EditClusterConfig(c *gin.Context) { } } if ch.S.opts.GCProducersConsumersRetention != body.GCProducersConsumersRetention { - err := changeGCProducersConsumersRetention(body.DlsRetention, user.TenantName) //change to gc + err := changeGCProducersConsumersRetention(body.GCProducersConsumersRetention, user.TenantName) if err != nil { serv.Errorf("[tenant: %v][user: %v]EditConfigurations at changeGCProducersConsumersRetention: %v", user.TenantName, user.Username, err.Error()) c.AbortWithStatusJSON(500, gin.H{"message": "Server error"}) diff --git a/server/reload.go b/server/reload.go index 76cd38c8d..c5d3ea1f7 100644 --- a/server/reload.go +++ b/server/reload.go @@ -1462,7 +1462,7 @@ func (s *Server) diffOptions(newOpts *Options) ([]option, error) { diffOpts = append(diffOpts, &brokerHostOption{newValue: newValue.(string)}) case "restgwhost": diffOpts = append(diffOpts, &restGwOption{newValue: newValue.(string)}) - case "gcproducerconsumerretention": + case "gcproducersconsumersretention": diffOpts = append(diffOpts, &GCProducersConsumersRetentionOption{newValue: newValue.(int)}) default: diff --git a/ui_src/src/domain/administration/clusterConfiguration/index.js b/ui_src/src/domain/administration/clusterConfiguration/index.js index 4484831ce..2b135dd40 100644 --- a/ui_src/src/domain/administration/clusterConfiguration/index.js +++ b/ui_src/src/domain/administration/clusterConfiguration/index.js @@ -141,6 +141,16 @@ function ClusterConfiguration() { unit={'h'} onChanges={(e) => handleChange('dls_retention', e)} /> + handleChange('gc_producer_consumer_retention', e)} + /> Date: Sun, 23 Jul 2023 11:19:55 +0300 Subject: [PATCH 4/5] resolved comments --- conf/debug/memphis-0.conf | 1 + conf/debug/memphis-1.conf | 1 + conf/debug/memphis-2.conf | 1 + conf/debug/stand-alone.conf | 1 + models/configurations.go | 16 ++++---- server/background_tasks.go | 2 +- server/memphis_cloud.go | 38 +++++++++---------- server/memphis_handlers_configurations.go | 4 +- server/memphis_helper.go | 4 +- server/opts.go | 30 +++++++-------- server/reload.go | 11 +++--- .../clusterConfiguration/index.js | 6 +-- 12 files changed, 59 insertions(+), 56 deletions(-) diff --git a/conf/debug/memphis-0.conf b/conf/debug/memphis-0.conf index 9fc82d82a..e8aba7876 100644 --- a/conf/debug/memphis-0.conf +++ b/conf/debug/memphis-0.conf @@ -8,6 +8,7 @@ k8s_namespace: "memphis" logs_retention_days: 7 tiered_storage_upload_interval_seconds: 8 dls_retention_hours: 3 +gc_producer_consumer_retention_hours: 3 # ui_host: "" # rest_gw_host: "" # broker_host: "" diff --git a/conf/debug/memphis-1.conf b/conf/debug/memphis-1.conf index e7caf88eb..69d72e1d6 100644 --- a/conf/debug/memphis-1.conf +++ b/conf/debug/memphis-1.conf @@ -8,6 +8,7 @@ k8s_namespace: "memphis" logs_retention_days: 7 tiered_storage_upload_interval_seconds: 8 dls_retention_hours: 3 +gc_producer_consumer_retention_hours: 3 # ui_host: "" # rest_gw_host: "" # broker_host: "" diff --git a/conf/debug/memphis-2.conf b/conf/debug/memphis-2.conf index 17424501c..3980397e4 100644 --- a/conf/debug/memphis-2.conf +++ b/conf/debug/memphis-2.conf @@ -8,6 +8,7 @@ k8s_namespace: "memphis" logs_retention_days: 7 tiered_storage_upload_interval_seconds: 8 dls_retention_hours: 3 +gc_producer_consumer_retention_hours: 3 # ui_host: "" # rest_gw_host: "" # broker_host: "" diff --git a/conf/debug/stand-alone.conf b/conf/debug/stand-alone.conf index a6fb53803..a45143742 100644 --- a/conf/debug/stand-alone.conf +++ b/conf/debug/stand-alone.conf @@ -8,6 +8,7 @@ rest_gw_port: 4444 logs_retention_days: 7 tiered_storage_upload_interval_seconds: 8 dls_retention_hours: 3 +gc_producer_consumer_retention_hours: 3 # ui_host: "" # rest_gw_host: "" # broker_host: "" diff --git a/models/configurations.go b/models/configurations.go index ed16da497..a6ca6398a 100644 --- a/models/configurations.go +++ b/models/configurations.go @@ -12,14 +12,14 @@ package models type EditClusterConfigSchema struct { - DlsRetention int `json:"dls_retention" binding:"required"` - LogsRetention int `json:"logs_retention" binding:"required"` - BrokerHost string `json:"broker_host"` - UiHost string `json:"ui_host"` - RestGWHost string `json:"rest_gw_host"` - TSTimeSec int `json:"tiered_storage_time_sec"` - MaxMsgSizeMb int `json:"max_msg_size_mb"` - GCProducersConsumersRetention int `json:"gc_producer_consumer_retention"` + DlsRetention int `json:"dls_retention" binding:"required"` + LogsRetention int `json:"logs_retention" binding:"required"` + BrokerHost string `json:"broker_host"` + UiHost string `json:"ui_host"` + RestGWHost string `json:"rest_gw_host"` + TSTimeSec int `json:"tiered_storage_time_sec"` + MaxMsgSizeMb int `json:"max_msg_size_mb"` + GCProducersConsumersRetentionHours int `json:"gc_producer_consumer_retention_hours"` } type GlobalConfigurationsUpdate struct { diff --git a/server/background_tasks.go b/server/background_tasks.go index 7aacc566c..8f2442cb4 100644 --- a/server/background_tasks.go +++ b/server/background_tasks.go @@ -539,7 +539,7 @@ func (s *Server) RemoveOldDlsMsgs() { func (s *Server) RemoveOldProducersAndConsumers() { ticker := time.NewTicker(15 * time.Minute) for range ticker.C { - timeInterval := time.Now().Add(time.Duration(time.Hour * -time.Duration(s.opts.GCProducersConsumersRetention))) + timeInterval := time.Now().Add(time.Duration(time.Hour * -time.Duration(s.opts.GCProducersConsumersRetentionHours))) deletedCGs, err := db.DeleteOldProducersAndConsumers(timeInterval) if err != nil { serv.Errorf("RemoveOldProducersAndConsumers at DeleteOldProducersAndConsumers : %v", err.Error()) diff --git a/server/memphis_cloud.go b/server/memphis_cloud.go index a9e53a7b1..b925d520a 100644 --- a/server/memphis_cloud.go +++ b/server/memphis_cloud.go @@ -980,10 +980,10 @@ func (ch ConfigurationsHandler) EditClusterConfig(c *gin.Context) { return } } - if ch.S.opts.GCProducersConsumersRetention != body.GCProducersConsumersRetention { - err := changeGCProducersConsumersRetention(body.GCProducersConsumersRetention, user.TenantName) + if ch.S.opts.GCProducersConsumersRetentionHours != body.GCProducersConsumersRetentionHours { + err := changeGCProducersConsumersRetentionHours(body.GCProducersConsumersRetentionHours, user.TenantName) if err != nil { - serv.Errorf("[tenant: %v][user: %v]EditConfigurations at changeGCProducersConsumersRetention: %v", user.TenantName, user.Username, err.Error()) + serv.Errorf("[tenant: %v][user: %v]EditConfigurations at changeGCProducersConsumersRetentionHours: %v", user.TenantName, user.Username, err.Error()) c.AbortWithStatusJSON(500, gin.H{"message": "Server error"}) return } @@ -1065,14 +1065,14 @@ func (ch ConfigurationsHandler) EditClusterConfig(c *gin.Context) { } c.IndentedJSON(200, gin.H{ - "dls_retention": body.DlsRetention, - "logs_retention": body.LogsRetention, - "broker_host": brokerHost, - "ui_host": uiHost, - "rest_gw_host": restGWHost, - "tiered_storage_time_sec": body.TSTimeSec, - "max_msg_size_mb": int32(body.MaxMsgSizeMb), - "gc_producer_consumer_retention": body.GCProducersConsumersRetention, + "dls_retention": body.DlsRetention, + "logs_retention": body.LogsRetention, + "broker_host": brokerHost, + "ui_host": uiHost, + "rest_gw_host": restGWHost, + "tiered_storage_time_sec": body.TSTimeSec, + "max_msg_size_mb": int32(body.MaxMsgSizeMb), + "gc_producer_consumer_retention_hours": body.GCProducersConsumersRetentionHours, }) } @@ -1090,14 +1090,14 @@ func (ch ConfigurationsHandler) GetClusterConfig(c *gin.Context) { analytics.SendEvent(user.TenantName, user.Username, analyticsParams, "user-enter-cluster-config-page") } c.IndentedJSON(200, gin.H{ - "dls_retention": ch.S.opts.DlsRetentionHours[user.TenantName], - "logs_retention": ch.S.opts.LogsRetentionDays, - "broker_host": ch.S.opts.BrokerHost, - "ui_host": ch.S.opts.UiHost, - "rest_gw_host": ch.S.opts.RestGwHost, - "tiered_storage_time_sec": ch.S.opts.TieredStorageUploadIntervalSec, - "max_msg_size_mb": ch.S.opts.MaxPayload / 1024 / 1024, - "gc_producer_consumer_retention": ch.S.opts.GCProducersConsumersRetention, + "dls_retention": ch.S.opts.DlsRetentionHours[user.TenantName], + "logs_retention": ch.S.opts.LogsRetentionDays, + "broker_host": ch.S.opts.BrokerHost, + "ui_host": ch.S.opts.UiHost, + "rest_gw_host": ch.S.opts.RestGwHost, + "tiered_storage_time_sec": ch.S.opts.TieredStorageUploadIntervalSec, + "max_msg_size_mb": ch.S.opts.MaxPayload / 1024 / 1024, + "gc_producer_consumer_retention_hours": ch.S.opts.GCProducersConsumersRetentionHours, }) } diff --git a/server/memphis_handlers_configurations.go b/server/memphis_handlers_configurations.go index c5781795a..2154e9fcd 100644 --- a/server/memphis_handlers_configurations.go +++ b/server/memphis_handlers_configurations.go @@ -28,8 +28,8 @@ func changeDlsRetention(dlsRetention int, tenantName string) error { return nil } -func changeGCProducersConsumersRetention(retention int, tenantName string) error { - err := db.UpsertConfiguration("gc_producer_consumer_retention", strconv.Itoa(retention), tenantName) +func changeGCProducersConsumersRetentionHours(retention int, tenantName string) error { + err := db.UpsertConfiguration("gc_producer_consumer_retention_hours", strconv.Itoa(retention), tenantName) if err != nil { return err } diff --git a/server/memphis_helper.go b/server/memphis_helper.go index 419e9deef..1b4c60aed 100644 --- a/server/memphis_helper.go +++ b/server/memphis_helper.go @@ -1227,9 +1227,9 @@ func GetMemphisOpts(opts *Options) (*Options, error) { case "max_msg_size_mb": v, _ := strconv.Atoi(conf.Value) opts.MaxPayload = int32(v * 1024 * 1024) - case "gc_producer_consumer_retention": + case "gc_producer_consumer_retention_hours": v, _ := strconv.Atoi(conf.Value) - opts.GCProducersConsumersRetention = v + opts.GCProducersConsumersRetentionHours = v } } diff --git a/server/opts.go b/server/opts.go index 4d0682576..fec96ac53 100644 --- a/server/opts.go +++ b/server/opts.go @@ -286,16 +286,16 @@ type Options struct { LameDuckGracePeriod time.Duration `json:"-"` // memphis options - UiPort int `json:"-"` - RestGwPort int `json:"-"` - K8sNamespace string `json:"-"` - LogsRetentionDays int `json:"-"` - TieredStorageUploadIntervalSec int `json:"-"` - DlsRetentionHours map[string]int `json:"-"` - GCProducersConsumersRetention int `json:"-"` - UiHost string `json:"-"` - RestGwHost string `json:"-"` - BrokerHost string `json:"-"` + UiPort int `json:"-"` + RestGwPort int `json:"-"` + K8sNamespace string `json:"-"` + LogsRetentionDays int `json:"-"` + TieredStorageUploadIntervalSec int `json:"-"` + DlsRetentionHours map[string]int `json:"-"` + GCProducersConsumersRetentionHours int `json:"-"` + UiHost string `json:"-"` + RestGwHost string `json:"-"` + BrokerHost string `json:"-"` // MaxTracedMsgLen is the maximum printable length for traced messages. MaxTracedMsgLen int `json:"-"` @@ -1444,13 +1444,13 @@ func (o *Options) processConfigFileLine(k string, v interface{}, errors *[]error } o.DlsRetentionHours = make(map[string]int) o.DlsRetentionHours[conf.MemphisGlobalAccountName] = value - case "gc_producer_consumer_retention": + case "gc_producer_consumer_retention_hours": value := int(v.(int64)) if value < 1 || value > 48 { - *errors = append(*errors, &configErr{tk, "error gc_producer_consumer_retention config: has to be positive and not more than 48"}) + *errors = append(*errors, &configErr{tk, "error gc_producer_consumer_retention_hours config: has to be positive and not more than 48"}) return } - o.GCProducersConsumersRetention = value + o.GCProducersConsumersRetentionHours = value case "ui_host": value := v.(string) @@ -4754,8 +4754,8 @@ func setBaselineOptions(opts *Options) { if opts.LogsRetentionDays == 0 { opts.LogsRetentionDays = 7 } - if opts.GCProducersConsumersRetention == 0 { - opts.GCProducersConsumersRetention = 2 + if opts.GCProducersConsumersRetentionHours == 0 { + opts.GCProducersConsumersRetentionHours = 2 } if opts.TieredStorageUploadIntervalSec == 0 { opts.TieredStorageUploadIntervalSec = DEFAULT_TIERED_STORAGE_UPLOAD_INTERVAL_SEC diff --git a/server/reload.go b/server/reload.go index c5d3ea1f7..2090dffca 100644 --- a/server/reload.go +++ b/server/reload.go @@ -717,7 +717,7 @@ type dlsRetentionHoursOption struct { newValue map[string]int } -type GCProducersConsumersRetentionOption struct { +type GCProducersConsumersRetentionHoursOption struct { noopOption newValue int } @@ -728,9 +728,9 @@ func (o *dlsRetentionHoursOption) Apply(server *Server) { server.Noticef("Reloaded: dls_retention_hours = %v", o.newValue) } -func (o *GCProducersConsumersRetentionOption) Apply(server *Server) { +func (o *GCProducersConsumersRetentionHoursOption) Apply(server *Server) { // no need to update anything since it happens on the edit cluster configuration endpoint - server.Noticef("Reloaded: gc_producer_consumer_retention = %d", o.newValue) + server.Noticef("Reloaded: gc_producer_consumer_retention_hours = %d", o.newValue) } // logsRetentionDaysOption implements the option interface for the `logs_retention_days` @@ -1462,9 +1462,8 @@ func (s *Server) diffOptions(newOpts *Options) ([]option, error) { diffOpts = append(diffOpts, &brokerHostOption{newValue: newValue.(string)}) case "restgwhost": diffOpts = append(diffOpts, &restGwOption{newValue: newValue.(string)}) - case "gcproducersconsumersretention": - diffOpts = append(diffOpts, &GCProducersConsumersRetentionOption{newValue: newValue.(int)}) - + case "gcproducersconsumersretentionhours": + diffOpts = append(diffOpts, &GCProducersConsumersRetentionHoursOption{newValue: newValue.(int)}) default: // TODO(ik): Implement String() on those options to have a nice print. // %v is difficult to figure what's what, %+v print private fields and diff --git a/ui_src/src/domain/administration/clusterConfiguration/index.js b/ui_src/src/domain/administration/clusterConfiguration/index.js index 2b135dd40..231bcbc40 100644 --- a/ui_src/src/domain/administration/clusterConfiguration/index.js +++ b/ui_src/src/domain/administration/clusterConfiguration/index.js @@ -142,14 +142,14 @@ function ClusterConfiguration() { onChanges={(e) => handleChange('dls_retention', e)} /> handleChange('gc_producer_consumer_retention', e)} + onChanges={(e) => handleChange('gc_producer_consumer_retention_hours', e)} /> Date: Sun, 23 Jul 2023 13:57:51 +0300 Subject: [PATCH 5/5] changed location of apply func on GCProducersConsumersRetentionHours --- server/reload.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/reload.go b/server/reload.go index 2090dffca..2755a93aa 100644 --- a/server/reload.go +++ b/server/reload.go @@ -722,15 +722,15 @@ type GCProducersConsumersRetentionHoursOption struct { newValue int } -// Apply the setting by updating the server info and each client. -func (o *dlsRetentionHoursOption) Apply(server *Server) { +func (o *GCProducersConsumersRetentionHoursOption) Apply(server *Server) { // no need to update anything since it happens on the edit cluster configuration endpoint - server.Noticef("Reloaded: dls_retention_hours = %v", o.newValue) + server.Noticef("Reloaded: gc_producer_consumer_retention_hours = %d", o.newValue) } -func (o *GCProducersConsumersRetentionHoursOption) Apply(server *Server) { +// Apply the setting by updating the server info and each client. +func (o *dlsRetentionHoursOption) Apply(server *Server) { // no need to update anything since it happens on the edit cluster configuration endpoint - server.Noticef("Reloaded: gc_producer_consumer_retention_hours = %d", o.newValue) + server.Noticef("Reloaded: dls_retention_hours = %v", o.newValue) } // logsRetentionDaysOption implements the option interface for the `logs_retention_days`