Skip to content

Commit

Permalink
PMM-5086 Fix Node nil handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriCtvrtka committed Dec 3, 2024
1 parent 26d6f8b commit e57bbc9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
3 changes: 0 additions & 3 deletions managed/services/agents/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ var (

func nodeExporterConfig(node *models.Node, exporter *models.Agent, agentVersion *version.Parsed) (*agentv1.SetStateRequest_AgentProcess, error) {
listenAddress := getExporterListenAddress(node, exporter)
if exporter.ExporterOptions == nil {
exporter.ExporterOptions = &models.ExporterOptions{}
}
tdp := models.TemplateDelimsPair(pointer.GetString(exporter.ExporterOptions.MetricsPath))
args := []string{
"--collector.textfile.directory.lr=" + pathsBase(agentVersion, tdp.Left, tdp.Right) + "/collectors/textfile-collector/low-resolution",
Expand Down
25 changes: 15 additions & 10 deletions managed/services/agents/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ func TestAuthWebConfig(t *testing.T) {

node := &models.Node{}
exporter := &models.Agent{
AgentID: "agent-id",
AgentType: models.NodeExporterType,
AgentID: "agent-id",
AgentType: models.NodeExporterType,
ExporterOptions: &models.ExporterOptions{},
}
agentVersion := version.MustParse("2.26.1")

Expand All @@ -58,8 +59,9 @@ func TestAuthWebConfig(t *testing.T) {

node := &models.Node{}
exporter := &models.Agent{
AgentID: "agent-id",
AgentType: models.NodeExporterType,
AgentID: "agent-id",
AgentType: models.NodeExporterType,
ExporterOptions: &models.ExporterOptions{},
}
agentVersion := version.MustParse("2.28.0")

Expand All @@ -83,8 +85,9 @@ func TestAuthWebConfig(t *testing.T) {

node := &models.Node{}
exporter := &models.Agent{
AgentID: "agent-id",
AgentType: models.NodeExporterType,
AgentID: "agent-id",
AgentType: models.NodeExporterType,
ExporterOptions: &models.ExporterOptions{},
}
agentVersion := version.MustParse("3.0.0")

Expand Down Expand Up @@ -114,8 +117,9 @@ func TestNodeExporterConfig(t *testing.T) {
Address: "1.2.3.4",
}
exporter := &models.Agent{
AgentID: "agent-id",
AgentType: models.NodeExporterType,
AgentID: "agent-id",
AgentType: models.NodeExporterType,
ExporterOptions: &models.ExporterOptions{},
}
agentVersion := version.MustParse("2.15.1")

Expand Down Expand Up @@ -293,8 +297,9 @@ func TestNodeExporterConfig(t *testing.T) {
Distro: "darwin",
}
exporter := &models.Agent{
AgentID: "agent-id",
AgentType: models.NodeExporterType,
AgentID: "agent-id",
AgentType: models.NodeExporterType,
ExporterOptions: &models.ExporterOptions{},
}
agentVersion := version.MustParse("2.15.1")

Expand Down

0 comments on commit e57bbc9

Please sign in to comment.