Repository: kubernetes-sigs/node-feature-discovery
Pull request #1309 (2023-08-18 14:52:05)

topology-gc: rename run()
Too many run methods here.

k8s-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes-sigs/node-feature-discovery/pull/1309#" title="Author self-approved">marquiz</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes-sigs%2Fnode-feature-discovery).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/OWNERS)~~ [marquiz]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/pkg/nfd-topology-gc/nfd-nrt-gc.go b/pkg/nfd-topology-gc/nfd-nrt-gc.go
index bb245ecdb..0a11eccad 100644
--- a/pkg/nfd-topology-gc/nfd-nrt-gc.go
+++ b/pkg/nfd-topology-gc/nfd-nrt-gc.go
@@ -158,7 +158,7 @@ func (n *topologyGC) periodicGC(gcPeriod time.Duration) {
 	}
 }
 
-func (n *topologyGC) run() error {
+func (n *topologyGC) startNodeInformer() error {
 	nodeInformer := n.factory.Core().V1().Nodes().Informer()
 
 	if _, err := nodeInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
@@ -178,7 +178,7 @@ func (n *topologyGC) run() error {
 
 // Run is a blocking function that removes stale NRT objects when Node is deleted and runs periodic GC to make sure any obsolete objects are removed
 func (n *topologyGC) Run() error {
-	if err := n.run(); err != nil {
+	if err := n.startNodeInformer(); err != nil {
 		return err
 	}
 	// run periodic GC


Test patch:
diff --git a/pkg/nfd-topology-gc/nfd-nrt-gc_test.go b/pkg/nfd-topology-gc/nfd-nrt-gc_test.go
index 6d9611bc7..cc8eef0e5 100644
--- a/pkg/nfd-topology-gc/nfd-nrt-gc_test.go
+++ b/pkg/nfd-topology-gc/nfd-nrt-gc_test.go
@@ -51,7 +51,7 @@ func TestNRTGC(t *testing.T) {
 			gcPeriod:   10 * time.Minute,
 		}
 
-		err := gc.run()
+		err := gc.startNodeInformer()
 		So(err, ShouldBeNil)
 
 		nrts, err := fakeClient.TopologyV1alpha2().NodeResourceTopologies().List(context.TODO(), metav1.ListOptions{})
@@ -90,7 +90,7 @@ func TestNRTGC(t *testing.T) {
 			gcPeriod:   10 * time.Minute,
 		}
 
-		err := gc.run()
+		err := gc.startNodeInformer()
 		So(err, ShouldBeNil)
 
 		nrts, err := fakeClient.TopologyV1alpha2().NodeResourceTopologies().List(context.TODO(), metav1.ListOptions{})
@@ -136,7 +136,7 @@ func TestNRTGC(t *testing.T) {
 			gcPeriod:   10 * time.Minute,
 		}
 
-		err := gc.run()
+		err := gc.startNodeInformer()
 		So(err, ShouldBeNil)
 
 		nrts, err := fakeClient.TopologyV1alpha2().NodeResourceTopologies().List(context.TODO(), metav1.ListOptions{})
@@ -197,7 +197,7 @@ func TestNRTGC(t *testing.T) {
 			gcPeriod:   time.Second,
 		}
 
-		err := gc.run()
+		err := gc.startNodeInformer()
 		So(err, ShouldBeNil)
 
 		nrts, err := fakeClient.TopologyV1alpha2().NodeResourceTopologies().List(context.TODO(), metav1.ListOptions{})