mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2024-12-14 11:57:51 +00:00
b4c92e4eed
- This patch allows to expose Resource Hardware Topology information through CRDs in Node Feature Discovery. - In order to do this we introduce another software component called nfd-topology-updater in addition to the already existing software components nfd-master and nfd-worker. - nfd-master was enhanced to communicate with nfd-topology-updater over gRPC followed by creation of CRs corresponding to the nodes in the cluster exposing resource hardware topology information of that node. - Pin kubernetes dependency to one that include pod resource implementation - This code is responsible for obtaining hardware information from the system as well as pod resource information from the Pod Resource API in order to determine the allocatable resource information for each NUMA zone. This information along with Costs for NUMA zones (obtained by reading NUMA distances) is gathered by nfd-topology-updater running on all the nodes of the cluster and propagate NUMA zone costs to master in order to populate that information in the CRs corresponding to the nodes. - We use GHW facilities for obtaining system information like CPUs, topology, NUMA distances etc. - This also includes updates made to Makefile and Dockerfile and Manifests for deploying nfd-topology-updater. - This patch includes unit tests - As part of the Topology Aware Scheduling work, this patch captures the configured Topology manager scope in addition to the Topology manager policy. Based on the value of both attribues a single string will be populated to the CRD. The string value will be on of the following {SingleNUMANodeContainerLevel, SingleNUMANodePodLevel, BestEffort, Restricted, None} Co-Authored-by: Artyom Lukianov <alukiano@redhat.com> Co-Authored-by: Francesco Romani <fromani@redhat.com> Co-Authored-by: Talor Itzhak <titzhak@redhat.com> Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
104 lines
3.9 KiB
Go
104 lines
3.9 KiB
Go
/*
|
|
Copyright 2021 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 main
|
|
|
|
import (
|
|
"flag"
|
|
"testing"
|
|
"time"
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
)
|
|
|
|
func TestArgsParse(t *testing.T) {
|
|
Convey("When parsing command line arguments", t, func() {
|
|
flags := flag.NewFlagSet(ProgramName, flag.ExitOnError)
|
|
|
|
Convey("When --no-publish and --oneshot flags are passed", func() {
|
|
args, finderArgs := parseArgs(flags, "--oneshot", "--no-publish")
|
|
|
|
Convey("noPublish is set and args.sources is set to the default value", func() {
|
|
So(args.NoPublish, ShouldBeTrue)
|
|
So(args.Oneshot, ShouldBeTrue)
|
|
So(finderArgs.SleepInterval, ShouldEqual, 60*time.Second)
|
|
So(finderArgs.KubeletConfigFile, ShouldEqual, "/var/lib/kubelet/config.yaml")
|
|
So(finderArgs.PodResourceSocketPath, ShouldEqual, "/var/lib/kubelet/pod-resources/kubelet.sock")
|
|
})
|
|
})
|
|
|
|
Convey("When valid args are specified for --kubelet-config-file and --sleep-interval,", func() {
|
|
args, finderArgs := parseArgs(flags,
|
|
"--kubelet-config-file=/path/testconfig.yaml",
|
|
"--sleep-interval=30s")
|
|
|
|
Convey("args.sources is set to appropriate values", func() {
|
|
So(args.NoPublish, ShouldBeFalse)
|
|
So(args.Oneshot, ShouldBeFalse)
|
|
So(finderArgs.SleepInterval, ShouldEqual, 30*time.Second)
|
|
So(finderArgs.KubeletConfigFile, ShouldEqual, "/path/testconfig.yaml")
|
|
So(finderArgs.PodResourceSocketPath, ShouldEqual, "/var/lib/kubelet/pod-resources/kubelet.sock")
|
|
})
|
|
})
|
|
|
|
Convey("When valid args are specified for --podresources-socket flag and --sleep-interval is specified", func() {
|
|
args, finderArgs := parseArgs(flags,
|
|
"--podresources-socket=/path/testkubelet.sock",
|
|
"--sleep-interval=30s")
|
|
|
|
Convey("args.sources is set to appropriate values", func() {
|
|
So(args.NoPublish, ShouldBeFalse)
|
|
So(args.Oneshot, ShouldBeFalse)
|
|
So(finderArgs.SleepInterval, ShouldEqual, 30*time.Second)
|
|
So(finderArgs.KubeletConfigFile, ShouldEqual, "/var/lib/kubelet/config.yaml")
|
|
So(finderArgs.PodResourceSocketPath, ShouldEqual, "/path/testkubelet.sock")
|
|
})
|
|
})
|
|
Convey("When valid args are specified for--sysfs and --sleep-inteval is specified", func() {
|
|
args, finderArgs := parseArgs(flags,
|
|
"--sleep-interval=30s")
|
|
|
|
Convey("args.sources is set to appropriate values", func() {
|
|
So(args.NoPublish, ShouldBeFalse)
|
|
So(args.Oneshot, ShouldBeFalse)
|
|
So(finderArgs.SleepInterval, ShouldEqual, 30*time.Second)
|
|
So(finderArgs.KubeletConfigFile, ShouldEqual, "/var/lib/kubelet/config.yaml")
|
|
So(finderArgs.PodResourceSocketPath, ShouldEqual, "/var/lib/kubelet/pod-resources/kubelet.sock")
|
|
})
|
|
})
|
|
|
|
Convey("When All valid args are specified", func() {
|
|
args, finderArgs := parseArgs(flags,
|
|
"--no-publish",
|
|
"--sleep-interval=30s",
|
|
"--kubelet-config-file=/path/testconfig.yaml",
|
|
"--podresources-socket=/path/testkubelet.sock",
|
|
"--ca-file=ca",
|
|
"--cert-file=crt",
|
|
"--key-file=key")
|
|
|
|
Convey("--no-publish is set and args.sources is set to appropriate values", func() {
|
|
So(args.NoPublish, ShouldBeTrue)
|
|
So(args.CaFile, ShouldEqual, "ca")
|
|
So(args.CertFile, ShouldEqual, "crt")
|
|
So(args.KeyFile, ShouldEqual, "key")
|
|
So(finderArgs.SleepInterval, ShouldEqual, 30*time.Second)
|
|
So(finderArgs.KubeletConfigFile, ShouldEqual, "/path/testconfig.yaml")
|
|
So(finderArgs.PodResourceSocketPath, ShouldEqual, "/path/testkubelet.sock")
|
|
})
|
|
})
|
|
})
|
|
}
|