Skip to content

feat(nodepool): add statuses for nodepool drift #2090

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

flavono123
Copy link
Contributor

Fixes #1785

Description

add two statuses of NodePool about drifts:

  • Drifted, as one of conditions, indicates if any NodeClaims belonging to the NodePool have drifted
  • DriftedNodeClaimCount, as a numeric field, represents the number of NodeClaims that have drifted

print the DriftedNodeClaimCount as a column of result of kubectl get nodepool

How was this change tested?

unit tests are added, make presubmit, kubectl get nodepool -owide on my local k3s

❯ k get nodepool -owide
NAME      NODECLASS   NODES   READY   AGE   WEIGHT   CPU   MEMORY   DRIFTEDNODECLAIMS
default   default                     10m                           

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: flavono123
Once this PR has been reviewed and has the lgtm label, please assign mwielgus for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 20, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @flavono123. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 20, 2025
@coveralls
Copy link

coveralls commented Mar 20, 2025

Pull Request Test Coverage Report for Build 14198715455

Details

  • 21 of 21 (100.0%) changed or added relevant lines in 1 file are covered.
  • 5 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.02%) to 81.6%

Files with Coverage Reduction New Missed Lines %
pkg/controllers/disruption/drift.go 2 89.66%
pkg/controllers/provisioning/scheduling/nodeclaim.go 3 88.51%
Totals Coverage Status
Change from base Build 14183583381: 0.02%
Covered Lines: 9677
Relevant Lines: 11859

💛 - Coveralls

@rschalo
Copy link
Contributor

rschalo commented Mar 31, 2025

Thanks for the contribution! Rather than create a separate controller for tracking this, is it possible to hook into resourceCountsFor for a NodePool in pkg/controllers/nodepool/counter/controller.go? I believe we'd able to count drifted nodes in the c.cluster.ForEachNode(...) call.

@flavono123 flavono123 force-pushed the feature/node-drift-status branch from 5e4d928 to 1ef715a Compare March 31, 2025 21:47
@jonathan-innis
Copy link
Member

/assign @rschalo

@flavono123 flavono123 marked this pull request as draft April 1, 2025 00:04
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 1, 2025
@flavono123 flavono123 force-pushed the feature/node-drift-status branch from 1ef715a to 6ec4639 Compare April 1, 2025 14:31
@flavono123 flavono123 force-pushed the feature/node-drift-status branch from 6ec4639 to a5736c7 Compare April 1, 2025 14:45
@flavono123
Copy link
Contributor Author

@rschalo i did, counting drifted nodeclaims, just like for nodes. and added setting the condition of nodepool(not sure the counter controller is the right place though)

// Set condition Drifted
driftedNodeClaimCount := nodePool.Status.Resources[ResourceDriftedNodeClaim]
if !driftedNodeClaimCount.IsZero() {
nodePool.StatusConditions().SetTrueWithReason(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

emitting an event is required too?

@flavono123 flavono123 marked this pull request as ready for review April 1, 2025 14:57
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 1, 2025
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 3, 2025
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a Drifted condition to NodePool that tells whether any nodeclaims are drifted from the desired state
5 participants