Skip to content

Set ActiveDeadlineSeconds and BackoffLimit on device-init Job#75

Draft
razo7 wants to merge 3 commits into
medik8s:mainfrom
razo7:fix/device-init-job-timeout
Draft

Set ActiveDeadlineSeconds and BackoffLimit on device-init Job#75
razo7 wants to merge 3 commits into
medik8s:mainfrom
razo7:fix/device-init-job-timeout

Conversation

@razo7

@razo7 razo7 commented Jul 19, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Sets ActiveDeadlineSeconds (300s) and BackoffLimit (1) on the device-init Job, matching the cleanup Job pattern. Emits a warning event on failure to aid diagnosis.

Why is this needed?

The device-init Job had no deadline or backoff limit, causing pods to hang indefinitely when storage is unavailable (e.g. Ceph degraded after node reboot).
This blocks agent deployment with no operator-level signal of the problem.

Related: RHWA-1370

How was this tested?

  • Two new unit tests added (envtest):
    • Verifies ActiveDeadlineSeconds and BackoffLimit are set on created Job
    • Simulates terminal Job failure, verifies warning event emission and Job recreation
  • Full controller test suite passes (34 specs)
  • go vet clean

Checklist

  • Code follows existing patterns (mirrors cleanup Job spec)
  • Unit tests pass
  • No downstream or product references

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of failed SBR device initialization jobs.
    • Failed initialization jobs are now detected via job failure conditions, automatically removed, and retried.
    • Added warning notifications when device initialization fails (with a dedicated failure reason).
  • Reliability

    • Device initialization jobs now use defined timeout and backoff settings.
    • Adjusted job TTL after completion to keep cleanup predictable.
  • Tests

    • Added coverage for job timeout/backoff settings and warning event emission.

The device-init Job had no deadline or backoff limit, causing pods to
hang indefinitely when storage is unavailable (e.g. Ceph degraded after
node reboot). Set ActiveDeadlineSeconds=300s and BackoffLimit=1 to match
the cleanup Job pattern. Emit a warning event on failure to aid
diagnosis.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-ci

openshift-ci Bot commented Jul 19, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci

openshift-ci Bot commented Jul 19, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: razo7

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

The pull request process is described 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

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@razo7, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 56 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a569b0b3-3f7f-4ba9-bd4f-fa9966107959

📥 Commits

Reviewing files that changed from the base of the PR and between a9e209c and f099ff6.

📒 Files selected for processing (1)
  • internal/controller/storagebasedremediationconfig_controller.go
📝 Walkthrough

Walkthrough

The controller configures SBR device-init Jobs with explicit deadlines and retry limits, detects failed Jobs through conditions, emits warning events, deletes failed Jobs, and allows recreation during subsequent reconciliation. Tests cover Job settings and failure-event behavior.

Changes

SBR device initialization

Layer / File(s) Summary
Device-init Job configuration
internal/controller/storagebasedremediationconfig_controller.go, internal/controller/storagebasedremediationconfig_controller_test.go
Adds exported deadline and backoff constants, applies Job timing settings, updates TTL pointer construction, and verifies the generated Job fields.
Failed Job detection and recreation
internal/controller/storagebasedremediationconfig_controller.go, internal/controller/storagebasedremediationconfig_controller_test.go
Skips terminating Jobs, detects JobFailed conditions, emits a warning event, deletes the failed Job, and validates the event during reconciliation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Reconciler
  participant KubernetesAPI
  participant EventRecorder
  Reconciler->>KubernetesAPI: Read device-init Job status
  KubernetesAPI-->>Reconciler: Return JobFailed condition
  Reconciler->>EventRecorder: Emit SBRDeviceInitFailed warning
  Reconciler->>KubernetesAPI: Delete failed Job
  Reconciler->>KubernetesAPI: Recreate Job on next reconcile
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: setting ActiveDeadlineSeconds and BackoffLimit on the device-init Job.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/controller/storagebasedremediationconfig_controller.go`:
- Around line 910-925: In the failed-job handling loop around
existingJob.Status.Conditions, first detect whether existingJob has a
DeletionTimestamp and skip the failure-processing path while deletion is in
progress. Preserve the existing logging, warning event, deletion, and return
behavior for failed Jobs that are not already terminating.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4eb08c5d-8da8-403c-b933-84682aa2beff

📥 Commits

Reviewing files that changed from the base of the PR and between e345299 and 5d178a1.

📒 Files selected for processing (2)
  • internal/controller/storagebasedremediationconfig_controller.go
  • internal/controller/storagebasedremediationconfig_controller_test.go

Comment thread internal/controller/storagebasedremediationconfig_controller.go
razo7 and others added 2 commits July 19, 2026 18:13
Prevents hot-looping, redundant Delete calls, and duplicate warning
events when a deleted Job lingers in Terminating state (e.g. pods
stuck on volume unmounts).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Returning (None, nil) allowed the caller to fall through to DaemonSet
creation while the failed Job was still terminating. Return an error
so the caller requeues with backoff instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@razo7

razo7 commented Jul 19, 2026

Copy link
Copy Markdown
Member Author

/test 5.0-openshift-e2e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant