Skip to content

HYPERFLEET-978 - feat: Update adapter configs, docs, and tests to use put endpoint for status updates#113

Open
ma-hill wants to merge 1 commit into
openshift-hyperfleet:mainfrom
ma-hill:HYPERFLEET-978
Open

HYPERFLEET-978 - feat: Update adapter configs, docs, and tests to use put endpoint for status updates#113
ma-hill wants to merge 1 commit into
openshift-hyperfleet:mainfrom
ma-hill:HYPERFLEET-978

Conversation

@ma-hill
Copy link
Copy Markdown
Contributor

@ma-hill ma-hill commented May 11, 2026

Summary

This change updates adapter documentation, configs, and testing to use the

  • PUT /api/hyperfleet/v1/clusters/{cluster_id}/statuses
  • PUT /api/hyperfleet/v1/clusters/{cluster_id}/nodepools/{nodepool_id}/statuses
    which handles the idempotent upserts.

Changes made:

  • Update adapter task config templates
  • Update documentation
  • Update testing to use PUT for post action statuses updates for NodePools and Clusters

Related changes from these two PRs:

Test Plan

  • make test
  • make lint
  • E2E tests pass
  • Dev deployment properly updates statuses as expected

Jira Issue

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 11, 2026

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
Copy link
Copy Markdown

openshift-ci Bot commented May 11, 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 crizzo71 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
Copy Markdown

coderabbitai Bot commented May 11, 2026

📝 Walkthrough

Summary by CodeRabbit

  • Changes

    • Status reporting to cluster endpoints now uses HTTP PUT instead of POST.
    • Enhanced error logging for PUT status requests.
  • Documentation

    • Updated adapter authoring guide and executor documentation with PUT method examples.
  • Tests

    • Updated test configurations and assertions for the new PUT method.

Walkthrough

The changes systematically update the HTTP method used for status reporting from POST to PUT across the codebase. This includes modifying the reportClusterStatus post-action configuration in the adapter template, updating all documentation examples and guides to reflect PUT usage for status endpoints, and updating test configurations and assertions to expect PUT requests instead of POST. A failure logging statement was also added to the PUT request handler in the executor to match existing POST error handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: updating configs, docs, and tests to use PUT endpoints instead of POST for status updates.
Description check ✅ Passed The description is well-structured and clearly related to the changeset, detailing the switch from POST to PUT endpoints for status reporting with specific endpoints and justification.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@ma-hill ma-hill marked this pull request as ready for review May 12, 2026 17:17
@openshift-ci openshift-ci Bot requested review from Mischulee and kuudori May 12, 2026 17:17
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 12, 2026

@ma-hill: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/presubmits-integration f02d6a0 link true /test presubmits-integration
ci/prow/lint f02d6a0 link true /test lint
ci/prow/images-images f02d6a0 link true /test images-images
ci/prow/presubmits-images f02d6a0 link true /test presubmits-images
ci/prow/unit f02d6a0 link true /test unit
ci/prow/validate-commits f02d6a0 link true /test validate-commits

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

Copy link
Copy Markdown

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/integration/executor/executor_k8s_integration_test.go (1)

86-94: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Align the mock expectation with the configured post-action method.

At Line 86 the mock only accepts PUT, but createK8sTestConfig still sends POST for /statuses (Line 298). That mismatch makes status calls fall through to 404 and breaks assertions that expect a captured status payload.

Suggested fix
-                       Method: "POST",
+                       Method: "PUT",
🤖 Prompt for 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.

In `@test/integration/executor/executor_k8s_integration_test.go` around lines 86 -
94, The test HTTP mock only handles http.MethodPut for status updates but
createK8sTestConfig sends POST to "/statuses", so update the mock handler to
accept the configured method (either change the condition to r.Method ==
http.MethodPost or allow both POST and PUT) and still unmarshal the body into
statusBody and append to mock.statusResponses; ensure the handler returns the
same 200+{"status":"accepted"} response so assertions that inspect
mock.statusResponses (from the test helper that calls createK8sTestConfig)
capture the payload.
🤖 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 `@docs/adapter-authoring-guide.md`:
- Around line 1262-1264: Several examples still document status-reporting as
POST while the canonical example uses "method": "PUT" for the status endpoint
(urlPattern: "/api/hyperfleet/v1/clusters/.*/statuses"); update every example
and sample that posts cluster statuses to use "method": "PUT" (and adjust any
surrounding narrative/sample payloads to match the PUT flow) so all references
to status-reporting consistently target the same HTTP verb and URL pattern, then
validate the changed examples against the HyperFleet architecture standards to
ensure conformity.

In `@test/integration/executor/executor_integration_test.go`:
- Around line 1302-1304: The test currently hardcodes http.MethodPut when
locating the /error-report request, but the test configuration defines that
endpoint as POST; update the condition that sets errorReportRequest to use the
configured method instead of a hardcoded PUT — e.g., replace the http.MethodPut
check with the test's expected method variable (such as errorReportMethod or
cfg.ErrorReportMethod) so the lookup uses requests[i].Method ==
expectedErrorReportMethod && strings.Contains(requests[i].Path, "/error-report")
and then assign errorReportRequest = &requests[i].

---

Outside diff comments:
In `@test/integration/executor/executor_k8s_integration_test.go`:
- Around line 86-94: The test HTTP mock only handles http.MethodPut for status
updates but createK8sTestConfig sends POST to "/statuses", so update the mock
handler to accept the configured method (either change the condition to r.Method
== http.MethodPost or allow both POST and PUT) and still unmarshal the body into
statusBody and append to mock.statusResponses; ensure the handler returns the
same 200+{"status":"accepted"} response so assertions that inspect
mock.statusResponses (from the test helper that calls createK8sTestConfig)
capture the payload.
🪄 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: Central YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: dbaef7cc-0e25-4dfc-bf42-dd60f23e98e3

📥 Commits

Reviewing files that changed from the base of the PR and between 2ff5ec0 and f02d6a0.

📒 Files selected for processing (7)
  • configs/adapter-task-config-template.yaml
  • docs/adapter-authoring-guide.md
  • internal/configloader/validator_test.go
  • internal/executor/README.md
  • internal/executor/utils.go
  • test/integration/executor/executor_integration_test.go
  • test/integration/executor/executor_k8s_integration_test.go

Comment on lines +1262 to 1264
"method": "PUT",
"urlPattern": "/api/hyperfleet/v1/clusters/.*/statuses"
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Complete the method migration in remaining examples within this guide.

These sections now document PUT, but the same file still has status-reporting references to POST (e.g., Line 1102 and Line 381). That leaves conflicting guidance for adapter authors.

Suggested fix
-        method: "POST"
+        method: "PUT"
-| **`last_updated_time`** | Adapter **reports status** (every POST, even if unchanged) | **Liveness checks** — "adapter reported recently" |
+| **`last_updated_time`** | Adapter **reports status** (every PUT, even if unchanged) | **Liveness checks** — "adapter reported recently" |

As per coding guidelines, Validate changes against HyperFleet architecture standards from the linked architecture repository.

Also applies to: 1330-1331, 1417-1419

🤖 Prompt for 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.

In `@docs/adapter-authoring-guide.md` around lines 1262 - 1264, Several examples
still document status-reporting as POST while the canonical example uses
"method": "PUT" for the status endpoint (urlPattern:
"/api/hyperfleet/v1/clusters/.*/statuses"); update every example and sample that
posts cluster statuses to use "method": "PUT" (and adjust any surrounding
narrative/sample payloads to match the PUT flow) so all references to
status-reporting consistently target the same HTTP verb and URL pattern, then
validate the changed examples against the HyperFleet architecture standards to
ensure conformity.

Comment on lines +1302 to 1304
if requests[i].Method == http.MethodPut && strings.Contains(requests[i].Path, "/error-report") {
errorReportRequest = &requests[i]
break
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use the configured method in the /error-report request assertion.

Line 1302 now looks for PUT, but this test config still defines /error-report as POST (Line 1257). The assertion can fail even when the call is correctly made.

Suggested fix
-       if requests[i].Method == http.MethodPut && strings.Contains(requests[i].Path, "/error-report") {
+       if requests[i].Method == http.MethodPost && strings.Contains(requests[i].Path, "/error-report") {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if requests[i].Method == http.MethodPut && strings.Contains(requests[i].Path, "/error-report") {
errorReportRequest = &requests[i]
break
if requests[i].Method == http.MethodPost && strings.Contains(requests[i].Path, "/error-report") {
errorReportRequest = &requests[i]
break
🤖 Prompt for 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.

In `@test/integration/executor/executor_integration_test.go` around lines 1302 -
1304, The test currently hardcodes http.MethodPut when locating the
/error-report request, but the test configuration defines that endpoint as POST;
update the condition that sets errorReportRequest to use the configured method
instead of a hardcoded PUT — e.g., replace the http.MethodPut check with the
test's expected method variable (such as errorReportMethod or
cfg.ErrorReportMethod) so the lookup uses requests[i].Method ==
expectedErrorReportMethod && strings.Contains(requests[i].Path, "/error-report")
and then assign errorReportRequest = &requests[i].

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