Skip to content

Commit

Permalink
Fix V2 loggers nil deref (#33770)
Browse files Browse the repository at this point in the history
* update elastic-agent-client

* fix nil pointer in V2 log statements

* change log lines
  • Loading branch information
fearful-symmetry authored Nov 22, 2022
1 parent 01430a4 commit 6fbbf24
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions x-pack/libbeat/management/managerV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,12 @@ func (cm *BeatV2Manager) Stop() {
}

// CheckRawConfig is currently not implemented for V1.
func (cm *BeatV2Manager) CheckRawConfig(cfg *conf.C) error {
func (cm *BeatV2Manager) CheckRawConfig(_ *conf.C) error {
// This does not do anything on V1 or V2, but here we are
return nil
}

// RegisterAction adds a V2 client action
func (cm *BeatV2Manager) RegisterAction(action client.Action) {
cm.unitsMut.Lock()
defer cm.unitsMut.Unlock()
Expand All @@ -158,6 +159,7 @@ func (cm *BeatV2Manager) RegisterAction(action client.Action) {
}
}

// UnregisterAction removes a V2 client action
func (cm *BeatV2Manager) UnregisterAction(action client.Action) {
cm.unitsMut.Lock()
defer cm.unitsMut.Unlock()
Expand All @@ -170,6 +172,7 @@ func (cm *BeatV2Manager) UnregisterAction(action client.Action) {
}
}

// SetPayload sets the global payload for the V2 client
func (cm *BeatV2Manager) SetPayload(payload map[string]interface{}) {
cm.payload = payload
}
Expand Down Expand Up @@ -319,7 +322,7 @@ func (cm *BeatV2Manager) handleUnitReload(unit *client.Unit) {
// Handle the updated config for an output unit
func (cm *BeatV2Manager) handleOutputReload(unit *client.Unit) {
_, _, rawConfig := unit.Expected()
cm.logger.Debugf("Got Output unit config: %s, ID: %s", rawConfig.Type, rawConfig.Id)
cm.logger.Debugf("Got Output unit config %s", rawConfig.GetId())

reloadConfig, err := groupByOutputs(rawConfig)
if err != nil {
Expand Down Expand Up @@ -348,7 +351,7 @@ func (cm *BeatV2Manager) handleOutputReload(unit *client.Unit) {
func (cm *BeatV2Manager) handleInputReload(unit *client.Unit) {
_, _, rawConfig := unit.Expected()
cm.setMainUnitValue(unit)
cm.logger.Debugf("Got Input unit config: %s, ID: %s", rawConfig.Type, rawConfig.Id)
cm.logger.Debugf("Got Input unit config %s", rawConfig.GetId())

// Find the V2 inputs we need to reload
// The reloader provides list and non-list types, but all the beats register as lists,
Expand Down

0 comments on commit 6fbbf24

Please sign in to comment.