Skip to content

fix: record conflict failures and fix missing status patch metric - #320

Open
rawadhossain wants to merge 2 commits into
kubernetes-sigs:mainfrom
rawadhossain:fix/failures-metric-conflict-exhaustion
Open

fix: record conflict failures and fix missing status patch metric#320
rawadhossain wants to merge 2 commits into
kubernetes-sigs:mainfrom
rawadhossain:fix/failures-metric-conflict-exhaustion

Conversation

@rawadhossain

@rawadhossain rawadhossain commented Jul 22, 2026

Copy link
Copy Markdown
Member

Description

This change improves failure observability by recording conflict-specific failure reasons in node_readiness_failures_total, fixing a missing failure metric in the node reconciler, and adding logs where API conflicts can actually occur.

Previously, conflict exhausted taint operations were recorded as generic taint errors, so it wasn't possible to distinguish them from other patch errors. The rule status patch error path in the node reconciler also logged failures without recording a failure metric.

To fix this:

  • add conflict-specific failure reasons:
    • AddTaintConflictExhausted
    • RemoveTaintConflictExhausted
    • StatusPatchConflictExhausted
  • record status patch failures in the node reconciler
  • add structured V(1) conflict logs with rule and operation at addTaintBySpec and removeTaint
  • update monitoring.md with the new reason label values

Related to Issue #182

Type of Change

/kind feature

Checklist

  • make test passes
  • make lint passes

@kubernetes-prow

Copy link
Copy Markdown

@rawadhossain: The label(s) kind/improvement cannot be applied, because the repository doesn't have them.

Details

In response to this:

Description

This change improves failure observability by recording conflict-specific failure reasons in node_readiness_failures_total and fixing a missing failure metric in the node reconciler.

Previously, conflict exhausted taint operations were recorded as generic taint errors, so it wasn't possible to distinguish them from other patch errors. The rule status patch error path in the node reconciler also logged failures without recording a failure metric.

To fix this:

  • add conflict-specific failure reasons:
  • AddTaintConflictExhausted
  • RemoveTaintConflictExhausted
  • StatusPatchConflictExhausted
  • record status patch failures in the node reconciler
  • add a structured operation field to evaluateRuleForNode error logs
  • update monitoring.md with the new reason label values

Related to Issue #182

Type of Change

/kind improvement

Checklist

  • make test passes
  • make lint passes

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.

@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

Details 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

@netlify

netlify Bot commented Jul 22, 2026

Copy link
Copy Markdown

Deploy Preview for node-readiness-controller ready!

Name Link
🔨 Latest commit f04128c
🔍 Latest deploy log https://app.netlify.com/projects/node-readiness-controller/deploys/6a89f347acb792000898f316
😎 Deploy Preview https://deploy-preview-320--node-readiness-controller.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 project configuration.

@kubernetes-prow
kubernetes-prow Bot requested review from dchen1107 and mrunalp July 22, 2026 19:23
@kubernetes-prow kubernetes-prow Bot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 22, 2026
@kubernetes-prow

Copy link
Copy Markdown

Hi @rawadhossain. 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.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

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.

Details

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.

@kubernetes-prow kubernetes-prow Bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 22, 2026

@AvineshTripathi AvineshTripathi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

left my initial thoughts here!

Comment thread internal/controller/node_controller.go Outdated
"ruleResourceVersion", rule.ResourceVersion)

if err := r.evaluateRuleForNode(ctx, rule, node); err != nil {
operation := "unknown"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we make a util function here?

case errors.Is(err, errRemoveTaintFailed):
operation = "remove_taint"
}
log.Error(err, "Failed to evaluate rule for node",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think adding operations would add value. We already are logging the error. If the idea here is to standardise error messaging, then that is a whole different discussion.

case errors.Is(err, errRemoveTaintFailed):
operation = "remove_taint"
}
log.Error(err, "Failed to evaluate node for rule", "rule", rule.Name, "node", node.Name, "operation", operation)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same as above. we already log errors.

log := ctrl.LoggerFrom(ctx)

var errors []string
var cleanupErrors []string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

any particular reason to change this?

@AvineshTripathi

Copy link
Copy Markdown
Contributor

cc @Priyankasaggu11929 I remember you had some thoughts on this

@kubernetes-prow kubernetes-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 5, 2026
@kubernetes-prow kubernetes-prow Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 22, 2026
Signed-off-by: Rawad Hossain <rawad.hossain00@gmail.com>
@rawadhossain
rawadhossain force-pushed the fix/failures-metric-conflict-exhaustion branch from 9d27a99 to f04128c Compare August 22, 2026 19:06
@kubernetes-prow kubernetes-prow Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 22, 2026
@rawadhossain

Copy link
Copy Markdown
Member Author

Hi @AvineshTripathi
gave this a fresh look. Actually built api_conflicts_total locally and live tested it to see if it was worth keeping. Most of what it would show either duplicates the ConflictExhausted reasons already in this PR, or just stay at zero where conflicts don't happen.
So I reworked this PR to go with the logs approach instead, which also addresses your earlier comments. PTAL.

@ajaysundark

Copy link
Copy Markdown
Contributor

The largest source of api conflicts (409s) don't rise up because they are handled as merge patch. We should check this after #343 is merged, only after when status conflicts will 'surface'

bhuvan-somisetty added a commit to bhuvan-somisetty/node-readiness-controller that referenced this pull request Aug 22, 2026
Deferred to kubernetes-sigs#320/kubernetes-sigs#288 per review feedback so conflict metrics get handled holistically instead of piecemeal here.
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. 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.

3 participants