mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2024-12-15 17:50:49 +00:00
348f3a7f89
* Make rdt-discovery buildable outside hardcoded path Do not assume that nfd sources always reside under hardcoded directory "/go/src/github.com/kubernetes-incubator/node-feature-discovery/". This makes it possible e.g. to build nfd locally outside the Docker container. * Do not hardcode the path for RDT helper binaries Utilize the standard PATH env variable, instead.
60 lines
1.7 KiB
Go
60 lines
1.7 KiB
Go
/*
|
|
Copyright 2017 The Kubernetes Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package rdt
|
|
|
|
import (
|
|
"os/exec"
|
|
|
|
"github.com/golang/glog"
|
|
)
|
|
|
|
// Source implements FeatureSource.
|
|
type Source struct{}
|
|
|
|
// Name returns an identifier string for this feature source.
|
|
func (s Source) Name() string { return "rdt" }
|
|
|
|
// Discover returns feature names for CMT and CAT if suppported.
|
|
func (s Source) Discover() ([]string, error) {
|
|
features := []string{}
|
|
|
|
cmd := exec.Command("bash", "-c", "mon-discovery")
|
|
if err := cmd.Run(); err != nil {
|
|
glog.Errorf("support for RDT monitoring was not detected: %v", err)
|
|
} else {
|
|
// RDT monitoring detected.
|
|
features = append(features, "RDTMON")
|
|
}
|
|
|
|
cmd = exec.Command("bash", "-c", "l3-alloc-discovery")
|
|
if err := cmd.Run(); err != nil {
|
|
glog.Errorf("support for RDT L3 allocation was not detected: %v", err)
|
|
} else {
|
|
// RDT L3 cache allocation detected.
|
|
features = append(features, "RDTL3CA")
|
|
}
|
|
|
|
cmd = exec.Command("bash", "-c", "l2-alloc-discovery")
|
|
if err := cmd.Run(); err != nil {
|
|
glog.Errorf("support for RDT L2 allocation was not detected: %v", err)
|
|
} else {
|
|
// RDT L2 cache allocation detected.
|
|
features = append(features, "RDTL2CA")
|
|
}
|
|
|
|
return features, nil
|
|
}
|