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:
parent
c52d01a6cb
commit
3e8217e9ef
2 changed files with 26 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue