-
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
feat: Remove the need for external tools for managing ElasticSearch #6291
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Rohanraj123 <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6291 +/- ##
==========================================
- Coverage 96.20% 95.92% -0.29%
==========================================
Files 356 359 +3
Lines 20416 20519 +103
==========================================
+ Hits 19642 19683 +41
- Misses 585 648 +63
+ Partials 189 188 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
pkg/es/config/config.go
Outdated
|
||
// Validation function for Cleaner struct | ||
func (c *Cleaner) Validate() error { | ||
if c.Frequency <= 0 { |
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.
validation can be declared in the field tags
pkg/es/config/config.go
Outdated
type Cleaner struct { | ||
Enabled bool `mapstructure:"enabled"` | ||
Frequency time.Duration `mapstructure:"frequency"` | ||
IncludeArchive bool `mapstructure:"include_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.
in v2 archive storage is a separate instance, this property won't make sense
pkg/es/config/config.go
Outdated
|
||
// ---- ES-specific config ---- | ||
// Cleaner holds the configuration for the Elasticsearch index Cleaner. | ||
Cleaner Cleaner `mapstructure:"cleaner"` |
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.
Cleaner Cleaner `mapstructure:"cleaner"` | |
IndexCleaner IndexCleaner `mapstructure:"index_cleaner"` |
pkg/es/config/config.go
Outdated
@@ -585,3 +608,198 @@ func (c *Configuration) Validate() error { | |||
_, err := govalidator.ValidateStruct(c) | |||
return err | |||
} | |||
|
|||
// Run starts the cleaner that runs periodically based on the Frequency field. | |||
func (cfg *Configuration) RunCleaner() { |
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.
config package is for configuration, not for business logic. This should be somewhere in plugin/storage/es
pkg/es/config/config.go
Outdated
} | ||
|
||
// deleteOldIndices deletes indices older than the configured MaxSpanAge. | ||
func (cfg *Configuration) deleteOldIndices() error { |
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.
doesn't this logic already exist in in cmd/es-index-cleaner? Why do we need to duplicate it?
cmd/jaeger/main.go
Outdated
@@ -24,6 +24,8 @@ func main() { | |||
command, | |||
) | |||
|
|||
internal.StartCleaner(v) |
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 enabled by config option, no need to "start" anything expicitly
Signed-off-by: Rohanraj123 <[email protected]>
pkg/es/config/config.go
Outdated
// Rollover struct for configuring roll over | ||
type Rollover struct { | ||
Enabled bool `mapstructure:"enabled" valid:"required"` | ||
IndexPattern string `mapstructure:"index_pattern" valid:"required"` |
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.
Storage already knows how indices are named, why is this arg needed?
// IndexCleaner struct for configuring index cleaning | ||
type IndexCleaner struct { | ||
Enabled bool `mapstructure:"enabled"` | ||
Frequency time.Duration `mapstructure:"frequency" validate:"gt=0"` |
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.
Please add comment describing the arg
pkg/es/config/config.go
Outdated
type Rollover struct { | ||
Enabled bool `mapstructure:"enabled" valid:"required"` | ||
IndexPattern string `mapstructure:"index_pattern" valid:"required"` | ||
Frequency time.Duration `mapstructure:"frequency" validate:"gt=0"` |
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.
Comment
Signed-off-by: Rohanraj123 <[email protected]>
Signed-off-by: Rohanraj123 <[email protected]>
Signed-off-by: Rohanraj123 <[email protected]>
Signed-off-by: Rohanraj123 <[email protected]>
Signed-off-by: Rohanraj123 <[email protected]>
Signed-off-by: Rohanraj123 <[email protected]>
6ca42c2
to
cf7043c
Compare
Signed-off-by: Rohanraj123 <[email protected]>
Signed-off-by: Rohanraj123 <[email protected]>
cf7043c
to
e40a5f7
Compare
@yurishkuro Can you please review the PR once. So that i can see, whether going into right direction or not. |
@@ -36,22 +36,22 @@ extensions: | |||
index_prefix: "jaeger-main" | |||
spans: | |||
date_layout: "2006-01-02" | |||
rollover_frequency: "day" | |||
rollover_frequency: "1day" |
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.
can you create another PR (to merge before this one) that changes the RolloverFrequency
field type to time.Duration
?
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.
Okay!
} | ||
|
||
// Run the esmapping-generator command | ||
execCmd := exec.Command("go", "run", "./cmd/esmapping-generator") |
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.
How do you imagine this working in production if someone runs Jaeger as a container image? Where would they get go
toolchain and Jaeger source code?
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.
Can you guide me here little
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.
Can you guide me here little
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.
first, I suggest you focus on one tool at a time, start with the cleaner only. The logic of the cleaner is already implemented in Go, we can call it directly as a library from the ES implementation. You can reuse all the sub-commands defined in cmd/es-cleaner, but you may have to move them out of main() into a reusable package (that would be a standalone refactoring and should be its own PR).
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.
one more thing - I think the easiest too to start with is es-mapping, because it's purely an on-demand command run with no need to set up periodic jobs.
I was wrong in the comment above - I don't think sub-commands will be needed once the cleaner/rollover are integrated into the main binary, because the only reason those sub-commands exist today is to allow the script to be run as externally managed cron job, so it needs to do different things. But if it's run as internal periodic job, it's one combined functionality.
Which problem is this PR solving?
Description of the changes
How was this change tested?
Checklist
jaeger
:make lint test
jaeger-ui
:yarn lint
andyarn test