Skip to content
3 changes: 3 additions & 0 deletions pkg/config/env/environment_container_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ const (
PodResources Feature = "podresources"
// NVML library present for GPU detection
NVML Feature = "nvml"
// NonstandardCRIRuntime is a fallback value for when customers supply a CRI compliant runtime via the
// cri_socket_path configuration field
NonstandardCRIRuntime = "nonstandard-cri-runtime"
)
6 changes: 5 additions & 1 deletion pkg/config/env/environment_containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func init() {
registerFeature(Podman)
registerFeature(PodResources)
registerFeature(NVML)
registerFeature(NonstandardCRIRuntime)
}

// IsAnyContainerFeaturePresent checks if any of known container features is present
Expand All @@ -65,7 +66,8 @@ func IsAnyContainerFeaturePresent() bool {
IsFeaturePresent(ECSManagedInstances) ||
IsFeaturePresent(EKSFargate) ||
IsFeaturePresent(CloudFoundry) ||
IsFeaturePresent(Podman)
IsFeaturePresent(Podman) ||
IsFeaturePresent(NonstandardCRIRuntime)
}

func detectContainerFeatures(features FeatureMap, cfg model.Reader) {
Expand Down Expand Up @@ -144,6 +146,8 @@ func detectCriRuntimes(features FeatureMap, cfg model.Reader) {
mergeContainerdNamespaces(cfg)
} else if strings.Contains(criSocket, "crio") {
features[Crio] = struct{}{}
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also want to apply the NonstandardCRIRuntime feature when the Docker feature is present? I think the code will currently apply both features when using the docker container runtime.

features[NonstandardCRIRuntime] = struct{}{}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/util/containers/metrics/cri/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ func newCRICollector(cache *provider.Cache) (provider.CollectorMetadata, error)
return provider.CollectorMetadata{
ID: collectorID,
Collectors: provider.CollectorCatalog{
provider.NewRuntimeMetadata(string(provider.RuntimeNameCRIO), ""): provider.MakeCached(collectorID, cache, collectors),
provider.NewRuntimeMetadata(string(provider.RuntimeNameCRIO), ""): provider.MakeCached(collectorID, cache, collectors),
provider.NewRuntimeMetadata(string(provider.RuntimeNameCRINonstandard), ""): provider.MakeCached(collectorID, cache, collectors),
},
}, nil
}
Expand Down
1 change: 1 addition & 0 deletions pkg/util/containers/metrics/kubelet/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func newKubeletCollector(_ *provider.Cache, wmeta workloadmeta.Component) (provi
provider.NewRuntimeMetadata(string(provider.RuntimeNameContainerd), string(provider.RuntimeFlavorKata)): collectors,
provider.NewRuntimeMetadata(string(provider.RuntimeNameCRIO), ""): collectors,
provider.NewRuntimeMetadata(string(provider.RuntimeNameDocker), ""): collectors,
provider.NewRuntimeMetadata(string(provider.RuntimeNameCRINonstandard), ""): collectors,
},
}, nil
}
Expand Down
18 changes: 18 additions & 0 deletions pkg/util/containers/metrics/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"sync"

workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
"github.com/DataDog/datadog-agent/pkg/config/env"
"github.com/DataDog/datadog-agent/pkg/util/log"
"github.com/DataDog/datadog-agent/pkg/util/option"
"github.com/DataDog/datadog-agent/pkg/util/retry"
)
Expand All @@ -30,6 +32,7 @@ const (
RuntimeNamePodman Runtime = "podman"
RuntimeNameECSFargate Runtime = "ecsfargate"
RuntimeNameECSManagedInstances Runtime = "ecsmanagedinstances"
RuntimeNameCRINonstandard Runtime = "cri-nonstandard"
)

var (
Expand Down Expand Up @@ -58,6 +61,7 @@ var (
RuntimeNamePodman,
RuntimeNameECSFargate,
RuntimeNameECSManagedInstances,
RuntimeNameCRINonstandard,
}

// AllWindowsRuntimes lists all runtimes available on Windows
Expand All @@ -67,7 +71,10 @@ var (
RuntimeNameContainerd,
RuntimeNameECSFargate,
RuntimeNameECSManagedInstances,
RuntimeNameCRINonstandard,
}

NonstandardMetadata = NewRuntimeMetadata(string(RuntimeNameCRINonstandard), "")
)

// RuntimeFlavor is a typed string for supported container runtime flavors
Expand Down Expand Up @@ -148,6 +155,17 @@ func (mp *GenericProvider) GetCollector(r RuntimeMetadata) Collector {
return runtime
}

// if the nonstandard runtime feature is present that means
// the user supplied a runtime socket that does not map to any of our known
// runtimes: containerd, cri-o
if env.IsFeaturePresent(env.NonstandardCRIRuntime) {
log.Debugf("Overriding collector runtime from %s to %s", r.String(), NonstandardMetadata.String())

if runtime, found := mp.collectors[NonstandardMetadata]; found {
return runtime
}
}

return nil
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Each section from every release note are combined when the
# CHANGELOG.rst is rendered. So the text needs to be worded so that
# it does not depend on any information only available in another
# section. This may mean repeating some details, but each section
# must be readable independently of the other.
#
# Each section note must be formatted as reStructuredText.
---
enhancements:
- |
Add container metric support for any CRI compliant runtime specified in
the `cri_socket_path` configuration.
Loading