Skip to content

HYPERFLEET-708 - doc: add Time-based stability preconditions and update related adapter config example#78

Open
86254860 wants to merge 1 commit intoopenshift-hyperfleet:mainfrom
86254860:HYPERFLEET-708
Open

HYPERFLEET-708 - doc: add Time-based stability preconditions and update related adapter config example#78
86254860 wants to merge 1 commit intoopenshift-hyperfleet:mainfrom
86254860:HYPERFLEET-708

Conversation

@86254860
Copy link
Contributor

@86254860 86254860 commented Mar 13, 2026

Summary by CodeRabbit

  • New Features

    • Time-based stability preconditions for readiness checks, including configurable timeout, retry and backoff, and capture of cluster metadata; readiness now supports a stability window for self-healing scenarios.
  • Documentation

    • Expanded authoring guide with patterns, examples, and best practices for time-based preconditions, timestamp arithmetic, and stability-window usage.

@openshift-ci openshift-ci bot requested review from Mischulee and xueli181114 March 13, 2026 09:22
@openshift-ci
Copy link

openshift-ci bot commented Mar 13, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign 86254860 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

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

Walkthrough

This change updates an adapter task example and docs to introduce a time-based stability precondition. The task captures currentTime, clusterName, and generation; calls the Kubernetes API with timeout/retry/backoff; derives two conditions (clusterNotReady and clusterReadyTTL) replacing the prior readyConditionStatus; and validates using clusterNotReady || clusterReadyTTL to allow execution when the cluster has been Ready for a configured TTL. Documentation adds a "Time-based stability preconditions" subsection with guidance, examples, and timestamp arithmetic recommendations.

Sequence Diagram(s)

sequenceDiagram
    participant Operator
    participant AdapterTask
    participant K8sAPI
    participant TimeSource

    Operator->>AdapterTask: trigger precondition evaluation
    AdapterTask->>TimeSource: capture now() as currentTime
    AdapterTask->>K8sAPI: GET cluster status (with timeout, retry, backoff)
    K8sAPI-->>AdapterTask: clusterStatus (conditions, lastTransitionTime, generation, name)
    AdapterTask->>AdapterTask: derive clusterNotReady and clusterReadyTTL using currentTime and lastTransitionTime
    AdapterTask->>AdapterTask: evaluate validationCheck = clusterNotReady || clusterReadyTTL
    alt validationCheck true
        AdapterTask->>Operator: allow resource execution (proceed)
    else validationCheck false
        AdapterTask->>Operator: block or retry later
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main changes: adding documentation about time-based stability preconditions and updating a related adapter config example file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@charts/examples/kubernetes/adapter-task-config.yaml`:
- Around line 56-57: The precondition uses
timestamp(readyCondition.last_transition_time) without guarding for a missing
last_transition_time, which can throw; update the boolean expression around
readyCondition in the condition (the expression using readyCondition,
last_transition_time, timestamp, and currentTime) to explicitly handle a
null/absent last_transition_time (e.g., treat missing last_transition_time as
stale by adding readyCondition.last_transition_time == null || before doing
timestamp math) so timestamp() is only called when last_transition_time is
present.

In `@docs/adapter-authoring-guide.md`:
- Around line 383-401: The example expression uses
timestamp(readyCondition.last_transition_time) without guarding for missing
last_transition_time; update the precondition expression to short-circuit when
readyCondition or readyCondition.last_transition_time is absent (e.g. use
readyCondition == null || readyCondition.status != "True" ||
readyCondition.last_transition_time == null || (timestamp(currentTime) -
timestamp(readyCondition.last_transition_time)).getSeconds() >= 300) so
timestamp(...) is only called when last_transition_time exists; adjust the
capture/expression lines referencing readyCondition and currentTime accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7b200dbb-0c0e-48b6-abcb-7d87cb06ed77

📥 Commits

Reviewing files that changed from the base of the PR and between 3f8b4d6 and 0ffabea.

📒 Files selected for processing (2)
  • charts/examples/kubernetes/adapter-task-config.yaml
  • docs/adapter-authoring-guide.md

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
charts/examples/kubernetes/adapter-task-config.yaml (1)

47-58: Make clusterReadyTTL reflect readiness, not just condition age.

This turns true whenever the Ready condition is older than 300s, even if the current status is "False". Line 58 still behaves correctly because clusterNotReady is ORed in, but the capture no longer matches its name/comments and is easy to reuse incorrectly later. Please mirror the same adjustment in the guide snippet so the documented pattern stays aligned.

♻️ Suggested adjustment
       - name: "clusterReadyTTL"
         expression: |
-          (timestamp(now()) - timestamp(
-            status.conditions.filter(c, c.type == "Ready").size() > 0
-              ? status.conditions.filter(c, c.type == "Ready")[0].last_transition_time
-              : now()
-          )).getSeconds() >= 300
+          status.conditions.filter(c, c.type == "Ready").size() > 0
+            && status.conditions.filter(c, c.type == "Ready")[0].status == "True"
+            && (timestamp(now()) - timestamp(
+              status.conditions.filter(c, c.type == "Ready")[0].last_transition_time
+            )).getSeconds() >= 300

As per coding guidelines, "-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/examples/kubernetes/adapter-task-config.yaml` around lines 47 - 58,
The clusterReadyTTL expression currently only checks the Ready condition age and
can be true even when Ready.status == "False"; update the clusterReadyTTL
expression to first select the Ready condition, ensure its status equals "True",
then compute age >= 300s (i.e., require condition exists AND condition.status ==
"True" AND (timestamp(now()) -
timestamp(condition.last_transition_time)).getSeconds() >= 300), and apply the
same corrected snippet to the guide example so the documented pattern matches;
references: clusterReadyTTL, validationCheck, clusterNotReady.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@charts/examples/kubernetes/adapter-task-config.yaml`:
- Around line 47-58: The clusterReadyTTL expression currently only checks the
Ready condition age and can be true even when Ready.status == "False"; update
the clusterReadyTTL expression to first select the Ready condition, ensure its
status equals "True", then compute age >= 300s (i.e., require condition exists
AND condition.status == "True" AND (timestamp(now()) -
timestamp(condition.last_transition_time)).getSeconds() >= 300), and apply the
same corrected snippet to the guide example so the documented pattern matches;
references: clusterReadyTTL, validationCheck, clusterNotReady.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cd9a6879-3ccc-45c0-b111-d623c2c18a2d

📥 Commits

Reviewing files that changed from the base of the PR and between 0ffabea and 321f3ca.

📒 Files selected for processing (2)
  • charts/examples/kubernetes/adapter-task-config.yaml
  • docs/adapter-authoring-guide.md

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant