Skip to content

Commit

Permalink
Update dskit version (#5392)
Browse files Browse the repository at this point in the history
* Update dskit version

Signed-off-by: Michel Hollands <[email protected]>

* update changelog

Signed-off-by: Michel Hollands <[email protected]>

* Add debug printing to see interfaces in CI. This will be reverted

Signed-off-by: Michel Hollands <[email protected]>

* Add comment to remember to remove

Signed-off-by: Michel Hollands <[email protected]>

* Use netutil.PrivateNetworkInterfacesWithFallback for the other rings

Signed-off-by: Michel Hollands <[email protected]>

* Move import to place indicated by linter

Signed-off-by: Michel Hollands <[email protected]>

* Remove debug printing

Signed-off-by: Michel Hollands <[email protected]>

* Determine local interfaces in tests

Signed-off-by: Michel Hollands <[email protected]>

* Rearrange import to satify linter

Signed-off-by: Michel Hollands <[email protected]>

* Update build image in CircleCI

Signed-off-by: Michel Hollands <[email protected]>

* Change changelegog message to show customer visible changes

Signed-off-by: Michel Hollands <[email protected]>

* Add doc tag and use private network interfaces in common config

Signed-off-by: Michel Hollands <[email protected]>

* Add comment about filtered out non private IP addresses

Signed-off-by: Michel Hollands <[email protected]>

* Update the documentation of the interface names settings

Signed-off-by: Michel Hollands <[email protected]>
  • Loading branch information
MichelHollands authored Feb 16, 2022
1 parent b4bb8a1 commit d8ed87d
Show file tree
Hide file tree
Showing 20 changed files with 118 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ workflows:
# https://circleci.com/blog/circleci-hacks-reuse-yaml-in-your-circleci-config-with-yaml/
.defaults: &defaults
docker:
- image: grafana/loki-build-image:0.13.0
- image: grafana/loki-build-image:0.19.0
working_directory: /src/loki

jobs:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Main

* [5392](https://github.com/grafana/loki/pull/5392) **MichelHollands**: Etcd credentials are parsed as secrets instead of plain text now.
* [5361](https://github.com/grafana/loki/pull/5361) **ctovena**: Add usage report to grafana.com.
* [5289](https://github.com/grafana/loki/pull/5289) **ctovena**: Fix deduplication bug in queries when mutating labels.
* [5302](https://github.com/grafana/loki/pull/5302) **MasslessParticle** Update azure blobstore client to use new sdk.
Expand Down
8 changes: 4 additions & 4 deletions docs/sources/configuration/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ ring:

# Name of network interface to read addresses from.
# CLI flag: -<prefix>.instance-interface-names
[instance_interface_names: <list of string> | default = [eth0 en0]]
[instance_interface_names: <list of string> | default = [<private network interfaces>]]

# The number of tokens the lifecycler will generate and put into the ring if
# it joined without transferring tokens from another lifecycler.
Expand Down Expand Up @@ -1079,7 +1079,7 @@ lifecycler:
# CLI flag: -ingester.lifecycler.interface
interface_names:
- [<string> ... | default = ["eth0", "en0"]]
- [<string> ... | default = [<private network interfaces>]]
# Duration to sleep before exiting to ensure metrics are scraped.
# CLI flag: -ingester.final-sleep
Expand Down Expand Up @@ -2483,7 +2483,7 @@ This way, one doesn't have to replicate configuration in multiple places.
# If "instance_interface_names" under the common ring section is configured,
# this common "instance_interface_names" is only applied to the frontend, but not for
# ring related components (ex: distributor, ruler, etc).
[instance_interface_names: <list of string>]
[instance_interface_names: <list of string> | default = [<private network interfaces>]]
# A common address used by Loki components to advertise their address.
# If a more specific "instance_addr" is set, this is ignored.
Expand Down Expand Up @@ -2609,7 +2609,7 @@ kvstore:
# Name of network interface to read addresses from.
# CLI flag: -<prefix>.instance-interface-names
[instance_interface_names: <list of string> | default = [eth0 en0]]
[instance_interface_names: <list of string> | default = [<private network interfaces>]]
# IP address to advertise in the ring.
# CLI flag: -<prefix>.instance-addr
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ require (
github.com/google/go-cmp v0.5.6
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.4.2
github.com/grafana/dskit v0.0.0-20220209070952-ea22a8f662d0
github.com/grafana/dskit v0.0.0-20220211095946-19921f863583
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645
github.com/hashicorp/consul/api v1.12.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1032,8 +1032,8 @@ github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0U
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY=
github.com/grafana/dskit v0.0.0-20211021180445-3bd016e9d7f1/go.mod h1:uPG2nyK4CtgNDmWv7qyzYcdI+S90kHHRWvHnBtEMBXM=
github.com/grafana/dskit v0.0.0-20220209070952-ea22a8f662d0 h1:R0Pw7VjouhYSS7bsMdxEidcJbCq1KUBCzPgsh7805NM=
github.com/grafana/dskit v0.0.0-20220209070952-ea22a8f662d0/go.mod h1:Q9WmQ9cVkrHx6g4KSl6TN+N3vEOkDZd9RtyXCHd5OPQ=
github.com/grafana/dskit v0.0.0-20220211095946-19921f863583 h1:UCLVGNJptATClAs4CbClVmn5b4YA6GTG3yoCObI//0E=
github.com/grafana/dskit v0.0.0-20220211095946-19921f863583/go.mod h1:q51XdMLLHNZJSG6KOGujC20ed2OoLFdx0hBmOEVfRs0=
github.com/grafana/go-gelf v0.0.0-20211112153804-126646b86de8 h1:aEOagXOTqtN9gd4jiDuP/5a81HdoJBqkVfn8WaxbsK4=
github.com/grafana/go-gelf v0.0.0-20211112153804-126646b86de8/go.mod h1:QAvS2C7TtQRhhv9Uf/sxD+BUhpkrPFm5jK/9MzUiDCY=
github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85 h1:xLuzPoOzdfNb/RF/IENCw+oLVdZB4G21VPhkHBgwSHY=
Expand Down
5 changes: 3 additions & 2 deletions pkg/distributor/distributor_ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/go-kit/log/level"
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/kv"
"github.com/grafana/dskit/netutil"
"github.com/grafana/dskit/ring"

util_log "github.com/grafana/loki/pkg/util/log"
Expand All @@ -24,7 +25,7 @@ type RingConfig struct {

// Instance details
InstanceID string `yaml:"instance_id" doc:"hidden"`
InstanceInterfaceNames []string `yaml:"instance_interface_names"`
InstanceInterfaceNames []string `yaml:"instance_interface_names" doc:"default=[<private network interfaces>]"`
InstancePort int `yaml:"instance_port" doc:"hidden"`
InstanceAddr string `yaml:"instance_addr" doc:"hidden"`

Expand All @@ -46,7 +47,7 @@ func (cfg *RingConfig) RegisterFlags(f *flag.FlagSet) {
f.DurationVar(&cfg.HeartbeatTimeout, "distributor.ring.heartbeat-timeout", time.Minute, "The heartbeat timeout after which distributors are considered unhealthy within the ring. 0 = never (timeout disabled).")

// Instance flags
cfg.InstanceInterfaceNames = []string{"eth0", "en0"}
cfg.InstanceInterfaceNames = netutil.PrivateNetworkInterfacesWithFallback([]string{"eth0", "en0"}, util_log.Logger)
f.Var((*flagext.StringSlice)(&cfg.InstanceInterfaceNames), "distributor.ring.instance-interface-names", "Name of network interface to read address from.")
f.StringVar(&cfg.InstanceAddr, "distributor.ring.instance-addr", "", "IP address to advertise in the ring.")
f.IntVar(&cfg.InstancePort, "distributor.ring.instance-port", 0, "Port to advertise in the ring (defaults to server.grpc-listen-port).")
Expand Down
2 changes: 1 addition & 1 deletion pkg/ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type Config struct {

// RegisterFlags registers the flags.
func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
cfg.LifecyclerConfig.RegisterFlags(f)
cfg.LifecyclerConfig.RegisterFlags(f, util_log.Logger)
cfg.WAL.RegisterFlags(f)

f.IntVar(&cfg.MaxTransferRetries, "ingester.max-transfer-retries", 0, "Number of times to try and transfer chunks before falling back to flushing. If set to 0 or negative value, transfers are disabled.")
Expand Down
8 changes: 6 additions & 2 deletions pkg/loki/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import (
"flag"

"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/netutil"

"github.com/grafana/loki/pkg/storage/chunk/aws"
"github.com/grafana/loki/pkg/storage/chunk/azure"
"github.com/grafana/loki/pkg/storage/chunk/gcp"
"github.com/grafana/loki/pkg/storage/chunk/hedging"
"github.com/grafana/loki/pkg/storage/chunk/openstack"
"github.com/grafana/loki/pkg/util"

util_log "github.com/grafana/loki/pkg/util/log"
)

// Config holds common config that can be shared between multiple other config sections.
Expand All @@ -27,7 +30,8 @@ type Config struct {
//
// Internally, addresses will be resolved in the order that this is configured.
// By default, the list of used interfaces are, in order: "eth0", "en0", and your loopback net interface (probably "lo").
InstanceInterfaceNames []string `yaml:"instance_interface_names"`
// If an interface does not have a private IP address it is filtered out, falling back to "eth0" and "en0" if none are left.
InstanceInterfaceNames []string `yaml:"instance_interface_names" doc:"default=[<private network interfaces>]"`

// InstanceAddr represents a common ip used by instances to advertise their address.
//
Expand All @@ -44,7 +48,7 @@ func (c *Config) RegisterFlags(_ *flag.FlagSet) {
c.Ring.RegisterFlagsWithPrefix("", "collectors/", throwaway)

// instance related flags.
c.InstanceInterfaceNames = []string{"eth0", "en0"}
c.InstanceInterfaceNames = netutil.PrivateNetworkInterfacesWithFallback([]string{"eth0", "en0"}, util_log.Logger)
throwaway.StringVar(&c.InstanceAddr, "common.instance-addr", "", "Default advertised address to be used by Loki components.")
throwaway.Var((*flagext.StringSlice)(&c.InstanceInterfaceNames), "common.instance-interface-names", "List of network interfaces to read address from.")
}
Expand Down
14 changes: 10 additions & 4 deletions pkg/loki/config_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"testing"
"time"

"github.com/grafana/dskit/netutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand All @@ -22,6 +23,7 @@ import (
"github.com/grafana/loki/pkg/storage/chunk/storage"
"github.com/grafana/loki/pkg/util"
"github.com/grafana/loki/pkg/util/cfg"
util_log "github.com/grafana/loki/pkg/util/log"
loki_net "github.com/grafana/loki/pkg/util/net"
)

Expand Down Expand Up @@ -1101,7 +1103,9 @@ query_scheduler:
assert.Equal(t, config.Distributor.DistributorRing.InstanceInterfaceNames, []string{"distributoriface"})
assert.Equal(t, config.QueryScheduler.SchedulerRing.InstanceInterfaceNames, []string{"scheduleriface"})
assert.Equal(t, config.Ruler.Ring.InstanceInterfaceNames, []string{"ruleriface"})
assert.Equal(t, config.Ingester.LifecyclerConfig.InfNames, []string{"eth0", "en0", defaultIface})
expectedInterfaces := netutil.PrivateNetworkInterfacesWithFallback([]string{"eth0", "en0"}, util_log.Logger)
expectedInterfaces = append(expectedInterfaces, defaultIface)
assert.Equal(t, config.Ingester.LifecyclerConfig.InfNames, expectedInterfaces)
})
}

Expand All @@ -1113,9 +1117,11 @@ func TestLoopbackAppendingToFrontendV2(t *testing.T) {
t.Run("when using common or ingester ring configs, loopback should be added to interface names", func(t *testing.T) {
config, _, err := configWrapperFromYAML(t, minimalConfig, []string{})
assert.NoError(t, err)
assert.Equal(t, []string{"eth0", "en0", defaultIface}, config.Frontend.FrontendV2.InfNames)
assert.Equal(t, []string{"eth0", "en0", defaultIface}, config.Ingester.LifecyclerConfig.InfNames)
assert.Equal(t, []string{"eth0", "en0", defaultIface}, config.Common.Ring.InstanceInterfaceNames)
expectedInterfaces := netutil.PrivateNetworkInterfacesWithFallback([]string{"eth0", "en0"}, util_log.Logger)
expectedInterfaces = append(expectedInterfaces, defaultIface)
assert.Equal(t, expectedInterfaces, config.Frontend.FrontendV2.InfNames)
assert.Equal(t, expectedInterfaces, config.Ingester.LifecyclerConfig.InfNames)
assert.Equal(t, expectedInterfaces, config.Common.Ring.InstanceInterfaceNames)
})

t.Run("loopback shouldn't be in FrontendV2 interface names if set by user", func(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion pkg/lokifrontend/frontend/v2/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/go-kit/log/level"
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/grpcclient"
"github.com/grafana/dskit/netutil"
"github.com/grafana/dskit/ring"
"github.com/grafana/dskit/services"
"github.com/opentracing/opentracing-go"
Expand All @@ -26,6 +27,7 @@ import (
"github.com/grafana/loki/pkg/querier/stats"
"github.com/grafana/loki/pkg/tenant"
lokigrpc "github.com/grafana/loki/pkg/util/httpgrpc"
util_log "github.com/grafana/loki/pkg/util/log"
)

// Config for a Frontend.
Expand All @@ -48,7 +50,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
f.DurationVar(&cfg.DNSLookupPeriod, "frontend.scheduler-dns-lookup-period", 10*time.Second, "How often to resolve the scheduler-address, in order to look for new query-scheduler instances. Also used to determine how often to poll the scheduler-ring for addresses if the scheduler-ring is configured.")
f.IntVar(&cfg.WorkerConcurrency, "frontend.scheduler-worker-concurrency", 5, "Number of concurrent workers forwarding queries to single query-scheduler.")

cfg.InfNames = []string{"eth0", "en0"}
cfg.InfNames = netutil.PrivateNetworkInterfacesWithFallback([]string{"eth0", "en0"}, util_log.Logger)
f.Var((*flagext.StringSlice)(&cfg.InfNames), "frontend.instance-interface-names", "Name of network interface to read address from. This address is sent to query-scheduler and querier, which uses it to send the query response back to query-frontend.")
f.StringVar(&cfg.Addr, "frontend.instance-addr", "", "IP address to advertise to querier (via scheduler) (resolved via interfaces by default).")
f.IntVar(&cfg.Port, "frontend.instance-port", 0, "Port to advertise to querier (via scheduler) (defaults to server.grpc-listen-port).")
Expand Down
7 changes: 5 additions & 2 deletions pkg/ruler/base/ruler_ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import (
"github.com/go-kit/log"
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/kv"
"github.com/grafana/dskit/netutil"
"github.com/grafana/dskit/ring"

util_log "github.com/grafana/loki/pkg/util/log"
)

const (
Expand All @@ -36,7 +39,7 @@ type RingConfig struct {

// Instance details
InstanceID string `yaml:"instance_id" doc:"hidden"`
InstanceInterfaceNames []string `yaml:"instance_interface_names"`
InstanceInterfaceNames []string `yaml:"instance_interface_names" doc:"default=[<private network interfaces>]"`
InstancePort int `yaml:"instance_port" doc:"hidden"`
InstanceAddr string `yaml:"instance_addr" doc:"hidden"`
NumTokens int `yaml:"num_tokens"`
Expand All @@ -61,7 +64,7 @@ func (cfg *RingConfig) RegisterFlags(f *flag.FlagSet) {
f.DurationVar(&cfg.HeartbeatTimeout, "ruler.ring.heartbeat-timeout", time.Minute, "The heartbeat timeout after which rulers are considered unhealthy within the ring. 0 = never (timeout disabled).")

// Instance flags
cfg.InstanceInterfaceNames = []string{"eth0", "en0"}
cfg.InstanceInterfaceNames = netutil.PrivateNetworkInterfacesWithFallback([]string{"eth0", "en0"}, util_log.Logger)
f.Var((*flagext.StringSlice)(&cfg.InstanceInterfaceNames), "ruler.ring.instance-interface-names", "Name of network interface to read address from.")
f.StringVar(&cfg.InstanceAddr, "ruler.ring.instance-addr", "", "IP address to advertise in the ring.")
f.IntVar(&cfg.InstancePort, "ruler.ring.instance-port", 0, "Port to advertise in the ring (defaults to server.grpc-listen-port).")
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func GetFirstAddressOf(names []string) (string, error) {
return ipAddr, nil
}
if ipAddr == "" {
return "", fmt.Errorf("No address found for %s", names)
return "", fmt.Errorf("no address found for %s", names)
}
if strings.HasPrefix(ipAddr, `169.254.`) {
level.Warn(util_log.Logger).Log("msg", "using automatic private ip", "address", ipAddr)
Expand Down
5 changes: 3 additions & 2 deletions pkg/util/ring_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/go-kit/log/level"
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/kv"
"github.com/grafana/dskit/netutil"
"github.com/grafana/dskit/ring"

util_log "github.com/grafana/loki/pkg/util/log"
Expand All @@ -29,7 +30,7 @@ type RingConfig struct {

// Instance details
InstanceID string `yaml:"instance_id"`
InstanceInterfaceNames []string `yaml:"instance_interface_names"`
InstanceInterfaceNames []string `yaml:"instance_interface_names" doc:"default=[<private network interfaces>]"`
InstancePort int `yaml:"instance_port"`
InstanceAddr string `yaml:"instance_addr"`
InstanceZone string `yaml:"instance_availability_zone"`
Expand Down Expand Up @@ -57,7 +58,7 @@ func (cfg *RingConfig) RegisterFlagsWithPrefix(flagsPrefix, storePrefix string,
f.BoolVar(&cfg.ZoneAwarenessEnabled, flagsPrefix+"ring.zone-awareness-enabled", false, "True to enable zone-awareness and replicate blocks across different availability zones.")

// Instance flags
cfg.InstanceInterfaceNames = []string{"eth0", "en0"}
cfg.InstanceInterfaceNames = netutil.PrivateNetworkInterfacesWithFallback([]string{"eth0", "en0"}, util_log.Logger)
f.Var((*flagext.StringSlice)(&cfg.InstanceInterfaceNames), flagsPrefix+"ring.instance-interface-names", "Name of network interface to read address from.")
f.StringVar(&cfg.InstanceAddr, flagsPrefix+"ring.instance-addr", "", "IP address to advertise in the ring.")
f.IntVar(&cfg.InstancePort, flagsPrefix+"ring.instance-port", 0, "Port to advertise in the ring (defaults to server.grpc-listen-port).")
Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/grafana/dskit/grpcclient/grpcclient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions vendor/github.com/grafana/dskit/kv/etcd/etcd.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions vendor/github.com/grafana/dskit/netutil/netutil.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d8ed87d

Please sign in to comment.