Skip to content

Commit

Permalink
Refactor: Moved windows to const
Browse files Browse the repository at this point in the history
Removed completed todos
  • Loading branch information
KlwntSingh committed Feb 29, 2024
1 parent d6d3176 commit b4ccbb2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions internal/aws/containerinsight/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
SourcesKey = "Sources"
Timestamp = "Timestamp"
OperatingSystem = "OperatingSystem"
OperatingSystemWindows = "windows"

// The following constants are used for metric name construction
CPUTotal = "cpu_usage_total"
Expand Down
2 changes: 1 addition & 1 deletion internal/aws/containerinsight/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func IsPod(mType string) bool {
func IsWindowsHostProcessContainer() bool {
// todo: Remove this workaround func when Windows AMIs has containerd 1.7 which solves upstream bug
// https://kubernetes.io/docs/tasks/configure-pod-container/create-hostprocess-pod/#containerd-v1-6
if runtime.GOOS == "windows" && os.Getenv(RunInContainer) == TrueValue && os.Getenv(RunAsHostProcessContainer) == TrueValue {
if runtime.GOOS == OperatingSystemWindows && os.Getenv(RunInContainer) == TrueValue && os.Getenv(RunAsHostProcessContainer) == TrueValue {
return true
}
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
"go.uber.org/zap"

ci "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/containerinsight"
)

var ebsMountPointRegex = regexp.MustCompile(`kubernetes\.io/aws-ebs/mounts/aws/(.+)/(vol-\w+)$`)
Expand Down Expand Up @@ -145,7 +147,7 @@ func (e *ebsVolume) findNvmeBlockNameIfPresent(devName string) string {

// Windows does not support file system eg: /rootfs to get Nvme Block name.
// todo: Implement logic to identify Nvme devices on Windows. Refer https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/nvme-ebs-volumes.html#identify-nvme-ebs-device
if runtime.GOOS == "windows" {
if runtime.GOOS == ci.OperatingSystemWindows {
return ""
}
hasRootFs := true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/shirou/gopsutil/v3/cpu"
"github.com/shirou/gopsutil/v3/mem"
"go.uber.org/zap"

ci "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/containerinsight"
)

type nodeCapacityProvider interface {
Expand Down Expand Up @@ -48,7 +50,7 @@ func newNodeCapacity(logger *zap.Logger, options ...nodeCapacityOption) (nodeCap
}

ctx := context.Background()
if runtime.GOOS != "windows" {
if runtime.GOOS != ci.OperatingSystemWindows {
if _, err := nc.osLstat(hostProc); os.IsNotExist(err) {
return nil, err
}
Expand All @@ -71,7 +73,7 @@ func (nc *nodeCapacity) parseMemory(ctx context.Context) {
}

func (nc *nodeCapacity) parseCPU(ctx context.Context) {
if runtime.GOOS == "windows" {
if runtime.GOOS == ci.OperatingSystemWindows {
nc.parseCPUWindows(ctx)
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ func (sp *SummaryProvider) getContainerMetrics(pod stats.PodStats) ([]*cExtracto

// getPodMetrics returns pod and container level metrics from kubelet summary.
func (sp *SummaryProvider) getPodMetrics(summary *stats.Summary) ([]*cExtractor.CAdvisorMetric, error) {
// todo: This is not complete implementation of pod level metric collection since network level metrics are pending
// May need to add some more pod level labels for store decorators to work properly
var metrics []*cExtractor.CAdvisorMetric

if summary == nil {
Expand Down
3 changes: 1 addition & 2 deletions receiver/awscontainerinsightreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ func (acir *awsContainerInsightReceiver) Start(ctx context.Context, host compone
return err
}

// todo: will need to use k8sAPIServer to add stats about enhanced CI.
if runtime.GOOS == "windows" {
if runtime.GOOS == ci.OperatingSystemWindows {
acir.containerMetricsProvider, err = k8swindows.New(acir.settings.Logger, k8sDecorator, *hostinfo)
if err != nil {
return err
Expand Down

0 comments on commit b4ccbb2

Please sign in to comment.