Skip to content

Commit

Permalink
[ASCII-1277] Remove sub packages from pkg/status. All agents now use …
Browse files Browse the repository at this point in the history
…the status component (#23525)

* Remove subpackages from pkg/status. All agents now use the status component

* fix lint issue with unused function

* fix test
  • Loading branch information
GustavoCaso authored and julien-lebot committed Mar 11, 2024
1 parent 7cf5362 commit a6d1d50
Show file tree
Hide file tree
Showing 54 changed files with 9 additions and 8,548 deletions.
9 changes: 1 addition & 8 deletions cmd/agent/subcommands/run/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ import (
"github.com/DataDog/datadog-agent/pkg/status/health"
httpproxyStatus "github.com/DataDog/datadog-agent/pkg/status/httpproxy"
jmxStatus "github.com/DataDog/datadog-agent/pkg/status/jmx"
otlpStatus "github.com/DataDog/datadog-agent/pkg/status/otlp"
systemprobeStatus "github.com/DataDog/datadog-agent/pkg/status/systemprobe"
pkgTelemetry "github.com/DataDog/datadog-agent/pkg/telemetry"
"github.com/DataDog/datadog-agent/pkg/util"
Expand Down Expand Up @@ -614,13 +613,7 @@ func startAgent(
// start dependent services
go startDependentServices()

if err := otelcollector.Start(); err != nil {
return err
}
// TODO: (components) remove this once migrating the status package to components
otlpStatus.SetOtelCollector(otelcollector)

return nil
return otelcollector.Start()
}

// StopAgentWithDefaults is a temporary way for other packages to use stopAgent.
Expand Down
9 changes: 6 additions & 3 deletions pkg/flare/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/DataDog/datadog-agent/pkg/diagnose"
"github.com/DataDog/datadog-agent/pkg/diagnose/diagnosis"
"github.com/DataDog/datadog-agent/pkg/status/health"
processagentStatus "github.com/DataDog/datadog-agent/pkg/status/processagent"
systemprobeStatus "github.com/DataDog/datadog-agent/pkg/status/systemprobe"
"github.com/DataDog/datadog-agent/pkg/util/installinfo"
"github.com/DataDog/datadog-agent/pkg/util/log"
Expand Down Expand Up @@ -199,8 +198,12 @@ func getProcessAgentFullConfig() ([]byte, error) {

procStatusURL := fmt.Sprintf("http://%s/config/all", addressPort)

cfgB := processagentStatus.GetRuntimeConfig(procStatusURL)
return cfgB, nil
bytes, err := getHTTPCallContent(procStatusURL)

if err != nil {
return []byte("error: process-agent is not running or is unreachable\n"), nil
}
return bytes, nil
}

func getConfigFiles(fb flaretypes.FlareBuilder, confSearchPaths map[string]string) {
Expand Down
29 changes: 0 additions & 29 deletions pkg/status/aggregator/aggregator.go

This file was deleted.

59 changes: 0 additions & 59 deletions pkg/status/apm/apm.go

This file was deleted.

109 changes: 0 additions & 109 deletions pkg/status/clusteragent/clusteragent.go

This file was deleted.

21 changes: 1 addition & 20 deletions pkg/status/clusteragent/status_apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,18 @@

//go:build kubeapiserver

// Package clusteragent fetch information about the cluster agent
package clusteragent

import (
"embed"
"fmt"
"io"
"time"

"github.com/DataDog/datadog-agent/comp/core/config"
"github.com/DataDog/datadog-agent/comp/core/status"
"github.com/DataDog/datadog-agent/pkg/util/clusteragent"
"github.com/DataDog/datadog-agent/pkg/util/kubernetes/apiserver/leaderelection"
)

func getLeaderElectionDetails() map[string]string {
leaderElectionStats := make(map[string]string)

record, err := leaderelection.GetLeaderElectionRecord()
if err != nil {
leaderElectionStats["status"] = "Failing"
leaderElectionStats["error"] = err.Error()
return leaderElectionStats
}
leaderElectionStats["leaderName"] = record.HolderIdentity
leaderElectionStats["acquiredTime"] = record.AcquireTime.Format(time.RFC1123)
leaderElectionStats["renewedTime"] = record.RenewTime.Format(time.RFC1123)
leaderElectionStats["transitions"] = fmt.Sprintf("%d transitions", record.LeaderTransitions)
leaderElectionStats["status"] = "Running"
return leaderElectionStats
}

// GetDCAStatus collect the DCA agent information and return it in a map
func GetDCAStatus(stats map[string]interface{}) {
clusterAgentDetails := make(map[string]string)
Expand Down
6 changes: 1 addition & 5 deletions pkg/status/clusteragent/status_no_apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

//go:build !kubeapiserver

// Package clusteragent fetch information about the cluster agent
package clusteragent

import (
Expand All @@ -13,11 +14,6 @@ import (
"github.com/DataDog/datadog-agent/pkg/util/log"
)

func getLeaderElectionDetails() map[string]string {
log.Info("Not implemented")
return nil
}

// GetDCAStatus empty function for agents not running in a k8s environment
func GetDCAStatus(_ map[string]interface{}) {
log.Info("Not implemented")
Expand Down
79 changes: 0 additions & 79 deletions pkg/status/common/common.go

This file was deleted.

Loading

0 comments on commit a6d1d50

Please sign in to comment.