Skip to content

Commit 0788d61

Browse files
authored
Accomodate logger changes from tlscommon package (#46308)
This PR accommodates breaking changes made in elastic-agent-libs . It effectively uses local logger in place of global ones
1 parent a031659 commit 0788d61

File tree

24 files changed

+56
-34
lines changed

24 files changed

+56
-34
lines changed

NOTICE.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12413,11 +12413,11 @@ SOFTWARE
1241312413

1241412414
--------------------------------------------------------------------------------
1241512415
Dependency : github.com/elastic/elastic-agent-libs
12416-
Version: v0.23.0
12416+
Version: v0.24.0
1241712417
Licence type (autodetected): Apache-2.0
1241812418
--------------------------------------------------------------------------------
1241912419

12420-
Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-libs@v0.23.0/LICENSE:
12420+
Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-libs@v0.24.0/LICENSE:
1242112421

1242212422
Apache License
1242312423
Version 2.0, January 2004

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ require (
176176
github.com/elastic/bayeux v1.0.5
177177
github.com/elastic/ebpfevents v0.7.0
178178
github.com/elastic/elastic-agent-autodiscover v0.10.0
179-
github.com/elastic/elastic-agent-libs v0.23.0
179+
github.com/elastic/elastic-agent-libs v0.24.0
180180
github.com/elastic/elastic-agent-system-metrics v0.13.2
181181
github.com/elastic/go-elasticsearch/v8 v8.18.1
182182
github.com/elastic/go-freelru v0.16.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ github.com/elastic/elastic-agent-autodiscover v0.10.0 h1:WJ4zl9uSfk1kHmn2B/0byQB
370370
github.com/elastic/elastic-agent-autodiscover v0.10.0/go.mod h1:Nf3zh9FcJ9nTTswTwDTUAqXmvQllOrNliM6xmORSxwE=
371371
github.com/elastic/elastic-agent-client/v7 v7.15.0 h1:nDB7v8TBoNuD6IIzC3z7Q0y+7bMgXoT2DsHfolO2CHE=
372372
github.com/elastic/elastic-agent-client/v7 v7.15.0/go.mod h1:6h+f9QdIr3GO2ODC0Y8+aEXRwzbA5W4eV4dd/67z7nI=
373-
github.com/elastic/elastic-agent-libs v0.23.0 h1:xpMKkrw59QUYWUx/q2TMpJU+6vwB3Mw1VPhRPcGhBMo=
374-
github.com/elastic/elastic-agent-libs v0.23.0/go.mod h1:xSeIP3NtOIT4N2pPS4EyURmS1Q8mK0lWZ8Wd1Du6q3w=
373+
github.com/elastic/elastic-agent-libs v0.24.0 h1:8skd0le8Y/zAGVaj4m44ljiJMAp0xuJz07ngDTL/1kM=
374+
github.com/elastic/elastic-agent-libs v0.24.0/go.mod h1:xSeIP3NtOIT4N2pPS4EyURmS1Q8mK0lWZ8Wd1Du6q3w=
375375
github.com/elastic/elastic-agent-system-metrics v0.13.2 h1:R4ogKHESuWhWTtopnw/aHnBxxSZbxd7KHV4GefdwT2M=
376376
github.com/elastic/elastic-agent-system-metrics v0.13.2/go.mod h1:ezM1kzDUT+vWXFh5oK8QXB/AEB0UoLWqWA8rkRicFFo=
377377
github.com/elastic/elastic-transport-go/v8 v8.7.0 h1:OgTneVuXP2uip4BA658Xi6Hfw+PeIOod2rY3GVMGoVE=

heartbeat/monitors/active/dialchain/tls.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
"github.com/elastic/beats/v7/heartbeat/monitors/active/dialchain/tlsmeta"
2727
"github.com/elastic/beats/v7/libbeat/beat"
28+
"github.com/elastic/elastic-agent-libs/logp"
2829
"github.com/elastic/elastic-agent-libs/transport"
2930
"github.com/elastic/elastic-agent-libs/transport/tlscommon"
3031
)
@@ -40,7 +41,7 @@ func TLSLayer(cfg *tlscommon.TLSConfig, to time.Duration) Layer {
4041
// This gets us the timestamp for when the TLS layer will start the handshake.
4142
next = startTimerAfterDial(&timer, next)
4243

43-
dialer := transport.TLSDialer(next, cfg, to)
44+
dialer := transport.TLSDialer(next, cfg, to, logp.NewLogger(""))
4445
return afterDial(dialer, func(conn net.Conn) (net.Conn, error) {
4546
tlsConn, ok := conn.(*cryptoTLS.Conn)
4647
if !ok {

libbeat/autodiscover/providers/kubernetes/config.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,13 @@ func (c *Config) Validate() error {
113113
if c.Scope != "node" && c.Scope != "cluster" {
114114
return fmt.Errorf("invalid `scope` configured. supported values are `node` and `cluster`")
115115
}
116-
if c.Unique && c.Scope != "cluster" {
117-
logp.L().Warnf("can only set `unique` when scope is `cluster`")
118-
}
119116

120117
return nil
121118
}
119+
120+
// checkUnsupportedParams checks if unsupported/deprecated/discouraged paramaters are set and logs a warning
121+
func (c Config) checkUnsupportedParams(logger *logp.Logger) {
122+
if c.Unique && c.Scope != "cluster" {
123+
logger.Warn("can only set `unique` when scope is `cluster`")
124+
}
125+
}

libbeat/autodiscover/providers/kubernetes/kubernetes.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ func AutodiscoverBuilder(
110110
return nil, errWrap(err)
111111
}
112112

113+
// log warning about any unsupported params
114+
config.checkUnsupportedParams(logger)
115+
113116
client, err := kubernetes.GetKubernetesClient(config.KubeConfig, config.KubeClientOptions)
114117
if err != nil {
115118
return nil, errWrap(err)

libbeat/autodiscover/providers/kubernetes/node.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ func NewNodeEventer(
6363
return nil, err
6464
}
6565

66+
// log warning about any unsupported params
67+
config.checkUnsupportedParams(logger)
68+
6669
// Ensure that node is set correctly whenever the scope is set to "node". Make sure that node is empty
6770
// when cluster scope is enforced.
6871
if config.Scope == "node" {

libbeat/autodiscover/providers/kubernetes/pod.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ func NewPodEventer(
7575
return nil, err
7676
}
7777

78+
// log warning about any unsupported params
79+
config.checkUnsupportedParams(logger)
80+
7881
// Ensure that node is set correctly whenever the scope is set to "node". Make sure that node is empty
7982
// when cluster scope is enforced.
8083
if config.Scope == "node" {

libbeat/autodiscover/providers/kubernetes/service.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ func NewServiceEventer(
6363
return nil, err
6464
}
6565

66+
// log warning about any unsupported params
67+
config.checkUnsupportedParams(logger)
68+
6669
watcher, err := kubernetes.NewNamedWatcher("service", client, &kubernetes.Service{}, kubernetes.WatchOptions{
6770
SyncTimeout: config.SyncPeriod,
6871
Namespace: config.Namespace,

libbeat/common/transport/transptest/testing.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func connectTCP(timeout time.Duration) TransportFactory {
171171
Proxy: proxy,
172172
Timeout: timeout,
173173
}
174-
return transport.NewClient(cfg, "tcp", addr, 0)
174+
return transport.NewClient(cfg, "tcp", addr, 0, logp.NewNopLogger())
175175
}
176176
}
177177

@@ -189,7 +189,7 @@ func connectTLS(timeout time.Duration, certName string) TransportFactory {
189189
TLS: tlsConfig,
190190
Timeout: timeout,
191191
}
192-
return transport.NewClient(cfg, "tcp", addr, 0)
192+
return transport.NewClient(cfg, "tcp", addr, 0, logp.NewNopLogger())
193193
}
194194
}
195195

0 commit comments

Comments
 (0)