Skip to content

Commit

Permalink
fix: opamp server: do not panic if config generation fails (#4307)
Browse files Browse the repository at this point in the history
  • Loading branch information
raj-k-singh authored Dec 29, 2023
1 parent 86ff865 commit fd9a502
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/query-service/app/opamp/model/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"crypto/sha256"
"fmt"
"sync"
"time"

Expand Down Expand Up @@ -259,7 +258,7 @@ func (agent *Agent) processStatusUpdate(
// If remote config is changed and different from what the Agent has then
// send the new remote config to the Agent.
if configChanged ||
(agent.Status.RemoteConfigStatus != nil &&
(agent.Status.RemoteConfigStatus != nil && agent.remoteConfig != nil &&
!bytes.Equal(agent.Status.RemoteConfigStatus.LastRemoteConfigHash, agent.remoteConfig.ConfigHash)) {
// The new status resulted in a change in the config of the Agent or the Agent
// does not have this config (hash is different). Send the new config the Agent.
Expand All @@ -277,8 +276,8 @@ func (agent *Agent) processStatusUpdate(
func (agent *Agent) updateRemoteConfig(configProvider AgentConfigProvider) bool {
recommendedConfig, confId, err := configProvider.RecommendAgentConfig([]byte(agent.EffectiveConfig))
if err != nil {
// The server must always recommend a config.
panic(fmt.Errorf("could not generate config recommendation for agent %s: %w", agent.ID, err))
zap.S().Error("could not generate config recommendation for agent:", agent.ID, err)
return false
}

cfg := protobufs.AgentRemoteConfig{
Expand Down

0 comments on commit fd9a502

Please sign in to comment.