Repository: kubernetes-sigs/node-feature-discovery
Pull request #1198 (2023-04-28 07:36:11)

nfd-master: refactor api-controller object handling
Split out resolving of node name (of the node to be updated) into a separate function. Makes it possible to add unit tests. Also. do unconditional type casting in the handler functions – that shouldn't fail unless there is a really serious internal inconsistency in the codebase so it should be ok to panic.

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/1198#" 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":[]} -->
netlify[bot]: ### <span aria-hidden="true">👷</span> Deploy Preview for *kubernetes-sigs-nfd* processing.


|  Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 51306fce77f57a2a9491a919ed992054a1a58daf |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/sites/kubernetes-sigs-nfd/deploys/644b776c1c67530008173d96 |
codecov[bot]: ## [Codecov](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) Report
> Merging [#1198](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) (51306fc) into [master](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/commit/611ed65e432c5dcdd54507ff996e33381ba0fe6c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) (611ed65) will **increase** coverage by `2.10%`.
> The diff coverage is `69.23%`.

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198/graphs/tree.svg?width=650&height=150&src=pr&token=mEZgtJQ1vg&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)

```diff
@@            Coverage Diff             @@
##           master    #1198      +/-   ##
==========================================
+ Coverage   26.77%   28.87%   +2.10%     
==========================================
  Files          51       51              
  Lines        7104     7106       +2     
==========================================
+ Hits         1902     2052     +150     
+ Misses       4999     4845     -154     
- Partials      203      209       +6     
```


| [Impacted Files](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) | Coverage Δ | |
|---|---|---|
| [pkg/apis/nfd/v1alpha1/feature.go](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs#diff-cGtnL2FwaXMvbmZkL3YxYWxwaGExL2ZlYXR1cmUuZ28=) | `91.96% <ø> (+76.78%)` | :arrow_up: |
| [pkg/nfd-master/nfd-api-controller.go](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs#diff-cGtnL25mZC1tYXN0ZXIvbmZkLWFwaS1jb250cm9sbGVyLmdv) | `14.13% <69.23%> (+14.13%)` | :arrow_up: |

... and [1 file with indirect coverage changes](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)

</details>
codecov[bot]: ## [Codecov](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) Report
> Merging [#1198](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) (51306fc) into [master](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/commit/611ed65e432c5dcdd54507ff996e33381ba0fe6c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) (611ed65) will **increase** coverage by `2.10%`.
> The diff coverage is `69.23%`.

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198/graphs/tree.svg?width=650&height=150&src=pr&token=mEZgtJQ1vg&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)

```diff
@@            Coverage Diff             @@
##           master    #1198      +/-   ##
==========================================
+ Coverage   26.77%   28.87%   +2.10%     
==========================================
  Files          51       51              
  Lines        7104     7106       +2     
==========================================
+ Hits         1902     2052     +150     
+ Misses       4999     4845     -154     
- Partials      203      209       +6     
```


| [Impacted Files](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) | Coverage Δ | |
|---|---|---|
| [pkg/apis/nfd/v1alpha1/feature.go](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs#diff-cGtnL2FwaXMvbmZkL3YxYWxwaGExL2ZlYXR1cmUuZ28=) | `91.96% <ø> (+76.78%)` | :arrow_up: |
| [pkg/nfd-master/nfd-api-controller.go](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs#diff-cGtnL25mZC1tYXN0ZXIvbmZkLWFwaS1jb250cm9sbGVyLmdv) | `14.13% <69.23%> (+14.13%)` | :arrow_up: |

... and [1 file with indirect coverage changes](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)

</details>
codecov[bot]: ## [Codecov](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) Report
> Merging [#1198](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) (b2cecc9) into [master](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/commit/611ed65e432c5dcdd54507ff996e33381ba0fe6c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) (611ed65) will **increase** coverage by `2.06%`.
> The diff coverage is `26.31%`.

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198/graphs/tree.svg?width=650&height=150&src=pr&token=mEZgtJQ1vg&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)

```diff
@@            Coverage Diff             @@
##           master    #1198      +/-   ##
==========================================
+ Coverage   26.77%   28.83%   +2.06%     
==========================================
  Files          51       51              
  Lines        7104     7102       -2     
==========================================
+ Hits         1902     2048     +146     
+ Misses       4999     4845     -154     
- Partials      203      209       +6     
```


| [Impacted Files](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) | Coverage Δ | |
|---|---|---|
| [pkg/apis/nfd/v1alpha1/feature.go](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs#diff-cGtnL2FwaXMvbmZkL3YxYWxwaGExL2ZlYXR1cmUuZ28=) | `91.96% <ø> (+76.78%)` | :arrow_up: |
| [pkg/nfd-master/nfd-api-controller.go](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs#diff-cGtnL25mZC1tYXN0ZXIvbmZkLWFwaS1jb250cm9sbGVyLmdv) | `10.22% <26.31%> (+10.22%)` | :arrow_up: |

... and [1 file with indirect coverage changes](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)

</details>
codecov[bot]: ## [Codecov](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) Report
> Merging [#1198](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) (b2cecc9) into [master](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/commit/1405290f199647b65f2f1a4e13817caa8b8b5eaf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) (1405290) will **increase** coverage by `0.13%`.
> The diff coverage is `26.31%`.

> :exclamation: Current head b2cecc9 differs from pull request most recent head 3d3815c. Consider uploading reports for the commit 3d3815c to get more accurate results

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198/graphs/tree.svg?width=650&height=150&src=pr&token=mEZgtJQ1vg&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)

```diff
@@            Coverage Diff             @@
##           master    #1198      +/-   ##
==========================================
+ Coverage   28.70%   28.83%   +0.13%     
==========================================
  Files          51       51              
  Lines        7104     7102       -2     
==========================================
+ Hits         2039     2048       +9     
+ Misses       4856     4845      -11     
  Partials      209      209              
```


| [Impacted Files](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) | Coverage Δ | |
|---|---|---|
| [pkg/nfd-master/nfd-api-controller.go](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs#diff-cGtnL25mZC1tYXN0ZXIvbmZkLWFwaS1jb250cm9sbGVyLmdv) | `10.22% <26.31%> (+10.22%)` | :arrow_up: |

</details>
codecov[bot]: ## [Codecov](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) Report
> Merging [#1198](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) (3d3815c) into [master](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/commit/1405290f199647b65f2f1a4e13817caa8b8b5eaf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) (1405290) will **increase** coverage by `0.13%`.
> The diff coverage is `26.31%`.

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198/graphs/tree.svg?width=650&height=150&src=pr&token=mEZgtJQ1vg&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)

```diff
@@            Coverage Diff             @@
##           master    #1198      +/-   ##
==========================================
+ Coverage   28.70%   28.83%   +0.13%     
==========================================
  Files          51       51              
  Lines        7104     7102       -2     
==========================================
+ Hits         2039     2048       +9     
+ Misses       4856     4845      -11     
  Partials      209      209              
```


| [Impacted Files](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) | Coverage Δ | |
|---|---|---|
| [pkg/nfd-master/nfd-api-controller.go](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs#diff-cGtnL25mZC1tYXN0ZXIvbmZkLWFwaS1jb250cm9sbGVyLmdv) | `10.22% <26.31%> (+10.22%)` | :arrow_up: |

</details>
codecov[bot]: ## [Codecov](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) Report
> Merging [#1198](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) (3d3815c) into [master](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/commit/1405290f199647b65f2f1a4e13817caa8b8b5eaf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) (1405290) will **increase** coverage by `0.13%`.
> The diff coverage is `26.31%`.

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198/graphs/tree.svg?width=650&height=150&src=pr&token=mEZgtJQ1vg&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)

```diff
@@            Coverage Diff             @@
##           master    #1198      +/-   ##
==========================================
+ Coverage   28.70%   28.83%   +0.13%     
==========================================
  Files          51       51              
  Lines        7104     7102       -2     
==========================================
+ Hits         2039     2048       +9     
+ Misses       4856     4845      -11     
  Partials      209      209              
```


| [Impacted Files](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) | Coverage Δ | |
|---|---|---|
| [pkg/nfd-master/nfd-api-controller.go](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs#diff-cGtnL25mZC1tYXN0ZXIvbmZkLWFwaS1jb250cm9sbGVyLmdv) | `10.22% <26.31%> (+10.22%)` | :arrow_up: |

</details>
k8s-ci-robot: LGTM label has been added.  <details>Git tree hash: 0c2d0d7049559b4bbe3e577f559dfc334bfedb94</details>
k8s-ci-robot: New changes are detected. LGTM label has been removed.
codecov[bot]: ## [Codecov](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) Report
> :exclamation: No coverage uploaded for pull request base (`master@64c1188`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs#section-missing-base-commit).
> The diff coverage is `26.31%`.

> :exclamation: Current head 3d3815c differs from pull request most recent head 6d0be51. Consider uploading reports for the commit 6d0be51 to get more accurate results

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198/graphs/tree.svg?width=650&height=150&src=pr&token=mEZgtJQ1vg&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)

```diff
@@            Coverage Diff            @@
##             master    #1198   +/-   ##
=========================================
  Coverage          ?   28.83%           
=========================================
  Files             ?       51           
  Lines             ?     7102           
  Branches          ?        0           
=========================================
  Hits              ?     2048           
  Misses            ?     4845           
  Partials          ?      209           
```


| [Impacted Files](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) | Coverage Δ | |
|---|---|---|
| [pkg/nfd-master/nfd-api-controller.go](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs#diff-cGtnL25mZC1tYXN0ZXIvbmZkLWFwaS1jb250cm9sbGVyLmdv) | `10.22% <26.31%> (ø)` | |

</details>
codecov[bot]: ## [Codecov](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) Report
> Merging [#1198](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) (6d0be51) into [master](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/commit/64c118892882662acc4b44b5510c70497df67c2c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) (64c1188) will **increase** coverage by `0.13%`.
> The diff coverage is `26.31%`.

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198/graphs/tree.svg?width=650&height=150&src=pr&token=mEZgtJQ1vg&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs)

```diff
@@            Coverage Diff             @@
##           master    #1198      +/-   ##
==========================================
+ Coverage   28.70%   28.83%   +0.13%     
==========================================
  Files          51       51              
  Lines        7104     7102       -2     
==========================================
+ Hits         2039     2048       +9     
+ Misses       4856     4845      -11     
  Partials      209      209              
```


| [Impacted Files](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) | Coverage Δ | |
|---|---|---|
| [pkg/nfd-master/nfd-api-controller.go](https://codecov.io/gh/kubernetes-sigs/node-feature-discovery/pull/1198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs#diff-cGtnL25mZC1tYXN0ZXIvbmZkLWFwaS1jb250cm9sbGVyLmdv) | `10.22% <26.31%> (+10.22%)` | :arrow_up: |

</details>

Patch:
diff --git a/pkg/nfd-master/nfd-api-controller.go b/pkg/nfd-master/nfd-api-controller.go
index 714037afb..b39a62fb4 100644
--- a/pkg/nfd-master/nfd-api-controller.go
+++ b/pkg/nfd-master/nfd-api-controller.go
@@ -17,8 +17,10 @@ limitations under the License.
 package nfdmaster
 
 import (
+	"fmt"
 	"time"
 
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	utilruntime "k8s.io/apimachinery/pkg/util/runtime"
 	restclient "k8s.io/client-go/rest"
 	"k8s.io/client-go/tools/cache"
@@ -61,19 +63,19 @@ func newNfdController(config *restclient.Config, nfdApiControllerOptions nfdApiC
 		featureInformer := informerFactory.Nfd().V1alpha1().NodeFeatures()
 		if _, err := featureInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
 			AddFunc: func(obj interface{}) {
-				key, _ := cache.MetaNamespaceKeyFunc(obj)
-				klog.V(2).Infof("NodeFeature %v added", key)
-				c.updateOneNode(obj)
+				nfr := obj.(*nfdv1alpha1.NodeFeature)
+				klog.V(2).Infof("NodeFeature %s/%s added", nfr.Namespace, nfr.Name)
+				c.updateOneNode("NodeFeature", nfr)
 			},
 			UpdateFunc: func(oldObj, newObj interface{}) {
-				key, _ := cache.MetaNamespaceKeyFunc(newObj)
-				klog.V(2).Infof("NodeFeature %v updated", key)
-				c.updateOneNode(newObj)
+				nfr := newObj.(*nfdv1alpha1.NodeFeature)
+				klog.V(2).Infof("NodeFeature %s/%s updated", nfr.Namespace, nfr.Name)
+				c.updateOneNode("NodeFeature", nfr)
 			},
 			DeleteFunc: func(obj interface{}) {
-				key, _ := cache.MetaNamespaceKeyFunc(obj)
-				klog.V(2).Infof("NodeFeature %v deleted", key)
-				c.updateOneNode(obj)
+				nfr := obj.(*nfdv1alpha1.NodeFeature)
+				klog.V(2).Infof("NodeFeature %s/%s deleted", nfr.Namespace, nfr.Name)
+				c.updateOneNode("NodeFeature", nfr)
 			},
 		}); err != nil {
 			return nil, err
@@ -128,26 +130,24 @@ func (c *nfdController) stop() {
 	}
 }
 
-func (c *nfdController) updateOneNode(obj interface{}) {
-	o, ok := obj.(*nfdv1alpha1.NodeFeature)
-	if !ok {
-		klog.Errorf("not a NodeFeature object (but of type %T): %v", obj, obj)
+func (c *nfdController) updateOneNode(typ string, obj metav1.Object) {
+	nodeName, err := getNodeNameForObj(obj)
+	if err != nil {
+		klog.Errorf("failed to determine node name for %s %s/%s: %v", typ, obj.GetNamespace(), obj.GetName(), err)
 		return
 	}
+	c.updateOneNodeChan <- nodeName
+}
 
-	nodeName, ok := o.Labels[nfdv1alpha1.NodeFeatureObjNodeNameLabel]
+func getNodeNameForObj(obj metav1.Object) (string, error) {
+	nodeName, ok := obj.GetLabels()[nfdv1alpha1.NodeFeatureObjNodeNameLabel]
 	if !ok {
-		klog.Errorf("no node name for NodeFeature object %s/%s: %q label is missing",
-			o.Namespace, o.Name, nfdv1alpha1.NodeFeatureObjNodeNameLabel)
-		return
+		return "", fmt.Errorf("%q label is missing", nfdv1alpha1.NodeFeatureObjNodeNameLabel)
 	}
 	if nodeName == "" {
-		klog.Errorf("no node name for NodeFeature object %s/%s: %q label is empty",
-			o.Namespace, o.Name, nfdv1alpha1.NodeFeatureObjNodeNameLabel)
-		return
+		return "", fmt.Errorf("%q label is empty", nfdv1alpha1.NodeFeatureObjNodeNameLabel)
 	}
-
-	c.updateOneNodeChan <- nodeName
+	return nodeName, nil
 }
 
 func (c *nfdController) updateAllNodes() {


Test patch:
diff --git a/pkg/nfd-master/nfd-api-controller_test.go b/pkg/nfd-master/nfd-api-controller_test.go
new file mode 100644
index 000000000..bffa9ffc2
--- /dev/null
+++ b/pkg/nfd-master/nfd-api-controller_test.go
@@ -0,0 +1,44 @@
+/*
+Copyright 2023 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 nfdmaster
+
+import (
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	nfdv1alpha1 "sigs.k8s.io/node-feature-discovery/pkg/apis/nfd/v1alpha1"
+)
+
+func TestGetNodeNameForObj(t *testing.T) {
+	// Test missing label
+	obj := &nfdv1alpha1.NodeFeature{ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}}
+	_, err := getNodeNameForObj(obj)
+	assert.Error(t, err)
+
+	// Test empty label
+	obj.SetLabels(map[string]string{nfdv1alpha1.NodeFeatureObjNodeNameLabel: ""})
+	_, err = getNodeNameForObj(obj)
+	assert.Error(t, err)
+
+	// Test proper node name
+	obj.SetLabels(map[string]string{nfdv1alpha1.NodeFeatureObjNodeNameLabel: "node-1"})
+	n, err := getNodeNameForObj(obj)
+	assert.Nil(t, err)
+	assert.Equal(t, n, "node-1")
+}