mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-16 21:38:23 +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:
parent
c52d01a6cb
commit
3e8217e9ef
2 changed files with 26 additions and 3 deletions
|
@ -260,9 +260,10 @@ possible security implications.
|
||||||
|
|
||||||
### Memory Features
|
### Memory Features
|
||||||
|
|
||||||
| Feature name | Description |
|
| Feature | Attribute | Description |
|
||||||
| :------------: | :---------------------------------------------------------------------------------: |
|
| ------- | --------- | ------------------------------------------------------ |
|
||||||
| numa | Multiple memory nodes i.e. NUMA architecture detected
|
| numa | <br> | Multiple memory nodes i.e. NUMA architecture detected
|
||||||
|
| nv | present | NVDIMM device(s) are present
|
||||||
|
|
||||||
### Network Features
|
### Network Features
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ package memory
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"sigs.k8s.io/node-feature-discovery/source"
|
"sigs.k8s.io/node-feature-discovery/source"
|
||||||
|
@ -42,6 +43,14 @@ func (s Source) Discover() (source.Features, error) {
|
||||||
features["numa"] = true
|
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
|
return features, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,3 +73,16 @@ func isNuma() (bool, error) {
|
||||||
}
|
}
|
||||||
return false, nil
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue