Skip to content

Commit

Permalink
post rebase fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thepalbi committed Jan 31, 2023
1 parent e2bdad0 commit 590c0f7
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 42 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@

* [8315](https://github.com/grafana/loki/pull/8315) **thepalbi** Relicense and export `pkg/ingester` WAL code to be used in Promtail's WAL.

* [8120](https://github.com/grafana/loki/pull/8232) **TaehyunHwang** Fix version info issue that shows wrong version.
*
#### Promtail

##### Enhancements
Expand Down
3 changes: 2 additions & 1 deletion clients/pkg/promtail/client/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"sync"

"github.com/go-kit/log"
"github.com/prometheus/client_golang/prometheus"

"github.com/grafana/loki/clients/pkg/promtail/api"
"github.com/grafana/loki/clients/pkg/promtail/wal"
"github.com/prometheus/client_golang/prometheus"
)

// Manager manages remote write client instantiation, and connects the related components to orchestrate the flow of api.Entry
Expand Down
1 change: 0 additions & 1 deletion clients/pkg/promtail/client/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (

"github.com/grafana/loki/clients/pkg/promtail/api"
"github.com/grafana/loki/clients/pkg/promtail/wal"

"github.com/grafana/loki/pkg/logproto"
)

Expand Down
1 change: 0 additions & 1 deletion clients/pkg/promtail/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/grafana/loki/clients/pkg/promtail/server"
"github.com/grafana/loki/clients/pkg/promtail/targets/file"
"github.com/grafana/loki/clients/pkg/promtail/wal"

"github.com/grafana/loki/pkg/tracing"
"github.com/grafana/loki/pkg/util/flagext"
)
Expand Down
10 changes: 4 additions & 6 deletions clients/pkg/promtail/promtail.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,24 @@ import (
"crypto/md5"
"errors"
"fmt"
"github.com/grafana/loki/clients/pkg/promtail/utils"
"os"
"os/signal"
"sync"
"syscall"

"github.com/grafana/loki/clients/pkg/promtail/api"
"github.com/grafana/loki/clients/pkg/promtail/wal"

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"

"github.com/grafana/loki/clients/pkg/logentry/stages"
"github.com/grafana/loki/clients/pkg/promtail/api"
"github.com/grafana/loki/clients/pkg/promtail/client"
"github.com/grafana/loki/clients/pkg/promtail/config"
"github.com/grafana/loki/clients/pkg/promtail/server"
"github.com/grafana/loki/clients/pkg/promtail/targets"
"github.com/grafana/loki/clients/pkg/promtail/targets/target"

"github.com/grafana/loki/clients/pkg/promtail/utils"
"github.com/grafana/loki/clients/pkg/promtail/wal"
util_log "github.com/grafana/loki/pkg/util/log"
)

Expand Down Expand Up @@ -242,7 +240,7 @@ func (p *Promtail) Shutdown() {
p.client.Stop()
}

// ActiveTargets returns active handlers per jobs from the target manager
// ActiveTargets returns active targets per jobs from the target manager
func (p *Promtail) ActiveTargets() map[string][]target.Target {
return p.targetManagers.ActiveTargets()
}
Expand Down
27 changes: 14 additions & 13 deletions clients/pkg/promtail/utils/entries.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package utils

import (
"github.com/grafana/loki/clients/pkg/promtail/api"
"sync"

"github.com/grafana/loki/clients/pkg/promtail/api"
)

// EntryHandlerFanouter implements api.EntryHandler, fanning out received entries to one or multiple channels.
Expand All @@ -14,18 +15,6 @@ type EntryHandlerFanouter struct {
wg sync.WaitGroup
}

func (x *EntryHandlerFanouter) Chan() chan<- api.Entry {
return x.entries
}

// Stop only stops the channel EntryHandlerFanouter exposes, not the ones it fans out to.
func (x *EntryHandlerFanouter) Stop() {
x.once.Do(func() {
close(x.entries)
})
x.wg.Wait()
}

func NewEntryHandlerFanouter(handlers ...api.EntryHandler) *EntryHandlerFanouter {
multiplex := &EntryHandlerFanouter{
entries: make(chan api.Entry),
Expand All @@ -42,3 +31,15 @@ func NewEntryHandlerFanouter(handlers ...api.EntryHandler) *EntryHandlerFanouter
}()
return multiplex
}

func (eh *EntryHandlerFanouter) Chan() chan<- api.Entry {
return eh.entries
}

// Stop only stops the channel EntryHandlerFanouter exposes, not the ones it fans out to.
func (eh *EntryHandlerFanouter) Stop() {
eh.once.Do(func() {
close(eh.entries)
})
eh.wg.Wait()
}
7 changes: 4 additions & 3 deletions clients/pkg/promtail/utils/entries_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package utils

import (
"github.com/grafana/loki/pkg/logproto"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/require"
"sync"
"testing"
"time"

"github.com/prometheus/common/model"
"github.com/stretchr/testify/require"

"github.com/grafana/loki/clients/pkg/promtail/api"
"github.com/grafana/loki/pkg/logproto"
)

func TestEntryHandlerFanouter(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions clients/pkg/promtail/wal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ const (

// Config contains all WAL-related settings.
type Config struct {
// Path where the WAL is written to.
Dir string `yaml:"dir"`

// Whether WAL-support should be enabled.
//
// WAL support is a WIP. Do not enable in production setups until https://github.com/grafana/loki/issues/8197
// is finished.
Enabled bool `yaml:"enabled"`

// Path where the WAL is written to.
Dir string `yaml:"dir"`

// MaxSegmentAge is threshold at which a WAL segment is considered old enough to be cleaned up. Default: 1h.
MaxSegmentAge time.Duration `yaml:"cleanSegmentsOlderThan"`
}
Expand Down
7 changes: 4 additions & 3 deletions clients/pkg/promtail/wal/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package wal

import (
"fmt"
"github.com/grafana/loki/clients/pkg/promtail/api"
"github.com/grafana/loki/pkg/ingester/wal"
walUtils "github.com/grafana/loki/pkg/util/wal"

"github.com/prometheus/common/model"

"github.com/grafana/loki/clients/pkg/promtail/api"
"github.com/grafana/loki/pkg/ingester/wal"
"github.com/grafana/loki/pkg/util"
walUtils "github.com/grafana/loki/pkg/util/wal"
)

// ReadWAL will read all entries in the WAL located under dir. Mainly used for testing
Expand Down
3 changes: 2 additions & 1 deletion clients/pkg/promtail/wal/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package wal

import (
"fmt"
"github.com/grafana/loki/pkg/ingester/wal"
"os"

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/prometheus/tsdb/wlog"

"github.com/grafana/loki/pkg/ingester/wal"
)

var (
Expand Down
12 changes: 7 additions & 5 deletions clients/pkg/promtail/wal/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package wal

import (
"fmt"
"github.com/grafana/loki/pkg/ingester/wal"
"github.com/prometheus/client_golang/prometheus"
"os"
"path/filepath"
"sort"
Expand All @@ -13,11 +11,13 @@ import (

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/grafana/loki/clients/pkg/promtail/api"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/tsdb/chunks"
"github.com/prometheus/prometheus/tsdb/record"

"github.com/grafana/loki/clients/pkg/promtail/api"
"github.com/grafana/loki/pkg/ingester/wal"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/util"
)
Expand All @@ -28,7 +28,8 @@ const (

// Writer implements api.EntryHandler, exposing a channel were scraping targets can write to. Reading from there, it
// writes incoming entries to a WAL.
// Also, since Writer is responsible for all changing operations over the WAL, a routine is run for cleaning old segments.
// Also, since Writer is responsible for all changing operations over the WAL, therefore a routine is run for cleaning
// old segments.
type Writer struct {
entries chan api.Entry
log log.Logger
Expand Down Expand Up @@ -220,12 +221,13 @@ type segmentRef struct {
lastModified time.Time
}

// listSegments list wal segments under the given directory, alongside with some file system information for each.
func listSegments(dir string) (refs []segmentRef, err error) {
files, err := os.ReadDir(dir)
if err != nil {
return nil, err
}
// the following will attempt to get segments info in a best effort manner
// the following will attempt to get segments info in a best effort manner, omitting file if error
for _, f := range files {
fn := f.Name()
k, err := strconv.Atoi(fn)
Expand Down
3 changes: 1 addition & 2 deletions clients/pkg/promtail/wal/writer_test.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package wal

import (
"github.com/go-kit/log/level"
"os"
"path/filepath"
"testing"
"time"

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/require"

"github.com/grafana/loki/clients/pkg/promtail/api"

"github.com/grafana/loki/pkg/logproto"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/ingester/recovery.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ingester

import (
io "io"
"io"
"runtime"
"sync"

Expand Down

0 comments on commit 590c0f7

Please sign in to comment.