mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-16 21:38:23 +00:00
pkg/utils: move hostpath helpers from source to utils
Refactor the code, moving the hostpath helper functionality to new "pkg/utils/hostpath" package. This breaks odd-ish dependency "pkg/utils" -> "source".
This commit is contained in:
parent
4097198848
commit
a00cdc2b61
18 changed files with 47 additions and 41 deletions
2
Makefile
2
Makefile
|
@ -55,7 +55,7 @@ KUBECONFIG ?=
|
||||||
E2E_TEST_CONFIG ?=
|
E2E_TEST_CONFIG ?=
|
||||||
E2E_PULL_IF_NOT_PRESENT ?= false
|
E2E_PULL_IF_NOT_PRESENT ?= false
|
||||||
|
|
||||||
LDFLAGS = -ldflags "-s -w -X sigs.k8s.io/node-feature-discovery/pkg/version.version=$(VERSION) -X sigs.k8s.io/node-feature-discovery/source.pathPrefix=$(HOSTMOUNT_PREFIX)"
|
LDFLAGS = -ldflags "-s -w -X sigs.k8s.io/node-feature-discovery/pkg/version.version=$(VERSION) -X sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath.pathPrefix=$(HOSTMOUNT_PREFIX)"
|
||||||
|
|
||||||
# multi-arch build with buildx
|
# multi-arch build with buildx
|
||||||
IMAGE_ALL_PLATFORMS ?= linux/amd64,linux/arm64
|
IMAGE_ALL_PLATFORMS ?= linux/amd64,linux/arm64
|
||||||
|
|
|
@ -29,8 +29,8 @@ import (
|
||||||
"sigs.k8s.io/node-feature-discovery/pkg/resourcemonitor"
|
"sigs.k8s.io/node-feature-discovery/pkg/resourcemonitor"
|
||||||
"sigs.k8s.io/node-feature-discovery/pkg/topologypolicy"
|
"sigs.k8s.io/node-feature-discovery/pkg/topologypolicy"
|
||||||
"sigs.k8s.io/node-feature-discovery/pkg/utils"
|
"sigs.k8s.io/node-feature-discovery/pkg/utils"
|
||||||
|
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
|
||||||
"sigs.k8s.io/node-feature-discovery/pkg/version"
|
"sigs.k8s.io/node-feature-discovery/pkg/version"
|
||||||
"sigs.k8s.io/node-feature-discovery/source"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -109,9 +109,9 @@ func initFlags(flagset *flag.FlagSet) (*topology.Args, *resourcemonitor.Args) {
|
||||||
"Time to sleep between CR updates. Non-positive value implies no CR updatation (i.e. infinite sleep). [Default: 60s]")
|
"Time to sleep between CR updates. Non-positive value implies no CR updatation (i.e. infinite sleep). [Default: 60s]")
|
||||||
flagset.StringVar(&resourcemonitorArgs.Namespace, "watch-namespace", "*",
|
flagset.StringVar(&resourcemonitorArgs.Namespace, "watch-namespace", "*",
|
||||||
"Namespace to watch pods (for testing/debugging purpose). Use * for all namespaces.")
|
"Namespace to watch pods (for testing/debugging purpose). Use * for all namespaces.")
|
||||||
flagset.StringVar(&resourcemonitorArgs.KubeletConfigFile, "kubelet-config-file", source.VarDir.Path("lib/kubelet/config.yaml"),
|
flagset.StringVar(&resourcemonitorArgs.KubeletConfigFile, "kubelet-config-file", hostpath.VarDir.Path("lib/kubelet/config.yaml"),
|
||||||
"Kubelet config file path.")
|
"Kubelet config file path.")
|
||||||
flagset.StringVar(&resourcemonitorArgs.PodResourceSocketPath, "podresources-socket", source.VarDir.Path("lib/kubelet/pod-resources/kubelet.sock"),
|
flagset.StringVar(&resourcemonitorArgs.PodResourceSocketPath, "podresources-socket", hostpath.VarDir.Path("lib/kubelet/pod-resources/kubelet.sock"),
|
||||||
"Pod Resource Socket path to use.")
|
"Pod Resource Socket path to use.")
|
||||||
flagset.StringVar(&args.Server, "server", "localhost:8080",
|
flagset.StringVar(&args.Server, "server", "localhost:8080",
|
||||||
"NFD server address to connecto to.")
|
"NFD server address to connecto to.")
|
||||||
|
|
|
@ -31,7 +31,7 @@ import (
|
||||||
podresourcesapi "k8s.io/kubelet/pkg/apis/podresources/v1"
|
podresourcesapi "k8s.io/kubelet/pkg/apis/podresources/v1"
|
||||||
|
|
||||||
"sigs.k8s.io/node-feature-discovery/pkg/utils"
|
"sigs.k8s.io/node-feature-discovery/pkg/utils"
|
||||||
"sigs.k8s.io/node-feature-discovery/source"
|
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -58,7 +58,7 @@ func NewResourcesAggregator(podResourceClient podresourcesapi.PodResourcesLister
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
topo, err := ghw.Topology(ghw.WithPathOverrides(ghw.PathOverrides{
|
topo, err := ghw.Topology(ghw.WithPathOverrides(ghw.PathOverrides{
|
||||||
"/sys": string(source.SysfsDir),
|
"/sys": string(hostpath.SysfsDir),
|
||||||
}))
|
}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package source
|
package hostpath
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
|
@ -28,11 +28,11 @@ import (
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
resourcehelper "k8s.io/kubernetes/pkg/apis/core/helper"
|
resourcehelper "k8s.io/kubernetes/pkg/apis/core/helper"
|
||||||
|
|
||||||
"sigs.k8s.io/node-feature-discovery/source"
|
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
sysBusNodeBasepath = source.SysfsDir.Path("bus/node/devices")
|
sysBusNodeBasepath = hostpath.SysfsDir.Path("bus/node/devices")
|
||||||
)
|
)
|
||||||
|
|
||||||
// NumaMemoryResources contains information of the memory resources per NUMA
|
// NumaMemoryResources contains information of the memory resources per NUMA
|
||||||
|
|
|
@ -26,6 +26,7 @@ import (
|
||||||
|
|
||||||
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
|
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
|
||||||
"sigs.k8s.io/node-feature-discovery/pkg/utils"
|
"sigs.k8s.io/node-feature-discovery/pkg/utils"
|
||||||
|
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
|
||||||
"sigs.k8s.io/node-feature-discovery/source"
|
"sigs.k8s.io/node-feature-discovery/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -282,14 +283,14 @@ func discoverTopology() map[string]string {
|
||||||
// Check if any (online) CPUs have thread siblings
|
// Check if any (online) CPUs have thread siblings
|
||||||
func haveThreadSiblings() (bool, error) {
|
func haveThreadSiblings() (bool, error) {
|
||||||
|
|
||||||
files, err := os.ReadDir(source.SysfsDir.Path("bus/cpu/devices"))
|
files, err := os.ReadDir(hostpath.SysfsDir.Path("bus/cpu/devices"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
// Try to read siblings from topology
|
// Try to read siblings from topology
|
||||||
siblings, err := os.ReadFile(source.SysfsDir.Path("bus/cpu/devices", file.Name(), "topology/thread_siblings_list"))
|
siblings, err := os.ReadFile(hostpath.SysfsDir.Path("bus/cpu/devices", file.Name(), "topology/thread_siblings_list"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import (
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
|
||||||
"sigs.k8s.io/node-feature-discovery/source"
|
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Discover if c-states are enabled
|
// Discover if c-states are enabled
|
||||||
|
@ -33,7 +33,7 @@ func detectCstate() (map[string]string, error) {
|
||||||
cstate := make(map[string]string)
|
cstate := make(map[string]string)
|
||||||
|
|
||||||
// Check that sysfs is available
|
// Check that sysfs is available
|
||||||
sysfsBase := source.SysfsDir.Path("devices/system/cpu")
|
sysfsBase := hostpath.SysfsDir.Path("devices/system/cpu")
|
||||||
if _, err := os.Stat(sysfsBase); err != nil {
|
if _, err := os.Stat(sysfsBase); err != nil {
|
||||||
return cstate, fmt.Errorf("unable to detect cstate status: %w", err)
|
return cstate, fmt.Errorf("unable to detect cstate status: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ func detectCstate() (map[string]string, error) {
|
||||||
return cstate, nil
|
return cstate, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := os.ReadFile(source.SysfsDir.Path("module/intel_idle/parameters/max_cstate"))
|
data, err := os.ReadFile(hostpath.SysfsDir.Path("module/intel_idle/parameters/max_cstate"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cstate, fmt.Errorf("cannot determine cstate from max_cstates: %w", err)
|
return cstate, fmt.Errorf("cannot determine cstate from max_cstates: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import (
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
|
||||||
"sigs.k8s.io/node-feature-discovery/pkg/cpuid"
|
"sigs.k8s.io/node-feature-discovery/pkg/cpuid"
|
||||||
"sigs.k8s.io/node-feature-discovery/source"
|
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -51,14 +51,14 @@ func discoverSSTBF() (bool, error) {
|
||||||
nominalBaseFrequency := int(freqInfo.EAX)
|
nominalBaseFrequency := int(freqInfo.EAX)
|
||||||
|
|
||||||
// Loop over all CPUs in the system
|
// Loop over all CPUs in the system
|
||||||
files, err := os.ReadDir(source.SysfsDir.Path("bus/cpu/devices"))
|
files, err := os.ReadDir(hostpath.SysfsDir.Path("bus/cpu/devices"))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
// Try to read effective base frequency of each cpu in the system
|
// Try to read effective base frequency of each cpu in the system
|
||||||
filePath := source.SysfsDir.Path("bus/cpu/devices", file.Name(), "cpufreq/base_frequency")
|
filePath := hostpath.SysfsDir.Path("bus/cpu/devices", file.Name(), "cpufreq/base_frequency")
|
||||||
data, err := os.ReadFile(filePath)
|
data, err := os.ReadFile(filePath)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
// Ignore missing file and continue to check other CPUs
|
// Ignore missing file and continue to check other CPUs
|
||||||
|
|
|
@ -24,13 +24,13 @@ import (
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
|
||||||
"sigs.k8s.io/node-feature-discovery/source"
|
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Discover p-state related features such as turbo boost.
|
// Discover p-state related features such as turbo boost.
|
||||||
func detectPstate() (map[string]string, error) {
|
func detectPstate() (map[string]string, error) {
|
||||||
// Check that sysfs is available
|
// Check that sysfs is available
|
||||||
sysfsBase := source.SysfsDir.Path("devices/system/cpu")
|
sysfsBase := hostpath.SysfsDir.Path("devices/system/cpu")
|
||||||
if _, err := os.Stat(sysfsBase); err != nil {
|
if _, err := os.Stat(sysfsBase); err != nil {
|
||||||
return nil, fmt.Errorf("unable to detect pstate status: %w", err)
|
return nil, fmt.Errorf("unable to detect pstate status: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/klauspost/cpuid/v2"
|
"github.com/klauspost/cpuid/v2"
|
||||||
"sigs.k8s.io/node-feature-discovery/source"
|
|
||||||
|
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
|
||||||
)
|
)
|
||||||
|
|
||||||
func discoverSecurity() map[string]string {
|
func discoverSecurity() map[string]string {
|
||||||
|
@ -64,7 +65,7 @@ func tdxEnabled() bool {
|
||||||
// If /sys/module/kvm_intel/parameters/tdx is not present, or is present
|
// If /sys/module/kvm_intel/parameters/tdx is not present, or is present
|
||||||
// with a value different than "Y\n" assume TDX to be unavailable or
|
// with a value different than "Y\n" assume TDX to be unavailable or
|
||||||
// disabled.
|
// disabled.
|
||||||
protVirtHost := source.SysfsDir.Path("module/kvm_intel/parameters/tdx")
|
protVirtHost := hostpath.SysfsDir.Path("module/kvm_intel/parameters/tdx")
|
||||||
if content, err := os.ReadFile(protVirtHost); err == nil {
|
if content, err := os.ReadFile(protVirtHost); err == nil {
|
||||||
if string(content) == "Y\n" {
|
if string(content) == "Y\n" {
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -22,7 +22,7 @@ package cpu
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"sigs.k8s.io/node-feature-discovery/source"
|
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
|
||||||
)
|
)
|
||||||
|
|
||||||
func discoverSecurity() map[string]string {
|
func discoverSecurity() map[string]string {
|
||||||
|
@ -39,7 +39,7 @@ func seEnabled() bool {
|
||||||
// This file is available in kernels >=5.12 + backports. Skip specifically
|
// This file is available in kernels >=5.12 + backports. Skip specifically
|
||||||
// checking facilities and kernel command lines and just assume Secure
|
// checking facilities and kernel command lines and just assume Secure
|
||||||
// Execution to be unavailable or disabled if the file is not present.
|
// Execution to be unavailable or disabled if the file is not present.
|
||||||
protVirtHost := source.SysfsDir.Path("firmware/uv/prot_virt_host")
|
protVirtHost := hostpath.SysfsDir.Path("firmware/uv/prot_virt_host")
|
||||||
if content, err := os.ReadFile(protVirtHost); err == nil {
|
if content, err := os.ReadFile(protVirtHost); err == nil {
|
||||||
if string(content) == "1\n" {
|
if string(content) == "1\n" {
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -25,7 +25,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"sigs.k8s.io/node-feature-discovery/source"
|
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Read gzipped kernel config
|
// Read gzipped kernel config
|
||||||
|
@ -63,21 +63,21 @@ func parseKconfig(configPath string) (realKconfig, legacyKconfig map[string]stri
|
||||||
if err != nil {
|
if err != nil {
|
||||||
searchPaths = []string{
|
searchPaths = []string{
|
||||||
"/proc/config.gz",
|
"/proc/config.gz",
|
||||||
source.UsrDir.Path("src/linux/.config"),
|
hostpath.UsrDir.Path("src/linux/.config"),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// from k8s.io/system-validator used by kubeadm
|
// from k8s.io/system-validator used by kubeadm
|
||||||
// preflight checks
|
// preflight checks
|
||||||
searchPaths = []string{
|
searchPaths = []string{
|
||||||
"/proc/config.gz",
|
"/proc/config.gz",
|
||||||
source.UsrDir.Path("src/linux-" + kVer + "/.config"),
|
hostpath.UsrDir.Path("src/linux-" + kVer + "/.config"),
|
||||||
source.UsrDir.Path("src/linux/.config"),
|
hostpath.UsrDir.Path("src/linux/.config"),
|
||||||
source.UsrDir.Path("lib/modules/" + kVer + "/config"),
|
hostpath.UsrDir.Path("lib/modules/" + kVer + "/config"),
|
||||||
source.UsrDir.Path("lib/ostree-boot/config-" + kVer),
|
hostpath.UsrDir.Path("lib/ostree-boot/config-" + kVer),
|
||||||
source.UsrDir.Path("lib/kernel/config-" + kVer),
|
hostpath.UsrDir.Path("lib/kernel/config-" + kVer),
|
||||||
source.UsrDir.Path("src/linux-headers-" + kVer + "/.config"),
|
hostpath.UsrDir.Path("src/linux-headers-" + kVer + "/.config"),
|
||||||
"/lib/modules/" + kVer + "/build/.config",
|
"/lib/modules/" + kVer + "/build/.config",
|
||||||
source.BootDir.Path("config-" + kVer),
|
hostpath.BootDir.Path("config-" + kVer),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,12 +23,12 @@ import (
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
|
||||||
"sigs.k8s.io/node-feature-discovery/source"
|
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SelinuxEnabled detects if selinux has been enabled in the kernel
|
// SelinuxEnabled detects if selinux has been enabled in the kernel
|
||||||
func SelinuxEnabled() (bool, error) {
|
func SelinuxEnabled() (bool, error) {
|
||||||
sysfsBase := source.SysfsDir.Path("fs")
|
sysfsBase := hostpath.SysfsDir.Path("fs")
|
||||||
if _, err := os.Stat(sysfsBase); err != nil {
|
if _, err := os.Stat(sysfsBase); err != nil {
|
||||||
return false, fmt.Errorf("unable to detect selinux status: %w", err)
|
return false, fmt.Errorf("unable to detect selinux status: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import (
|
||||||
|
|
||||||
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
|
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
|
||||||
"sigs.k8s.io/node-feature-discovery/pkg/utils"
|
"sigs.k8s.io/node-feature-discovery/pkg/utils"
|
||||||
|
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
|
||||||
"sigs.k8s.io/node-feature-discovery/source"
|
"sigs.k8s.io/node-feature-discovery/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -114,7 +115,7 @@ func (s *memorySource) GetFeatures() *feature.DomainFeatures {
|
||||||
|
|
||||||
// detectNuma detects NUMA node information
|
// detectNuma detects NUMA node information
|
||||||
func detectNuma() (map[string]string, error) {
|
func detectNuma() (map[string]string, error) {
|
||||||
sysfsBasePath := source.SysfsDir.Path("bus/node/devices")
|
sysfsBasePath := hostpath.SysfsDir.Path("bus/node/devices")
|
||||||
|
|
||||||
nodes, err := os.ReadDir(sysfsBasePath)
|
nodes, err := os.ReadDir(sysfsBasePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -129,7 +130,7 @@ func detectNuma() (map[string]string, error) {
|
||||||
|
|
||||||
// detectNv detects NVDIMM devices
|
// detectNv detects NVDIMM devices
|
||||||
func detectNv() ([]feature.InstanceFeature, error) {
|
func detectNv() ([]feature.InstanceFeature, error) {
|
||||||
sysfsBasePath := source.SysfsDir.Path("bus/nd/devices")
|
sysfsBasePath := hostpath.SysfsDir.Path("bus/nd/devices")
|
||||||
info := make([]feature.InstanceFeature, 0)
|
info := make([]feature.InstanceFeature, 0)
|
||||||
|
|
||||||
devices, err := os.ReadDir(sysfsBasePath)
|
devices, err := os.ReadDir(sysfsBasePath)
|
||||||
|
|
|
@ -27,6 +27,7 @@ import (
|
||||||
|
|
||||||
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
|
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
|
||||||
"sigs.k8s.io/node-feature-discovery/pkg/utils"
|
"sigs.k8s.io/node-feature-discovery/pkg/utils"
|
||||||
|
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
|
||||||
"sigs.k8s.io/node-feature-discovery/source"
|
"sigs.k8s.io/node-feature-discovery/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -112,7 +113,7 @@ func (s *networkSource) GetFeatures() *feature.DomainFeatures {
|
||||||
}
|
}
|
||||||
|
|
||||||
func detectNetDevices() ([]feature.InstanceFeature, error) {
|
func detectNetDevices() ([]feature.InstanceFeature, error) {
|
||||||
sysfsBasePath := source.SysfsDir.Path(sysfsBaseDir)
|
sysfsBasePath := hostpath.SysfsDir.Path(sysfsBaseDir)
|
||||||
|
|
||||||
ifaces, err := os.ReadDir(sysfsBasePath)
|
ifaces, err := os.ReadDir(sysfsBasePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -25,7 +25,7 @@ import (
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
|
||||||
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
|
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
|
||||||
"sigs.k8s.io/node-feature-discovery/source"
|
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
|
||||||
)
|
)
|
||||||
|
|
||||||
var mandatoryDevAttrs = []string{"class", "vendor", "device", "subsystem_vendor", "subsystem_device"}
|
var mandatoryDevAttrs = []string{"class", "vendor", "device", "subsystem_vendor", "subsystem_device"}
|
||||||
|
@ -71,7 +71,7 @@ func readPciDevInfo(devPath string) (*feature.InstanceFeature, error) {
|
||||||
// detectPci detects available PCI devices and retrieves their device attributes.
|
// detectPci detects available PCI devices and retrieves their device attributes.
|
||||||
// An error is returned if reading any of the mandatory attributes fails.
|
// An error is returned if reading any of the mandatory attributes fails.
|
||||||
func detectPci() ([]feature.InstanceFeature, error) {
|
func detectPci() ([]feature.InstanceFeature, error) {
|
||||||
sysfsBasePath := source.SysfsDir.Path("bus/pci/devices")
|
sysfsBasePath := hostpath.SysfsDir.Path("bus/pci/devices")
|
||||||
|
|
||||||
devices, err := os.ReadDir(sysfsBasePath)
|
devices, err := os.ReadDir(sysfsBasePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import (
|
||||||
|
|
||||||
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
|
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
|
||||||
"sigs.k8s.io/node-feature-discovery/pkg/utils"
|
"sigs.k8s.io/node-feature-discovery/pkg/utils"
|
||||||
|
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
|
||||||
"sigs.k8s.io/node-feature-discovery/source"
|
"sigs.k8s.io/node-feature-discovery/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -94,7 +95,7 @@ func (s *storageSource) GetFeatures() *feature.DomainFeatures {
|
||||||
}
|
}
|
||||||
|
|
||||||
func detectBlock() ([]feature.InstanceFeature, error) {
|
func detectBlock() ([]feature.InstanceFeature, error) {
|
||||||
sysfsBasePath := source.SysfsDir.Path("block")
|
sysfsBasePath := hostpath.SysfsDir.Path("block")
|
||||||
|
|
||||||
blockdevices, err := os.ReadDir(sysfsBasePath)
|
blockdevices, err := os.ReadDir(sysfsBasePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import (
|
||||||
|
|
||||||
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
|
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
|
||||||
"sigs.k8s.io/node-feature-discovery/pkg/utils"
|
"sigs.k8s.io/node-feature-discovery/pkg/utils"
|
||||||
|
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
|
||||||
"sigs.k8s.io/node-feature-discovery/source"
|
"sigs.k8s.io/node-feature-discovery/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -117,7 +118,7 @@ func (s *systemSource) GetFeatures() *feature.DomainFeatures {
|
||||||
func parseOSRelease() (map[string]string, error) {
|
func parseOSRelease() (map[string]string, error) {
|
||||||
release := map[string]string{}
|
release := map[string]string{}
|
||||||
|
|
||||||
f, err := os.Open(source.EtcDir.Path("os-release"))
|
f, err := os.Open(hostpath.EtcDir.Path("os-release"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue