Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apis/nfd: drop the private template caching fields #1477

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

marquiz
Copy link
Contributor

@marquiz marquiz commented Nov 29, 2023

Drop the private fields – that were supposed to be used for caching parsed templates – from the Rule type. Keep the API typedefs cleaner and simpler. Moreover, the caching was not even used in practice, effectively complicating code without any benefit: the way the types are used in nfd-master creates a local copy of Rule type storing the cached template in the copy, wasting it from any future users.

There are also other possible caveats in caching like we tried to do it. For example the objects returned by the api lister are supposed to be treated as read-only - in particular if we would be to modify them there should at least be proper locking in place as nfd-master potentially processes the same rule (the same Go object) in parallel for multiple nodes. If any optimization like this will be pursued it should be done properly, probably with private type(s) at the consumer's end, not contaminating the API types.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 29, 2023
Copy link

netlify bot commented Nov 29, 2023

Deploy Preview for kubernetes-sigs-nfd ready!

Name Link
🔨 Latest commit b2d9e15
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-nfd/deploys/657c12d23f0d560007897b7c
😎 Deploy Preview https://deploy-preview-1477--kubernetes-sigs-nfd.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 29, 2023
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 29, 2023
@marquiz
Copy link
Contributor Author

marquiz commented Dec 1, 2023

/assign @ArangoGutierrez

Drop the private fields – that were supposed to be used for caching parsed
templates – from the Rule type. Keep the API typedefs cleaner and
simpler. Moreover, the caching was not even used in practice,
effectively complicating code without any benefit: the way the types
are used in nfd-master creates a local copy of Rule type storing the
cached template in the copy, wasting it from any future users.

There are also other possible caveats in caching like we tried to do it.
For example the objects returned by the api lister are supposed to be
treated as read-only - in particular if we would be to modify them there
should at least be proper locking in place as nfd-master potentially
processes the same rule (the same Go object) in parallel for multiple
nodes. If any optimization like this will be pursued it should be done
properly, probably with private type(s) at the consumer's end, not
contaminating the API types.
@marquiz
Copy link
Contributor Author

marquiz commented Dec 15, 2023

Rebased

Copy link
Contributor

@ArangoGutierrez ArangoGutierrez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 15, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: af19b85f6b1a1416a3f46ba140182973dcdd8dc4

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ArangoGutierrez, marquiz

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [ArangoGutierrez,marquiz]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

codecov bot commented Dec 15, 2023

Codecov Report

Merging #1477 (b2d9e15) into master (443ff80) will increase coverage by 1.13%.
Report is 8 commits behind head on master.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1477      +/-   ##
==========================================
+ Coverage   31.39%   32.53%   +1.13%     
==========================================
  Files          59       59              
  Lines        7555     7810     +255     
==========================================
+ Hits         2372     2541     +169     
- Misses       4939     5014      +75     
- Partials      244      255      +11     
Files Coverage Δ
pkg/apis/nfd/v1alpha1/rule.go 87.56% <100.00%> (+6.50%) ⬆️
pkg/apis/nfd/v1alpha1/zz_generated.deepcopy.go 37.70% <ø> (+11.80%) ⬆️

... and 2 files with indirect coverage changes

@k8s-ci-robot k8s-ci-robot merged commit 884edc6 into kubernetes-sigs:master Dec 15, 2023
12 checks passed
@marquiz marquiz deleted the devel/api-cleanup branch December 15, 2023 15:33
@marquiz marquiz mentioned this pull request Dec 20, 2023
24 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants