Skip to content

Restrict checks for image existence #734

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

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

qbarrand
Copy link
Contributor

@qbarrand qbarrand commented Feb 8, 2024

Before populating the NodeModulesConfig object, only check if built or signed image exist on the registry.
Add a log message when the NodeModulesConfig is not populated for that reason.

/cc @yevgeny-shnaidman @mresvanis

Copy link

netlify bot commented Feb 8, 2024

Deploy Preview for kubernetes-sigs-kmm ready!

Name Link
🔨 Latest commit 5f3fbde
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kmm/deploys/65ca409678aa6a000845edeb
😎 Deploy Preview https://deploy-preview-734--kubernetes-sigs-kmm.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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 8, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qbarrand

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:

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

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 8, 2024
@codecov-commenter
Copy link

codecov-commenter commented Feb 8, 2024

Codecov Report

Attention: 64 lines in your changes are missing coverage. Please review.

Comparison is base (fa23a9b) 79.09% compared to head (5f3fbde) 78.40%.
Report is 10 commits behind head on main.

Files Patch % Lines
internal/controllers/module_nmc_reconciler.go 66.07% 13 Missing and 6 partials ⚠️
internal/webhook/module.go 70.96% 6 Missing and 3 partials ⚠️
...ternal/controllers/build_sign_events_reconciler.go 36.36% 5 Missing and 2 partials ⚠️
...ontrollers/node_label_module_version_reconciler.go 12.50% 7 Missing ⚠️
internal/webhook/namespace.go 61.53% 5 Missing ⚠️
...ternal/controllers/device_plugin_pod_reconciler.go 42.85% 3 Missing and 1 partial ⚠️
internal/controllers/device_plugin_reconciler.go 20.00% 4 Missing ⚠️
internal/controllers/build_sign_reconciler.go 25.00% 3 Missing ⚠️
...rnal/controllers/preflightvalidation_reconciler.go 40.00% 3 Missing ⚠️
internal/meta/labels.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #734      +/-   ##
==========================================
- Coverage   79.09%   78.40%   -0.69%     
==========================================
  Files          51       49       -2     
  Lines        5109     3960    -1149     
==========================================
- Hits         4041     3105     -936     
+ Misses        882      663     -219     
- Partials      186      192       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Before populating the NodeModulesConfig object, only check if built or
signed image exist on the registry.
Add a log message when the NodeModulesConfig is not populated for that
reason.
@mresvanis
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 12, 2024
@k8s-ci-robot k8s-ci-robot merged commit a7709ac into kubernetes-sigs:main Feb 12, 2024
@qbarrand qbarrand deleted the fix-image-check branch February 12, 2024 17:03
// skip updating NMC, reconciliation will kick in once the build pod is completed
return nil

if module.ShouldBeBuilt(mld) || module.ShouldBeSigned(mld) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In case Module is using pre-built image, we are not checking it existence here, so we might end up spawning the Worker pod that will fail on pulling an image. How about we change this code here, so that we always check image existence, and in case prebuilt image should exist, we log it and return an error? WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

@qbarrand i see that the PR was merged, but have not received answer for the comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A problem with doing that is that we are going to query the registry a lot. That is likely why we did not do it in the first place.

@@ -357,7 +362,7 @@ func (mnrh *moduleNMCReconcilerHelper) enableModuleOnNode(ctx context.Context, m
}

opRes, err := controllerutil.CreateOrPatch(ctx, mnrh.client, nmcObj, func() error {
err = mnrh.nmcHelper.SetModuleConfig(nmcObj, mld, &moduleConfig)
err := mnrh.nmcHelper.SetModuleConfig(nmcObj, mld, &moduleConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need a new variable here? if SetModuleConfig fail, err will be update with its value, and if it is ok then err will be updated anyway with the value of CreateOrPatch. What am i missing?

Copy link
Contributor

Choose a reason for hiding this comment

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

@qbarrand i see that the PR was merged, but have not received answer the comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

err inside the callback called CreateOrPatch and outside that callback are two different variables.
If SetModuleConfig returns an error, then CreateOrPatch likely returns that error as well. But the line

if err := mnrh.nmcHelper.SetModuleConfig(nmcObj, mld, &moduleConfig); err != nil {

does not affect the outside err.

Copy link
Contributor

Choose a reason for hiding this comment

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

and why do we care if it affects? eventually outside err will hold the return value of CreateAndPatch, so even if it holds the error code of SeModuleConfig, it will be for a short time, and it won't affect the correctness of the code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see what you mean now. Indeed we could have skipped the semicolon here - I added it out of habit because I rewrote the if statement to hold on one line. At best, this adds one pointer on the stack - I don't think it warrants a reverting PR 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

sure , no need for additional PR. Just wanted to make sure that i read the code correctly, that there is no hidden issue that i missed that required a new err variable

qbarrand added a commit to qbarrand/kernel-module-management that referenced this pull request Mar 6, 2024
Before populating the NodeModulesConfig object, only check if built or
signed image exist on the registry.
Add a log message when the NodeModulesConfig is not populated for that
reason.
k8s-ci-robot pushed a commit that referenced this pull request Mar 6, 2024
* Add a webhook for namespace deletion (#719)

This commit makes KMM set the kmm.node.k8s.io/contains-modules label on
all namespaces that contain at least one Module.
It also adds a new webhook to the bundle and the corresponding handler
in the manager.
The new webhook rejects namespace deletions if the
kmm.node.k8s.io/contains-modules label is present on the namespace.
This avoids entering situations where the namespace is being deleted and
KMM cannot create unloading Pods to honor Module deletion.

* Restrict checks for image existence (#734)

Before populating the NodeModulesConfig object, only check if built or
signed image exist on the registry.
Add a log message when the NodeModulesConfig is not populated for that
reason.

* Make slight changes to the CRDs (#736)

Module: make moduleName an optional field.
ManagedClusterModule: make spokeNamespace a required field.
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.

5 participants