Skip to content

Commit 6495466

Browse files
faecswiatekm
andauthored
Make data updates in add_host_metadata processor synchronous (#46645)
* Refactor add_host_metadata processor callback * go mod tidy * Use an atomic to avoid double updates * Do updates only synchronously * Add changelog entry * Fix CAS check and add test to verify * Ensure we let goroutines process data in the test * Refactor add_host_metadata to cache fqdn and non-fqdn cases separately * cleanup * add comment * fix tests --------- Co-authored-by: Mikołaj Świątek <[email protected]>
1 parent 49aa721 commit 6495466

File tree

6 files changed

+269
-206
lines changed

6 files changed

+269
-206
lines changed

CHANGELOG.next.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ otherwise no tag is added. {issue}42208[42208] {pull}42403[42403]
159159
- Update Go version to 1.24.7 {pull}46070[46070].
160160
- Update github.com/go-viper/mapstructure/v2 to v2.4.0 {pull}46335[46335]
161161
- Update github.com/docker/docker to v28.3.3 {pull}46334[46334]
162+
- Make data updates in add_host_metadata processor synchronous {pull}46546[46546]
162163

163164
*Auditbeat*
164165

NOTICE.txt

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14841,37 +14841,6 @@ Contents of probable licence file $GOMODCACHE/github.com/fearful-symmetry/gorapl
1484114841
limitations under the License.
1484214842

1484314843

14844-
--------------------------------------------------------------------------------
14845-
Dependency : github.com/foxcpp/go-mockdns
14846-
Version: v0.0.0-20201212160233-ede2f9158d15
14847-
Licence type (autodetected): MIT
14848-
--------------------------------------------------------------------------------
14849-
14850-
Contents of probable licence file $GOMODCACHE/github.com/foxcpp/[email protected]/LICENSE:
14851-
14852-
MIT License
14853-
14854-
Copyright © 2019 Max Mazurov <[email protected]>
14855-
14856-
Permission is hereby granted, free of charge, to any person obtaining a copy
14857-
of this software and associated documentation files (the "Software"), to deal
14858-
in the Software without restriction, including without limitation the rights
14859-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14860-
copies of the Software, and to permit persons to whom the Software is
14861-
furnished to do so, subject to the following conditions:
14862-
14863-
The above copyright notice and this permission notice shall be included in all
14864-
copies or substantial portions of the Software.
14865-
14866-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14867-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14868-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14869-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14870-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
14871-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
14872-
SOFTWARE.
14873-
14874-
1487514844
--------------------------------------------------------------------------------
1487614845
Dependency : github.com/elastic/fsevents
1487714846
Version: v0.0.0-20181029231046-e1d381a4d270

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ require (
185185
github.com/elastic/sarama v1.19.1-0.20250603175145-7672917f26b6
186186
github.com/elastic/tk-btf v0.2.0
187187
github.com/elastic/toutoumomoma v0.0.0-20240626215117-76e39db18dfb
188-
github.com/foxcpp/go-mockdns v0.0.0-20201212160233-ede2f9158d15
189188
github.com/go-ldap/ldap/v3 v3.4.6
190189
github.com/go-ole/go-ole v1.3.0
191190
github.com/go-resty/resty/v2 v2.16.5

go.sum

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,6 @@ github.com/foxboron/go-tpm-keyfiles v0.0.0-20250323135004-b31fac66206e h1:2jjYsG
461461
github.com/foxboron/go-tpm-keyfiles v0.0.0-20250323135004-b31fac66206e/go.mod h1:uAyTlAUxchYuiFjTHmuIEJ4nGSm7iOPaGcAyA81fJ80=
462462
github.com/foxboron/swtpm_test v0.0.0-20230726224112-46aaafdf7006 h1:50sW4r0PcvlpG4PV8tYh2RVCapszJgaOLRCS2subvV4=
463463
github.com/foxboron/swtpm_test v0.0.0-20230726224112-46aaafdf7006/go.mod h1:eIXCMsMYCaqq9m1KSSxXwQG11krpuNPGP3k0uaWrbas=
464-
github.com/foxcpp/go-mockdns v0.0.0-20201212160233-ede2f9158d15 h1:nLPjjvpUAODOR6vY/7o0hBIk8iTr19Fvmf8aFx/kC7A=
465-
github.com/foxcpp/go-mockdns v0.0.0-20201212160233-ede2f9158d15/go.mod h1:tPg4cp4nseejPd+UKxtCVQ2hUxNTZ7qQZJa7CLriIeo=
466464
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
467465
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
468466
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
@@ -770,7 +768,6 @@ github.com/microsoft/go-mssqldb v1.9.2 h1:nY8TmFMQOHpm2qVWo6y4I2mAmVdZqlGiMGAYt6
770768
github.com/microsoft/go-mssqldb v1.9.2/go.mod h1:GBbW9ASTiDC+mpgWDGKdm3FnFLTUsLYN3iFL90lQ+PA=
771769
github.com/microsoft/wmi v0.25.1 h1:sQv9hCEHtW5K6yEVL78T6XGRMGxk4aTpcJwCiB5rLN0=
772770
github.com/microsoft/wmi v0.25.1/go.mod h1:1zbdSF0A+5OwTUII5p3hN7/K6KF2m3o27pSG6Y51VU8=
773-
github.com/miekg/dns v1.1.22/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
774771
github.com/miekg/dns v1.1.66 h1:FeZXOS3VCVsKnEAd+wBkjMC3D2K+ww66Cq3VnCINuJE=
775772
github.com/miekg/dns v1.1.66/go.mod h1:jGFzBsSNbJw6z1HYut1RKBKHA9PBdxeHrZG8J+gC2WE=
776773
github.com/mileusna/useragent v1.3.5 h1:SJM5NzBmh/hO+4LGeATKpaEX9+b4vcGg2qXGLiNGDws=
@@ -1236,7 +1233,6 @@ go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
12361233
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
12371234
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
12381235
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
1239-
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
12401236
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
12411237
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
12421238
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
@@ -1276,7 +1272,6 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
12761272
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
12771273
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
12781274
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
1279-
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
12801275
golang.org/x/net v0.0.0-20191112182307-2180aed22343/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
12811276
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
12821277
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@@ -1324,8 +1319,6 @@ golang.org/x/sys v0.0.0-20190529164535-6a60838ec259/go.mod h1:h1NjWce9XRLGQEsW7w
13241319
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
13251320
golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
13261321
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1327-
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1328-
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
13291322
golang.org/x/sys v0.0.0-20191112214154-59a1497f0cea/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
13301323
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
13311324
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -1387,7 +1380,6 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3
13871380
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
13881381
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
13891382
golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
1390-
golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
13911383
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
13921384
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
13931385
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=

libbeat/processors/add_host_metadata/add_host_metadata.go

Lines changed: 72 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ import (
2323
"sync"
2424
"time"
2525

26-
"github.com/gofrs/uuid/v5"
27-
2826
"github.com/elastic/elastic-agent-libs/monitoring"
2927
"github.com/elastic/go-sysinfo"
28+
"github.com/elastic/go-sysinfo/types"
3029

3130
"github.com/elastic/beats/v7/libbeat/beat"
3231
"github.com/elastic/beats/v7/libbeat/features"
@@ -57,16 +56,28 @@ type metrics struct {
5756
FQDNLookupFailed *monitoring.Int
5857
}
5958

59+
// Interfaces to make mocking getting the hostname easier
60+
type hostInfo interface {
61+
Info() types.HostInfo
62+
FQDNWithContext(context.Context) (string, error)
63+
}
64+
65+
type hostInfoFactory func() (hostInfo, error)
66+
67+
type hostMetadataCache struct {
68+
sync.Mutex
69+
lastUpdate time.Time
70+
data mapstr.Pointer
71+
}
72+
6073
type addHostMetadata struct {
61-
lastUpdate struct {
62-
time.Time
63-
sync.Mutex
64-
}
65-
data mapstr.Pointer
66-
geoData mapstr.M
67-
config Config
68-
logger *logp.Logger
69-
metrics metrics
74+
// One cache for standard hostname, one for FQDN
75+
caches [2]hostMetadataCache
76+
geoData mapstr.M
77+
config Config
78+
logger *logp.Logger
79+
metrics metrics
80+
hostInfoFactory hostInfoFactory
7081
}
7182

7283
// New constructs a new add_host_metadata processor.
@@ -77,14 +88,19 @@ func New(cfg *config.C, log *logp.Logger) (beat.Processor, error) {
7788
}
7889

7990
p := &addHostMetadata{
91+
caches: [2]hostMetadataCache{
92+
{data: mapstr.NewPointer(nil)},
93+
{data: mapstr.NewPointer(nil)},
94+
},
8095
config: c,
81-
data: mapstr.NewPointer(nil),
8296
logger: log.Named(logName),
8397
metrics: metrics{
8498
FQDNLookupFailed: monitoring.NewInt(reg, "fqdn_lookup_failed"),
8599
},
100+
hostInfoFactory: func() (hostInfo, error) { return sysinfo.Host() },
86101
}
87-
if err := p.loadData(true, features.FQDN()); err != nil {
102+
// Fetch and cache the initial host data.
103+
if _, err := p.loadData(features.FQDN()); err != nil {
88104
return nil, fmt.Errorf("failed to load data: %w", err)
89105
}
90106

@@ -96,28 +112,6 @@ func New(cfg *config.C, log *logp.Logger) (beat.Processor, error) {
96112
p.geoData = mapstr.M{"host": mapstr.M{"geo": geoFields}}
97113
}
98114

99-
// create a unique ID for this instance of the processor
100-
var cbIDStr string
101-
cbID, err := uuid.NewV4()
102-
// if we fail, fall back to the processor name, hope for the best.
103-
if err != nil {
104-
p.logger.Errorf("error generating ID for FQDN callback, reverting to processor name: %v", err)
105-
cbIDStr = processorName
106-
} else {
107-
cbIDStr = cbID.String()
108-
}
109-
110-
// this is safe as New() returns a pointer, not the actual object.
111-
// This matters as other pieces of code in libbeat, like libbeat/processors/processor.go,
112-
// will do weird stuff like copy the entire list of global processors.
113-
err = features.AddFQDNOnChangeCallback(p.handleFQDNReportingChange, cbIDStr)
114-
if err != nil {
115-
return nil, fmt.Errorf(
116-
"could not register callback for FQDN reporting onChange from %s processor: %w",
117-
processorName, err,
118-
)
119-
}
120-
121115
return p, nil
122116
}
123117

@@ -128,12 +122,15 @@ func (p *addHostMetadata) Run(event *beat.Event) (*beat.Event, error) {
128122
return event, nil
129123
}
130124

131-
err := p.loadData(true, features.FQDN())
125+
data, err := p.loadData(features.FQDN())
132126
if err != nil {
133127
return nil, fmt.Errorf("error loading data during event update: %w", err)
134128
}
135129

136-
event.Fields.DeepUpdate(p.data.Get().Clone())
130+
// Superficially this clone seems unnecessary, but it seems to have been
131+
// applied as a fix a long time ago -- possibly there can be later processors
132+
// or changes to an event that would affect the cached data?
133+
event.Fields.DeepUpdate(data.Clone())
137134

138135
if len(p.geoData) > 0 {
139136
event.Fields.DeepUpdate(p.geoData)
@@ -150,34 +147,50 @@ func (p *addHostMetadata) Run(event *beat.Event) (*beat.Event, error) {
150147
// return nil
151148
//}
152149

153-
func (p *addHostMetadata) expired() bool {
154-
155-
p.lastUpdate.Lock()
156-
defer p.lastUpdate.Unlock()
157-
158-
if p.config.CacheTTL <= 0 {
159-
return true
150+
func (p *addHostMetadata) cacheForFQDN(useFQDN bool) *hostMetadataCache {
151+
if useFQDN {
152+
return &p.caches[1]
160153
}
154+
return &p.caches[0]
155+
}
161156

162-
if p.lastUpdate.Add(p.config.CacheTTL).After(time.Now()) {
163-
return false
157+
func timestampExpired(timestamp time.Time, ttl time.Duration) bool {
158+
if ttl <= 0 {
159+
return true
164160
}
165-
p.lastUpdate.Time = time.Now()
166-
return true
161+
return timestamp.Add(ttl).Before(time.Now())
167162
}
168163

169164
// loadData update's the processor's associated host metadata
170-
func (p *addHostMetadata) loadData(checkCache bool, useFQDN bool) error {
171-
if checkCache && !p.expired() {
172-
return nil
165+
func (p *addHostMetadata) loadData(useFQDN bool) (mapstr.M, error) {
166+
cache := p.cacheForFQDN(useFQDN)
167+
cache.Lock()
168+
defer cache.Unlock()
169+
170+
data := cache.data.Get()
171+
var err error
172+
if data == nil || timestampExpired(cache.lastUpdate, p.config.CacheTTL) {
173+
// Data is absent or expired, refresh it.
174+
data, err = p.fetchData(useFQDN)
175+
if err == nil {
176+
cache.data.Set(data)
177+
}
178+
// Backwards compatibility (for now): cache timestamp is updated even if
179+
// the update fails (falls back on the last successful update, and avoids
180+
// blocking the pipeline when there are issues with the hostname).
181+
cache.lastUpdate = time.Now()
173182
}
183+
return data, err
184+
}
174185

175-
h, err := sysinfo.Host()
186+
func (p *addHostMetadata) fetchData(useFQDN bool) (mapstr.M, error) {
187+
h, err := p.hostInfoFactory()
176188
if err != nil {
177-
return fmt.Errorf("error collecting host info: %w", err)
189+
return nil, fmt.Errorf("error collecting host info: %w", err)
178190
}
179191

180-
hostname := h.Info().Hostname
192+
hInfo := h.Info()
193+
hostname := hInfo.Hostname
181194
if useFQDN {
182195
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
183196
defer cancel()
@@ -198,7 +211,7 @@ func (p *addHostMetadata) loadData(checkCache bool, useFQDN bool) error {
198211
}
199212
}
200213

201-
data := host.MapHostInfo(h.Info(), hostname)
214+
data := host.MapHostInfo(hInfo, hostname)
202215
if p.config.NetInfoEnabled {
203216
// IP-address and MAC-address
204217
var ipList, hwList, err = util.GetNetInfo()
@@ -208,85 +221,30 @@ func (p *addHostMetadata) loadData(checkCache bool, useFQDN bool) error {
208221

209222
if len(ipList) > 0 {
210223
if _, err := data.Put("host.ip", ipList); err != nil {
211-
return fmt.Errorf("could not set host.ip: %w", err)
224+
return nil, fmt.Errorf("could not set host.ip: %w", err)
212225
}
213226
}
214227
if len(hwList) > 0 {
215228
if _, err := data.Put("host.mac", hwList); err != nil {
216-
return fmt.Errorf("could not set host.mac: %w", err)
229+
return nil, fmt.Errorf("could not set host.mac: %w", err)
217230
}
218231
}
219232
}
220233

221234
if p.config.Name != "" {
222235
if _, err := data.Put("host.name", p.config.Name); err != nil {
223-
return fmt.Errorf("could not set host.name: %w", err)
236+
return nil, fmt.Errorf("could not set host.name: %w", err)
224237
}
225238
}
226239

227-
p.data.Set(data)
228-
return nil
240+
return data, nil
229241
}
230242

231243
func (p *addHostMetadata) String() string {
232244
return fmt.Sprintf("%v=[netinfo.enabled=[%v], cache.ttl=[%v]]",
233245
processorName, p.config.NetInfoEnabled, p.config.CacheTTL)
234246
}
235247

236-
func (p *addHostMetadata) handleFQDNReportingChange(new, old bool) {
237-
if new == old {
238-
// Nothing to do
239-
return
240-
}
241-
242-
// update the data for the processor
243-
p.updateOrExpire(new)
244-
}
245-
246-
// updateOrExpire will attempt to update the data for the processor, or expire the cache
247-
// if the config update fails, or times out
248-
func (p *addHostMetadata) updateOrExpire(useFQDN bool) {
249-
if p.config.CacheTTL <= 0 {
250-
return
251-
}
252-
253-
p.lastUpdate.Lock()
254-
defer p.lastUpdate.Unlock()
255-
256-
// while holding the mutex, attempt to update loadData()
257-
// doing this with the mutex means other events must wait until we have the correct host data, as we assume that
258-
// a call to this function means something else wants to force an update, and thus all events must sync.
259-
260-
updateChanSuccess := make(chan bool)
261-
timeout := time.After(p.config.ExpireUpdateTimeout)
262-
go func() {
263-
err := p.loadData(false, useFQDN)
264-
if err != nil {
265-
p.logger.Errorf("error updating data for processor: %v", err)
266-
updateChanSuccess <- false
267-
return
268-
}
269-
updateChanSuccess <- true
270-
}()
271-
272-
// this additional timeout check is paranoid, but when it's method is called from handleFQDNReportingChange(),
273-
// it's blocking, which means we can hold a mutex in features. In addition, we don't want to break the processor by
274-
// having all the events wait for too long.
275-
select {
276-
case <-timeout:
277-
p.logger.Errorf("got timeout while trying to update metadata")
278-
p.lastUpdate.Time = time.Time{}
279-
case success := <-updateChanSuccess:
280-
// only expire the cache if update was failed
281-
if !success {
282-
p.lastUpdate.Time = time.Time{}
283-
} else {
284-
p.lastUpdate.Time = time.Now()
285-
}
286-
}
287-
288-
}
289-
290248
func skipAddingHostMetadata(event *beat.Event) bool {
291249
// If host fields exist(besides host.name added by libbeat) in event, skip add_host_metadata.
292250
hostFields, err := event.Fields.GetValue("host")

0 commit comments

Comments
 (0)