diff --git a/cmd/webhook/start.go b/cmd/webhook/start.go index a0046e383..2a13c4420 100644 --- a/cmd/webhook/start.go +++ b/cmd/webhook/start.go @@ -10,7 +10,7 @@ import ( "github.com/fsnotify/fsnotify" "github.com/golang/glog" "github.com/spf13/cobra" - "k8s.io/api/admission/v1" + v1 "k8s.io/api/admission/v1" "k8s.io/apimachinery/pkg/runtime" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/webhook" @@ -29,11 +29,6 @@ var ( Long: "Starts Webhook Daemon", Run: runStartCmd, } - - startOpts struct { - kubeconfig string - nodeName string - } ) // admitv1Func handles a v1 admission diff --git a/controllers/sriovoperatorconfig_controller.go b/controllers/sriovoperatorconfig_controller.go index 9b4d43742..0711f8a98 100644 --- a/controllers/sriovoperatorconfig_controller.go +++ b/controllers/sriovoperatorconfig_controller.go @@ -48,9 +48,6 @@ type SriovOperatorConfigReconciler struct { Scheme *runtime.Scheme } -var injectorServiceCaCmVersion = "" -var webhookServiceCaCmVersion = "" - //+kubebuilder:rbac:groups=sriovnetwork.openshift.io,resources=sriovoperatorconfigs,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=sriovnetwork.openshift.io,resources=sriovoperatorconfigs/status,verbs=get;update;patch //+kubebuilder:rbac:groups=sriovnetwork.openshift.io,resources=sriovoperatorconfigs/finalizers,verbs=update diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 034e5811c..1df326471 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -32,7 +32,6 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" @@ -48,7 +47,6 @@ import ( // These tests use Ginkgo (BDD-style Go testing framework). Refer to // http://onsi.github.io/ginkgo/ to learn more about Ginkgo. -var cfg *rest.Config var k8sClient client.Client var testEnv *envtest.Environment diff --git a/pkg/daemon/daemon.go b/pkg/daemon/daemon.go index 038e8d315..bd374240f 100644 --- a/pkg/daemon/daemon.go +++ b/pkg/daemon/daemon.go @@ -24,7 +24,6 @@ import ( mcfginformers "github.com/openshift/machine-config-operator/pkg/generated/informers/externalversions" "golang.org/x/time/rate" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" @@ -63,8 +62,7 @@ type Message struct { type Daemon struct { // name is the node name. - name string - namespace string + name string platform utils.PlatformType @@ -88,8 +86,6 @@ type Daemon struct { refreshCh chan<- Message - dpReboot bool - mu *sync.Mutex drainer *drain.Helper @@ -107,10 +103,6 @@ type Daemon struct { mcpName string } -type workItem struct { - old, new *sriovnetworkv1.SriovNetworkNodeState -} - const ( rdmaScriptsPath = "/bindata/scripts/enable-rdma.sh" udevScriptsPath = "/bindata/scripts/load-udev.sh" @@ -179,26 +171,6 @@ func New( } } -func (dn *Daemon) annotateUnsupportedNicIdConfigMap(cm *v1.ConfigMap, nodeName string) (*v1.ConfigMap, error) { - jsonData, err := json.Marshal(cm.Data) - if err != nil { - return nil, err - } - cmData := string(jsonData) - - annotationKey := "openshift.io/" + nodeName - annotationData, ok := cm.ObjectMeta.Annotations[annotationKey] - if ok && cmData == annotationData { - return cm, nil - } - - if cm.ObjectMeta.Annotations == nil { - cm.ObjectMeta.Annotations = make(map[string]string) - } - cm.ObjectMeta.Annotations[annotationKey] = cmData - return dn.kubeClient.CoreV1().ConfigMaps(namespace).Update(context.Background(), cm, metav1.UpdateOptions{}) -} - func (dn *Daemon) tryCreateUdevRuleWrapper() error { ns, nodeStateErr := dn.client.SriovnetworkV1().SriovNetworkNodeStates(namespace).Get( context.Background(), diff --git a/pkg/plugins/virtual/virtual_plugin.go b/pkg/plugins/virtual/virtual_plugin.go index dbae02e63..2fa6f46ce 100644 --- a/pkg/plugins/virtual/virtual_plugin.go +++ b/pkg/plugins/virtual/virtual_plugin.go @@ -1,9 +1,7 @@ package main import ( - "os/exec" "reflect" - "syscall" "github.com/golang/glog" sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1" @@ -132,12 +130,3 @@ func needVfioDriver(state *sriovnetworkv1.SriovNetworkNodeState) bool { } return false } - -func isCommandNotFound(err error) bool { - if exitErr, ok := err.(*exec.ExitError); ok { - if status, ok := exitErr.Sys().(syscall.WaitStatus); ok && status.ExitStatus() == 127 { - return true - } - } - return false -} diff --git a/pkg/webhook/validate.go b/pkg/webhook/validate.go index 4c86fd4e7..d851e3fd4 100644 --- a/pkg/webhook/validate.go +++ b/pkg/webhook/validate.go @@ -257,16 +257,6 @@ func validatePolicyForNodePolicy( return true, nil } -func keys(m map[string]([]string)) []string { - keys := make([]string, len(m)) - i := 0 - for k := range m { - keys[i] = k - i++ - } - return keys -} - func validateNicModel(selector *sriovnetworkv1.SriovNetworkNicSelector, iface *sriovnetworkv1.InterfaceExt, node *corev1.Node) bool { if selector.Vendor != "" && selector.Vendor != iface.Vendor { return false diff --git a/test/conformance/tests/sriov_operator.go b/test/conformance/tests/sriov_operator.go index ea28a876b..0a94b759d 100644 --- a/test/conformance/tests/sriov_operator.go +++ b/test/conformance/tests/sriov_operator.go @@ -1978,36 +1978,6 @@ func createSriovPolicy(sriovDevice string, testNode string, numVfs int, resource }, 10*time.Minute, time.Second).Should(Equal(int64(numVfs))) } -func createUnschedulableTestPod(node string, networks []string, resourceName string) { - podDefinition := pod.RedefineWithNodeSelector( - pod.DefineWithNetworks(networks), - node, - ) - createdPod, err := clients.Pods(namespaces.Test).Create(context.Background(), podDefinition, metav1.CreateOptions{}) - Consistently(func() k8sv1.PodPhase { - runningPod, err := clients.Pods(namespaces.Test).Get(context.Background(), createdPod.Name, metav1.GetOptions{}) - Expect(err).ToNot(HaveOccurred()) - return runningPod.Status.Phase - }, 3*time.Minute, 1*time.Second).Should(Equal(k8sv1.PodPending)) - pod, err := clients.Pods(namespaces.Test).Get(context.Background(), createdPod.Name, metav1.GetOptions{}) - Expect(err).ToNot(HaveOccurred()) - for _, condition := range pod.Status.Conditions { - if condition.Reason == "Unschedulable" && strings.Contains(condition.Message, "Insufficient openshift.io/"+resourceName) { - return - } - } - Fail("Pod should be Unschedulable due to: Insufficient openshift.io/" + resourceName) -} - -func isPodConditionUnschedulable(pod *k8sv1.Pod, resourceName string) bool { - for _, condition := range pod.Status.Conditions { - if condition.Reason == "Unschedulable" && strings.Index(condition.Message, "Insufficient openshift.io/"+resourceName) != -1 { - return true - } - } - return false -} - func createTestPod(node string, networks []string) *k8sv1.Pod { return createCustomTestPod(node, networks, false, nil) } diff --git a/test/e2e/e2e_tests_suite_test.go b/test/e2e/e2e_tests_suite_test.go index fdfcb1bcb..39da4f101 100644 --- a/test/e2e/e2e_tests_suite_test.go +++ b/test/e2e/e2e_tests_suite_test.go @@ -23,7 +23,6 @@ import ( sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1" // +kubebuilder:scaffold:imports - "github.com/k8snetworkplumbingwg/sriov-network-operator/test/util/cluster" "github.com/k8snetworkplumbingwg/sriov-network-operator/test/util/netns" ) @@ -56,7 +55,6 @@ func TestSriovTests(t *testing.T) { []Reporter{printer.NewlineReporter{}}) } -var sriovInfos *cluster.EnabledNodes var sriovIface *sriovnetworkv1.InterfaceExt var _ = BeforeSuite(func(done Done) { diff --git a/test/util/discovery/discovery.go b/test/util/discovery/discovery.go index a2a160d50..8f5cbf737 100644 --- a/test/util/discovery/discovery.go +++ b/test/util/discovery/discovery.go @@ -70,12 +70,3 @@ func getSriovNodes(clients *client.ClientSet, sriovNodeNames []string) ([]corev1 } return nodes, nil } - -func containsNode(name string, sriovNodes []string) bool { - for _, node := range sriovNodes { - if node == name { - return true - } - } - return false -} diff --git a/test/util/k8sreporter/reporter.go b/test/util/k8sreporter/reporter.go index da8716b7c..3473ff2e2 100644 --- a/test/util/k8sreporter/reporter.go +++ b/test/util/k8sreporter/reporter.go @@ -149,26 +149,6 @@ func (r *KubernetesReporter) logNetworkPolicies() { } fmt.Fprintln(r.dumpOutput, string(j)) } -func (r *KubernetesReporter) logNetworks() { - fmt.Fprintf(r.dumpOutput, "Logging networks") - - networks := sriovv1.SriovNetworkList{} - err := r.clients.List(context.Background(), - &networks, - runtimeclient.InNamespace("openshift-sriov-network-operator")) - - if err != nil { - fmt.Fprintf(os.Stderr, "failed to fetch network policies: %v\n", err) - return - } - - j, err := json.MarshalIndent(networks, "", " ") - if err != nil { - fmt.Println("Failed to marshal networks") - return - } - fmt.Fprintln(r.dumpOutput, string(j)) -} func (r *KubernetesReporter) logSriovNodeState() { fmt.Fprintf(r.dumpOutput, "Logging node states") diff --git a/test/validation/tests/validation.go b/test/validation/tests/validation.go index 999cb32fe..52090bf11 100644 --- a/test/validation/tests/validation.go +++ b/test/validation/tests/validation.go @@ -19,10 +19,6 @@ import ( "github.com/k8snetworkplumbingwg/sriov-network-operator/test/util/cluster" ) -var ( - machineConfigPoolNodeSelector string -) - var ( clients *testclient.ClientSet operatorNamespace string @@ -54,8 +50,6 @@ func init() { if roleWorkerCNF == "" { roleWorkerCNF = "worker-cnf" } - - machineConfigPoolNodeSelector = fmt.Sprintf("node-role.kubernetes.io/%s", roleWorkerCNF) } var _ = Describe("validation", func() {