HYPERFLEET-1057 - fix: Update idempotent delete test to scale by sele…#128
HYPERFLEET-1057 - fix: Update idempotent delete test to scale by sele…#128ma-hill wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughSummary by CodeRabbit
Walkthrough
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Security & RiskCWE-284 (Improper Access Control) — selector scope. CWE-754 (Improper Check for Unusual Exceptional Conditions) — partial failure without rollback. CWE-391 (Unchecked Error) — deferred error ignored. 🚥 Pre-merge checks | ✅ 10 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (10 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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 `@e2e/cluster/delete_edge_cases.go`:
- Around line 43-45: The error from h.ScaleDeploymentBySelector in this cleanup
step is being logged but not propagated, which violates the coding guideline
that log-and-continue patterns must be intentional degradation with a comment.
Either return the error from this cleanup step to properly fail if sentinel
restoration fails, or if intentional degradation is acceptable, add a detailed
comment with a ticket reference explaining why the failure is being
intentionally swallowed instead of using the bare log-and-continue pattern.
In `@pkg/client/kubernetes/client.go`:
- Around line 309-320: Add input validation at the beginning of the
ScaleDeploymentBySelector method to reject empty or whitespace-only selectors
before attempting to list deployments. Check if the selector parameter is empty
after trimming whitespace using strings.TrimSpace and return a descriptive error
if validation fails. This prevents unintended scaling operations when an invalid
selector is passed to the method.
- Around line 322-326: The loop in the deployment scaling code returns
immediately when ScaleDeployment fails for the first deployment, preventing
subsequent deployments from being processed and leaving the system in a partial
state. Instead of returning on the first error, accumulate all errors that occur
while iterating through the deployments, continue processing each deployment in
the Items slice, and return all collected errors as a single error message after
the loop completes. This ensures all matching deployments are attempted to be
scaled regardless of individual failures.
In `@pkg/helper/k8s.go`:
- Around line 182-183: The error returned from the ScaleDeploymentBySelector
method call is being returned bare without context information. Instead of
returning the error directly, wrap it with contextual details including the
namespace and selector values to make the error diagnosable at the helper
boundary. Use an error wrapping approach (such as fmt.Errorf with the %w verb or
your project's standard error wrapping method) to include these contextual
details in the error message before returning it.
🪄 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: CHILL
Plan: Enterprise
Run ID: 70592edd-c143-49b7-91ce-75b31dcf4949
📒 Files selected for processing (3)
e2e/cluster/delete_edge_cases.gopkg/client/kubernetes/client.gopkg/helper/k8s.go
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
openshift-hyperfleet/architecture(manual)openshift-hyperfleet/hyperfleet-api(manual)openshift-hyperfleet/hyperfleet-sentinel(manual)openshift-hyperfleet/hyperfleet-adapter(manual)openshift-hyperfleet/hyperfleet-broker(manual)
|
/test images-images |
…ctor not just release name
98178ae to
8347aef
Compare
Summary
Fixes the idempotent delete test to scale down all sentinel cluster instances using label selectors instead of relying on Helm release names. Previously, the test scaled down only the deployment found by Helm release name
sentinel-clusters, which failed when sentinel deployments with different release names existed. This change allows the helmfile installation to properly scale down. In the future if testing with multi-instance sentinels, will need to modify this to be more inclusive.HYPERFLEET-1057
Notes
In conjunction with openshift/release#80366
Changes
ScaleDeploymentBySelectormethod topkg/client/kubernetes/client.gothat scales all deployments matching a label selectorScaleDeploymentBySelectorwrapper method topkg/helper/k8s.gowith logginge2e/cluster/delete_edge_cases.goto scale using selectorapp.kubernetes.io/instance in (sentinel-clusters,clusters)instead of querying Helm release nameTest Plan
make test-allpassesmake lintpasses