mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-16 21:38:23 +00:00
Merge pull request #538 from ArangoGutierrez/devel/go_report
make go report happy
This commit is contained in:
commit
6e039818eb
13 changed files with 30 additions and 25 deletions
|
@ -365,7 +365,7 @@ func TestSetLabels(t *testing.T) {
|
||||||
apihelper.NewJsonPatch("add", "/metadata/labels", "valid.ns/feature-2", mockLabels["valid.ns/feature-2"]),
|
apihelper.NewJsonPatch("add", "/metadata/labels", "valid.ns/feature-2", mockLabels["valid.ns/feature-2"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
mockMaster.args.ExtraLabelNs = map[string]struct{}{"valid.ns": struct{}{}}
|
mockMaster.args.ExtraLabelNs = map[string]struct{}{"valid.ns": {}}
|
||||||
mockMaster.annotationNs = instance + "." + AnnotationNsBase
|
mockMaster.annotationNs = instance + "." + AnnotationNsBase
|
||||||
mockHelper.On("GetClient").Return(mockClient, nil)
|
mockHelper.On("GetClient").Return(mockClient, nil)
|
||||||
mockHelper.On("GetNode", mockClient, workerName).Return(mockNode, nil)
|
mockHelper.On("GetNode", mockClient, workerName).Return(mockNode, nil)
|
||||||
|
@ -391,7 +391,7 @@ func TestSetLabels(t *testing.T) {
|
||||||
apihelper.NewJsonPatch("add", "/status/capacity", LabelNs+"/feature-3", mockLabels["feature-3"]),
|
apihelper.NewJsonPatch("add", "/status/capacity", LabelNs+"/feature-3", mockLabels["feature-3"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
mockMaster.args.ResourceLabels = map[string]struct{}{"feature-3": struct{}{}, "feature-1": struct{}{}}
|
mockMaster.args.ResourceLabels = map[string]struct{}{"feature-3": {}, "feature-1": {}}
|
||||||
mockHelper.On("GetClient").Return(mockClient, nil)
|
mockHelper.On("GetClient").Return(mockClient, nil)
|
||||||
mockHelper.On("GetNode", mockClient, workerName).Return(mockNode, nil)
|
mockHelper.On("GetNode", mockClient, workerName).Return(mockNode, nil)
|
||||||
mockHelper.On("PatchNode", mockClient, mockNodeName, mock.MatchedBy(jsonPatchMatcher(expectedPatches))).Return(nil)
|
mockHelper.On("PatchNode", mockClient, mockNodeName, mock.MatchedBy(jsonPatchMatcher(expectedPatches))).Return(nil)
|
||||||
|
|
|
@ -43,10 +43,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Namespace for feature labels
|
// LabelNs defines the Namespace for feature labels
|
||||||
LabelNs = "feature.node.kubernetes.io"
|
LabelNs = "feature.node.kubernetes.io"
|
||||||
|
|
||||||
// Base namespace for all NFD-related annotations
|
// AnnotationNsBase namespace for all NFD-related annotations
|
||||||
AnnotationNsBase = "nfd.node.kubernetes.io"
|
AnnotationNsBase = "nfd.node.kubernetes.io"
|
||||||
|
|
||||||
// NFD Annotations
|
// NFD Annotations
|
||||||
|
@ -65,7 +65,7 @@ type ExtendedResources map[string]string
|
||||||
// Annotations are used for NFD-related node metadata
|
// Annotations are used for NFD-related node metadata
|
||||||
type Annotations map[string]string
|
type Annotations map[string]string
|
||||||
|
|
||||||
// Command line arguments
|
// Args holds command line arguments
|
||||||
type Args struct {
|
type Args struct {
|
||||||
CaFile string
|
CaFile string
|
||||||
CertFile string
|
CertFile string
|
||||||
|
|
|
@ -51,13 +51,13 @@ func newDefaultConfig() *config {
|
||||||
return &config{}
|
return &config{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FeatureSource Interface
|
// Source implements FeatureSource Interface
|
||||||
type Source struct {
|
type Source struct {
|
||||||
config *config
|
config *config
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return name of the feature source
|
// Name returns the name of the feature source
|
||||||
func (s Source) Name() string { return Name }
|
func (s Source) Name() string { return "custom" }
|
||||||
|
|
||||||
// NewConfig method of the FeatureSource interface
|
// NewConfig method of the FeatureSource interface
|
||||||
func (s *Source) NewConfig() source.Config { return newDefaultConfig() }
|
func (s *Source) NewConfig() source.Config { return newDefaultConfig() }
|
||||||
|
|
|
@ -26,6 +26,7 @@ import (
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Directory stores the full path for the custom sources folder
|
||||||
const Directory = "/etc/kubernetes/node-feature-discovery/custom.d"
|
const Directory = "/etc/kubernetes/node-feature-discovery/custom.d"
|
||||||
|
|
||||||
// getDirectoryFeatureConfig returns features configured in the "/etc/kubernetes/node-feature-discovery/custom.d"
|
// getDirectoryFeatureConfig returns features configured in the "/etc/kubernetes/node-feature-discovery/custom.d"
|
||||||
|
|
|
@ -22,7 +22,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Rule that matches on loaded kernel modules in the system
|
// LoadedKModRule matches loaded kernel modules in the system
|
||||||
type LoadedKModRule []string
|
type LoadedKModRule []string
|
||||||
|
|
||||||
const kmodProcfsPath = "/proc/modules"
|
const kmodProcfsPath = "/proc/modules"
|
||||||
|
|
|
@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package rules
|
package rules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -26,7 +27,7 @@ var (
|
||||||
nodeName = os.Getenv("NODE_NAME")
|
nodeName = os.Getenv("NODE_NAME")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Rule that matches on nodenames configured in a ConfigMap
|
// NodenameRule matches on nodenames configured in a ConfigMap
|
||||||
type NodenameRule []string
|
type NodenameRule []string
|
||||||
|
|
||||||
// Force implementation of Rule
|
// Force implementation of Rule
|
||||||
|
|
|
@ -24,20 +24,20 @@ import (
|
||||||
// e.g RMDA related features. NFD configuration file may extend these custom features by adding rules.
|
// e.g RMDA related features. NFD configuration file may extend these custom features by adding rules.
|
||||||
func getStaticFeatureConfig() []FeatureSpec {
|
func getStaticFeatureConfig() []FeatureSpec {
|
||||||
return []FeatureSpec{
|
return []FeatureSpec{
|
||||||
FeatureSpec{
|
{
|
||||||
Name: "rdma.capable",
|
Name: "rdma.capable",
|
||||||
MatchOn: []MatchRule{
|
MatchOn: []MatchRule{
|
||||||
MatchRule{
|
{
|
||||||
PciID: &rules.PciIDRule{
|
PciID: &rules.PciIDRule{
|
||||||
PciIDRuleInput: rules.PciIDRuleInput{Vendor: []string{"15b3"}},
|
PciIDRuleInput: rules.PciIDRuleInput{Vendor: []string{"15b3"}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
FeatureSpec{
|
{
|
||||||
Name: "rdma.available",
|
Name: "rdma.available",
|
||||||
MatchOn: []MatchRule{
|
MatchOn: []MatchRule{
|
||||||
MatchRule{
|
{
|
||||||
LoadedKMod: &rules.LoadedKModRule{"ib_uverbs", "rdma_ucm"},
|
LoadedKMod: &rules.LoadedKModRule{"ib_uverbs", "rdma_ucm"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"github.com/klauspost/cpuid/v2"
|
"github.com/klauspost/cpuid/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Discover returns feature names for all the supported CPU features.
|
// GetCpuidFlags returns feature names for all the supported CPU features.
|
||||||
func GetCpuidFlags() []string {
|
func GetCpuidFlags() []string {
|
||||||
return cpuid.CPU.FeatureSet()
|
return cpuid.CPU.FeatureSet()
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,12 +68,12 @@ func readPciDevInfo(devPath string, deviceAttrSpec map[string]bool) (PciDeviceIn
|
||||||
return info, nil
|
return info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// List available PCI devices and retrieve device attributes.
|
// DetectPci lists available PCI devices and retrieve device attributes.
|
||||||
// deviceAttrSpec is a map which specifies which attributes to retrieve.
|
// deviceAttrSpec is a map which specifies which attributes to retrieve.
|
||||||
// a false value for a specific attribute marks the attribute as optional.
|
// a false value for a specific attribute marks the attribute as optional.
|
||||||
// a true value for a specific attribute marks the attribute as mandatory.
|
// a true value for a specific attribute marks the attribute as mandatory.
|
||||||
// "class" attribute is considered mandatory.
|
// "class" attribute is considered mandatory.
|
||||||
// DetectPci() will fail if the retrieval of a mandatory attribute fails.
|
// will fail if the retrieval of a mandatory attribute fails.
|
||||||
func DetectPci(deviceAttrSpec map[string]bool) (map[string][]PciDeviceInfo, error) {
|
func DetectPci(deviceAttrSpec map[string]bool) (map[string][]PciDeviceInfo, error) {
|
||||||
sysfsBasePath := source.SysfsDir.Path("bus/pci/devices")
|
sysfsBasePath := source.SysfsDir.Path("bus/pci/devices")
|
||||||
devInfo := make(map[string][]PciDeviceInfo)
|
devInfo := make(map[string][]PciDeviceInfo)
|
||||||
|
|
|
@ -26,6 +26,7 @@ import (
|
||||||
const Name = "iommu"
|
const Name = "iommu"
|
||||||
|
|
||||||
// Implement FeatureSource interface
|
// Implement FeatureSource interface
|
||||||
|
// Source implements FeatureSource interface
|
||||||
type Source struct{}
|
type Source struct{}
|
||||||
|
|
||||||
func (s Source) Name() string { return Name }
|
func (s Source) Name() string { return Name }
|
||||||
|
|
|
@ -38,10 +38,11 @@ var (
|
||||||
hookDir = "/etc/kubernetes/node-feature-discovery/source.d/"
|
hookDir = "/etc/kubernetes/node-feature-discovery/source.d/"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Implement FeatureSource interface
|
// Source implements FeatureSource interface
|
||||||
type Source struct{}
|
type Source struct{}
|
||||||
|
|
||||||
func (s Source) Name() string { return Name }
|
// Name returns the name of the feature source
|
||||||
|
func (s Source) Name() string { return "local" }
|
||||||
|
|
||||||
// NewConfig method of the FeatureSource interface
|
// NewConfig method of the FeatureSource interface
|
||||||
func (s *Source) NewConfig() source.Config { return nil }
|
func (s *Source) NewConfig() source.Config { return nil }
|
||||||
|
@ -52,6 +53,7 @@ func (s *Source) GetConfig() source.Config { return nil }
|
||||||
// SetConfig method of the FeatureSource interface
|
// SetConfig method of the FeatureSource interface
|
||||||
func (s *Source) SetConfig(source.Config) {}
|
func (s *Source) SetConfig(source.Config) {}
|
||||||
|
|
||||||
|
// Discover returns features from hooks and files
|
||||||
func (s Source) Discover() (source.Features, error) {
|
func (s Source) Discover() (source.Features, error) {
|
||||||
featuresFromHooks, err := getFeaturesFromHooks()
|
featuresFromHooks, err := getFeaturesFromHooks()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -41,13 +41,13 @@ func newDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implement FeatureSource interface
|
// Source implements FeatureSource interface
|
||||||
type Source struct {
|
type Source struct {
|
||||||
config *Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return name of the feature source
|
// Name returns the name of the feature source
|
||||||
func (s Source) Name() string { return Name }
|
func (s Source) Name() string { return "pci" }
|
||||||
|
|
||||||
// NewConfig method of the FeatureSource interface
|
// NewConfig method of the FeatureSource interface
|
||||||
func (s *Source) NewConfig() source.Config { return newDefaultConfig() }
|
func (s *Source) NewConfig() source.Config { return newDefaultConfig() }
|
||||||
|
|
|
@ -44,13 +44,13 @@ func newDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implement FeatureSource interface
|
// Source implements FeatureSource interface
|
||||||
type Source struct {
|
type Source struct {
|
||||||
config *Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return name of the feature source
|
// Name returns the name of the feature source
|
||||||
func (s Source) Name() string { return Name }
|
func (s Source) Name() string { return "usb" }
|
||||||
|
|
||||||
// NewConfig method of the FeatureSource interface
|
// NewConfig method of the FeatureSource interface
|
||||||
func (s *Source) NewConfig() source.Config { return newDefaultConfig() }
|
func (s *Source) NewConfig() source.Config { return newDefaultConfig() }
|
||||||
|
|
Loading…
Add table
Reference in a new issue