1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

source/memory: detect presence of NVDIMM devices

Add a new (binary) label indicating the presence of non-volatile DIMM
devices:
  feature.node.kubernetes.io/memory-nv.present
This commit is contained in:
Markus Lehtonen 2019-01-25 16:54:34 +02:00
parent c52d01a6cb
commit 3e8217e9ef
2 changed files with 26 additions and 3 deletions

View file

@ -260,9 +260,10 @@ possible security implications.
### Memory Features
| Feature name | Description |
| :------------: | :---------------------------------------------------------------------------------: |
| numa | Multiple memory nodes i.e. NUMA architecture detected
| Feature | Attribute | Description |
| ------- | --------- | ------------------------------------------------------ |
| numa | <br> | Multiple memory nodes i.e. NUMA architecture detected
| nv | present | NVDIMM device(s) are present
### Network Features

View file

@ -19,6 +19,7 @@ package memory
import (
"io/ioutil"
"log"
"os"
"strings"
"sigs.k8s.io/node-feature-discovery/source"
@ -42,6 +43,14 @@ func (s Source) Discover() (source.Features, error) {
features["numa"] = true
}
// Detect NVDIMM
nv, err := hasNvdimm()
if err != nil {
log.Printf("ERROR: failed to detect presence of NVDIMM: %s", err)
} else if nv {
features["nv.present"] = true
}
return features, nil
}
@ -64,3 +73,16 @@ func isNuma() (bool, error) {
}
return false, nil
}
// Detect presence of NVDIMM devices
func hasNvdimm() (bool, error) {
devices, err := ioutil.ReadDir("/sys/class/nd/")
if err == nil {
if len(devices) > 0 {
return true, nil
}
} else if !os.IsNotExist(err) {
return false, err
}
return false, nil
}