Skip to content

Commit

Permalink
fixed the integration issue
Browse files Browse the repository at this point in the history
Signed-off-by: Rohanraj123 <[email protected]>
  • Loading branch information
Rohanraj123 committed Dec 6, 2024
1 parent 5058ec2 commit 95d4041
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 22 deletions.
3 changes: 3 additions & 0 deletions cmd/jaeger/config-elasticsearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ extensions:
backends:
some_storage:
elasticsearch:
rollover:
enabled: true
frequency: "week"
indices:
index_prefix: "jaeger-main"
spans:
Expand Down
2 changes: 1 addition & 1 deletion pkg/es/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ type Configuration struct {
// IndexCleaner holds the configuration for the Elasticsearch index Cleaner.
IndexCleaner IndexCleaner `mapstructure:"index_cleaner"`
// Rollover holds the configuration for the Elasticsearh roll over.
Rollover Rollover `mapstructure:"roll_over"`
Rollover Rollover `mapstructure:"rollover"`
}

// TagsAsFields holds configuration for tag schema.
Expand Down
9 changes: 3 additions & 6 deletions plugin/storage/es/index_cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package es

import (
"errors"
"fmt"
"log"
"os/exec"
Expand Down Expand Up @@ -39,14 +40,10 @@ func (cfg *CleanerConfigWrapper) RunCleaner() {
// runESIndexCleaner runs the cmd/es-index-cleaner command.
func (cfg *CleanerConfigWrapper) runESIndexCleaner() error {
if len(cfg.Servers) == 0 {
return fmt.Errorf("elasticsearch server URL is missing in configuration")
return errors.New("elasticsearch server URL is missing in configuration")
}

Check warning on line 44 in plugin/storage/es/index_cleaner.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/es/index_cleaner.go#L41-L44

Added lines #L41 - L44 were not covered by tests

esURL := cfg.Servers[0]
numOfDays := int(cfg.MaxSpanAge.Hours() / 24)

cmd := exec.Command("./cmd/es-index-cleaner", fmt.Sprintf("%d", numOfDays), esURL)
cmd.Args = append(cmd.Args, "--max-span-age", cfg.MaxSpanAge.String())
cmd := exec.Command("./cmd/es-index-cleaner")

err := cmd.Run()
if err != nil {
Expand Down
20 changes: 5 additions & 15 deletions plugin/storage/es/index_rollover.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package es

import (
"fmt"
"log"
"os/exec"
"time"
Expand All @@ -29,22 +28,13 @@ func (cfg *RolloverConfigWrapper) RunRollover() {
for range ticker.C {
log.Println("Running index rollover...")

err := cfg.runEsRollover()
cmd := exec.Command("./cmd/es-rollover")
err := cmd.Run()

if err != nil {
log.Printf("Error running es-rollover: %v", err)
} else {
log.Println("Index rollover executed successfully.")
}

Check warning on line 38 in plugin/storage/es/index_rollover.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/es/index_rollover.go#L25-L38

Added lines #L25 - L38 were not covered by tests
}
}

// runEsRollover executes the rollover tool.
func (cfg *RolloverConfigWrapper) runEsRollover() error {
cmd := exec.Command("./cmd/es-rollover")

err := cmd.Run()
if err != nil {
return fmt.Errorf("failed to run es-rollover: %w", err)
}

log.Println("Index rollover executed successfully")
return nil
}

0 comments on commit 95d4041

Please sign in to comment.