Skip to content

HYPERFLEET-790 - fix: use kubectl exec instead of kubectl run for maestro consumer creation#27

Open
tzhou5 wants to merge 3 commits intoopenshift-hyperfleet:mainfrom
tzhou5:debug-maestro-consumer
Open

HYPERFLEET-790 - fix: use kubectl exec instead of kubectl run for maestro consumer creation#27
tzhou5 wants to merge 3 commits intoopenshift-hyperfleet:mainfrom
tzhou5:debug-maestro-consumer

Conversation

@tzhou5
Copy link
Contributor

@tzhou5 tzhou5 commented Mar 20, 2026

Summary by CodeRabbit

  • Chores
    • Consumer-creation now runs inside the cluster and no longer spins up ephemeral helper pods.
    • Added retry logic (up to 5 attempts with pauses) and clearer success/failure messages.
    • Expected outcome: fewer transient resources, simpler operations, and more reliable deployment requests.

@openshift-ci openshift-ci bot requested review from ciaranRoche and rh-amarin March 20, 2026 10:41
@openshift-ci
Copy link

openshift-ci bot commented Mar 20, 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 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ea8abd57-9466-4586-babe-d80f6fa58e43

📥 Commits

Reviewing files that changed from the base of the PR and between 01039e1 and 0eb503e.

📒 Files selected for processing (1)
  • Makefile
🚧 Files skipped from review as they are similar to previous changes (1)
  • Makefile

Walkthrough

The Makefile's create-maestro-consumer target no longer creates or deletes an ephemeral maestro-consumer-create pod. Instead it runs curl via kubectl exec against the existing deploy/maestro pod to perform the consumer-creation HTTP POST. The curl is executed inside a retry loop (up to 5 attempts, 5s sleep between attempts); on success it exits 0, and after exhausting retries it prints an error and exits 1. All prior pod creation, readiness waits, log retrieval, and deletion steps were removed.

Sequence Diagram(s)

sequenceDiagram
    participant Make as Makefile target
    participant Kubectl as kubectl
    participant MaestroPod as deploy/maestro pod
    participant MaestroSvc as Maestro HTTP endpoint

    Make->>Kubectl: kubectl exec (run curl POST)
    Kubectl->>MaestroPod: execute curl inside container
    MaestroPod->>MaestroSvc: HTTP POST /consumers
    MaestroSvc-->>MaestroPod: 2xx or error response
    MaestroPod-->>Kubectl: exit code and output
    Kubectl-->>Make: return status
    alt failure and attempts < 5
        Make->>Make: print attempt failure, sleep 5s, retry
    else exhausted attempts
        Make-->>Make: print error, exit 1
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 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 change: replacing kubectl run with kubectl exec for maestro consumer creation, which aligns perfectly with the changeset.
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
📝 Coding Plan
  • Generate coding plan for human review comments

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

@tzhou5
Copy link
Contributor Author

tzhou5 commented Mar 20, 2026

/test integration

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)
Makefile (1)

135-144: Consider handling the "consumer already exists" case for idempotency.

If the consumer already exists (e.g., re-running this target), the API likely returns a 4xx error, causing all retries to fail. This breaks re-runnability of the make target.

Additionally, -s (silent) hides error details, making failures harder to debug. Consider -sS to show errors while suppressing progress output.

♻️ Suggested improvement for idempotency and error visibility
 `@for` i in 1 2 3 4 5; do \
 	kubectl exec deploy/maestro --namespace $(MAESTRO_NS) --kubeconfig $(KUBECONFIG) -- \
-		curl -sf -X POST \
+		curl -sSf -X POST \
 		-H "Content-Type: application/json" \
 		http://maestro.$(MAESTRO_NS).svc.cluster.local:8000/api/maestro/v1/consumers \
-		-d '{"name": "$(MAESTRO_CONSUMER)"}' && exit 0; \
+		-d '{"name": "$(MAESTRO_CONSUMER)"}' && exit 0 || \
+	{ status=$$?; \
+	  kubectl exec deploy/maestro --namespace $(MAESTRO_NS) --kubeconfig $(KUBECONFIG) -- \
+		curl -sS http://maestro.$(MAESTRO_NS).svc.cluster.local:8000/api/maestro/v1/consumers \
+		| grep -q '"name":"$(MAESTRO_CONSUMER)"' && { echo "Consumer already exists"; exit 0; }; \
+	}; \
 	echo "  Attempt $$i failed, retrying in 5s..."; \
 	sleep 5; \
 done; \

Alternatively, a simpler approach is to check if the consumer exists before attempting creation, or to accept 409 Conflict as success.

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

In `@Makefile` around lines 135 - 144, The Makefile target that runs kubectl exec
deploy/maestro ... curl -sf -X POST to create the Maestro consumer is not
idempotent and hides HTTP errors; change the logic so that POST treats a
409/consumer-already-exists response as success (i.e., break/exit 0 on HTTP 201
or 409) or perform a prior GET to confirm existence before POST, and switch curl
flags from -s to -sS so error bodies are shown; update the code paths around the
curl call and retry loop (the kubectl exec + curl invocation) to implement the
409-acceptance or existence-check behavior and surface errors for debugging.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@Makefile`:
- Around line 135-144: The Makefile target that runs kubectl exec deploy/maestro
... curl -sf -X POST to create the Maestro consumer is not idempotent and hides
HTTP errors; change the logic so that POST treats a 409/consumer-already-exists
response as success (i.e., break/exit 0 on HTTP 201 or 409) or perform a prior
GET to confirm existence before POST, and switch curl flags from -s to -sS so
error bodies are shown; update the code paths around the curl call and retry
loop (the kubectl exec + curl invocation) to implement the 409-acceptance or
existence-check behavior and surface errors for debugging.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 32b21d59-8d70-4fa5-8baf-3d0ecd25a040

📥 Commits

Reviewing files that changed from the base of the PR and between 7b5ce10 and 01039e1.

📒 Files selected for processing (1)
  • Makefile

@tzhou5
Copy link
Contributor Author

tzhou5 commented Mar 20, 2026

/test integration

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