-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[refactor] Seperated the parts of ES-Rollover Config common with ES Config #6516
Conversation
…onfig Signed-off-by: Manik2708 <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6516 +/- ##
=======================================
Coverage 96.27% 96.28%
=======================================
Files 372 373 +1
Lines 21283 21301 +18
=======================================
+ Hits 20491 20509 +18
Misses 605 605
Partials 187 187
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Manik2708 <[email protected]>
@@ -202,6 +202,31 @@ type BearerTokenAuthentication struct { | |||
AllowFromContext bool `mapstructure:"from_context"` | |||
} | |||
|
|||
type RolloverOptions struct { | |||
// Archive if set to true will handle archive indices also | |||
Archive bool `mapstructure:"archive"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're working on removing the explicit knowledge of "archive" from storage implementations. Is this needed? cc @mahadzaryab1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're very close to cleaning up archive, so I'd like to hold this PR until we merge #6490 and then do archive differently.
// Unit is used with lookback to remove indices from read alias e.g, days, weeks, months, years | ||
Unit string `mapstructure:"unit"` | ||
// UnitCount is the count of units for which look-up is performed | ||
UnitCount int `mapstructure:"unit-count"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- do we actually support weeks / months / years? Code ptr?
- can we not simply have this as Duration type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a copy of What used in es-rollover
. As the need was not to introduce a major change in rollover but just to include it in binary. So should we change this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could raise another PR to see if changing to time.Duration
would work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok to have the old command's flags to be a mess, but if we incorporate these into the config which will be used in Jaeger v2 we need to do a clean cut (but backwards compatible).
@@ -202,6 +202,31 @@ type BearerTokenAuthentication struct { | |||
AllowFromContext bool `mapstructure:"from_context"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you introduce these new types, where are they going to be incorporated into the main Config? We can add them now, I would like to see the full config design.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to be encorprated in the config of es.
type Rollover struct {
// Enabled if set to true will enable the ES Rollover, which will manage the jaeger indices
// automatically without manually running the cron job
Enabled bool `mapstructure:"enabled"`
// Frequency stores the duration after which this job should be performed periodically.
Frequency time.Duration `mapstructure:"frequency"`
// LookBackEnabled if set to true will enable the look back process in the rollover job. Look-back process
// is very similar to Jaeger ES-Cleaner, if cleaning through only ES-Cleaner is required then this
// can be set to false. See this section of documentation for more context:
// https://www.jaegertracing.io/docs/2.1/elasticsearch/#index-rollover
LookBackEnabled bool `mapstructure:"look_back_enabled"`
// LookBackOptions store the configuration which will be executed if look back is enabled
LookBackOptions LookBackOptions `mapstructure:"look_back_options"`
// RollBackConditions stores the conditions on which index writing should be performed
RollBackOptions RollBackOptions `mapstructure:"roll_back_options"`
// RolloverOptions store the configuration required for setting up the cron job of rolling over indices
RolloverOptions RolloverOptions `mapstructure:"rollover_options"`
}
|
||
// Config holds configuration for index cleaner binary. | ||
type Config struct { | ||
app.Config | ||
Conditions string | ||
config.RollBackOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused by the name "roll back" - what is it we're rolling back? Rollover != rollback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also confused for the name. I deduced this name from the description of the flag. RolloverConditions
would be alright?
Signed-off-by: Manik2708 <[email protected]>
) | ||
|
||
type EsRolloverFlagConfig struct { | ||
Prefix string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not seeing any usage examples where Prefix is defined to be non-empty. What is it needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is in #6500. The config of es uses a namespace es
, so the command needs to be with a prefix.
Prefix string | ||
} | ||
|
||
func (e EsRolloverFlagConfig) AddFlagsForRolloverOptions(flags *flag.FlagSet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func (e EsRolloverFlagConfig) AddFlagsForRolloverOptions(flags *flag.FlagSet) { | |
func (e EsRolloverFlagConfig) AddFlags(flags *flag.FlagSet) { |
flags.Bool(e.Prefix+flagRolloverAdaptiveSampling, defaultAdaptiveSampling, "Enable rollover for adaptive sampling index") | ||
} | ||
|
||
func (e EsRolloverFlagConfig) InitRolloverOptionsFromViper(v *viper.Viper) RolloverOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func (e EsRolloverFlagConfig) InitRolloverOptionsFromViper(v *viper.Viper) RolloverOptions { | |
func (e EsRolloverFlagConfig) InitFromViper(v *viper.Viper) RolloverOptions { |
return *r | ||
} | ||
|
||
func (e EsRolloverFlagConfig) AddFlagsForLookBackOptions(flags *flag.FlagSet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow - if these are separate sets of options/flags why do they need to be provided by the same config struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could do in a different struct also but that would be the copy of this same struct. These options/flags doesn't have a prefix but we need to have a prefix when extending the config of es.
// Unit is used with lookback to remove indices from read alias e.g, days, weeks, months, years | ||
Unit string `mapstructure:"unit"` | ||
// UnitCount is the count of units for which look-up is performed | ||
UnitCount int `mapstructure:"unit-count"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok to have the old command's flags to be a mess, but if we incorporate these into the config which will be used in Jaeger v2 we need to do a clean cut (but backwards compatible).
AdaptiveSampling bool `mapstructure:"include_adaptive_sampling"` | ||
} | ||
|
||
// LookBackOptions store the options for a sub-process which is similar to index cleaner of auto rollover of jaeger. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I question why these need to be separate. If I think about the user taking a declarative approach to index rollovers, they would describe the frequency of rotations and how much data to retain, so that the rollover and cleanup are done as a single logical process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these 3 options will be in same common struct of Rollover. Please see this:
type Rollover struct {
// Enabled if set to true will enable the ES Rollover, which will manage the jaeger indices
// automatically without manually running the cron job
Enabled bool `mapstructure:"enabled"`
// Frequency stores the duration after which this job should be performed periodically.
Frequency time.Duration `mapstructure:"frequency"`
// LookBackEnabled if set to true will enable the look back process in the rollover job. Look-back process
// is very similar to Jaeger ES-Cleaner, if cleaning through only ES-Cleaner is required then this
// can be set to false. See this section of documentation for more context:
// https://www.jaegertracing.io/docs/2.1/elasticsearch/#index-rollover
LookBackEnabled bool `mapstructure:"look_back_enabled"`
// LookBackOptions store the configuration which will be executed if look back is enabled
LookBackOptions LookBackOptions `mapstructure:"look_back_options"`
// RollBackConditions stores the conditions on which index writing should be performed
RollBackOptions RollBackOptions `mapstructure:"roll_back_options"`
// RolloverOptions store the configuration required for setting up the cron job of rolling over indices
RolloverOptions RolloverOptions `mapstructure:"rollover_options"`
}
I have created different structs because we want to keep the processes of cmd/es-rollover
decoupled. Creating a single struct will give options of LookBack
to Rollover
also.
} | ||
|
||
// RollOverConditions store the conditions required for the rollover operation in the auto-rollover cron job of jaeger. | ||
type RollOverConditions struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to question about LookBackOptions, why is this a separate struct?
// RollOverConditions store the conditions required for the rollover operation in the auto-rollover cron job of jaeger. | ||
type RollOverConditions struct { | ||
// Conditions stores the conditions on which index writing should be performed, for example: "{\"max_age\": \"2d\"}" | ||
Conditions string `mapstructure:"conditions"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
who interprets these conditions? Are they sent to Elasticsearch verbatim? if so let's say so in the comments.
@@ -202,6 +202,31 @@ type BearerTokenAuthentication struct { | |||
AllowFromContext bool `mapstructure:"from_context"` | |||
} | |||
|
|||
type RolloverOptions struct { | |||
// Archive if set to true will handle archive indices also | |||
Archive bool `mapstructure:"archive"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're very close to cleaning up archive, so I'd like to hold this PR until we merge #6490 and then do archive differently.
// Copyright (c) 2025 The Jaeger Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file can be called simply rollover.go
- both es
and cfg
are implied by the package.
@yurishkuro As discussed in the comment: #6500 (comment) and also addressing this comment: #6516 (comment) I am thinking of encorporating the config of
|
Do you see a strong business reason for If it makes sense for them to run separately then it would make sense to have separate configs with separate run-frequency settings. I am also curious about how these apply per-index. We recently upgraded configuration (only accessible via v2, not supported in v1) where each index can have its own rotation etc. settings. |
I don't think that seperate rollover frequencies is a good option. We can keep the |
I am starting to have second thoughts about this whole thing. Both ES and OS already provide automation for index rollover via ILM/ISM. Why do we need to keep maintaining our own custom scripts in the first place? |
Is this what are you saying? https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started-index-lifecycle-management.html |
Yes (but for OpenSearch there's ISM, which is similar but not the same). Since you've been reading about these rollovers, can you propose what might be needed from the Jaeger binary if we only wanted to recommend to users to use ILM/ISM? |
Sure, can work on it! Then for now I think I should stop working on this refactoring or using |
Yes, that's correct. Sorry for the churn, it seemed like a good idea originally, but it turned into more longer term maintenance than I feel it's worth. Jaeger project should be focusing on tracing, not on db management, especially when DBs already support automation out of the box. |
@yurishkuro Ok, so closing this PR as these changes doesn't make any sense now. Thanks for giving a direction. Will submit a proposal of enabling the automated rollover using ILM/ISM. |
Which problem is this PR solving?
Supporting PR of #6500
Description of the changes
How was this change tested?
Checklist
jaeger
:make lint test
jaeger-ui
:npm run lint
andnpm run test