Skip to content

HYPERFLEET-1488 - bug: Change namespace and configmap name for negative adapters - #156

Open
ma-hill wants to merge 1 commit into
openshift-hyperfleet:mainfrom
ma-hill:tier1-failures
Open

HYPERFLEET-1488 - bug: Change namespace and configmap name for negative adapters#156
ma-hill wants to merge 1 commit into
openshift-hyperfleet:mainfrom
ma-hill:tier1-failures

Conversation

@ma-hill

@ma-hill ma-hill commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Update negative adapter task configs to create resources without the clusterId prefix.

Replaced naming convention to: <adapter_name>- this is to avoid collisions with base testing resources that get created with the clusterID prefix. SInce our e2e suites are now running in parallel we hit a failure here in the tier1 nightly:

Add per-test cleanup for negative adapter tests where the resources created don't get properly cleaned up when the cluster gets deleted (e.g. Namespaces, Configmaps, AppliedManifestWorks) which are only getting swept up on end of test cleanup. Added both during test run and post test suite cleanup. Refactored cleanup logic: extracted FindResourcesByLabel as a generic helper, added FindResourceBundlesByRunId for run-ID based cleanup. Updated CleanupHelper to delete ResourceBundles by run ID in Phase 1 of cleanup, removing the dependency on finalizer manipulation

https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/test-platform-results/logs/periodic-ci-openshift-hyperfleet-hyperfleet-e2e-main-e2e-tier1-nightly/2084965232177844224/build-log.txt

Jira

HF-1488

Test Plan

  • make test-all passes
  • make lint
  • Verify adapter tests succeed

@openshift-ci

openshift-ci Bot commented Aug 6, 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 Aug 6, 2026

Copy link
Copy Markdown

[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 mischulee 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

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved cleanup of test resources, including namespaces and resource bundles.
    • Standardized resource naming to consistently include the adapter name and cluster identifier.
    • Improved resource discovery and cleanup using run identifiers and labels.
    • Clarified Pub/Sub cleanup behavior.
  • Tests

    • Added adapter categorization to negative, failure, and recovery scenarios.
    • Updated validation for the standardized resource naming scheme.
    • Expanded cleanup verification and resource discovery coverage.

Walkthrough

The change adds the Adapter label to adapter-related tests. Maestro clients can search ResourceBundles by label and run ID. Cleanup now deletes ResourceBundles through Maestro instead of removing AppliedManifestWork finalizers. Adapter task configurations and E2E assertions now use the ${adapterName}-${clusterID} naming format.

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

Suggested reviewers: rafabene, ruclo

🚥 Pre-merge checks | ✅ 10 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
No Pii Or Sensitive Data In Logs ⚠️ Warning New cleanup logs serialize Maestro errors, while client errors include raw non-2xx response bodies; this may expose customer data (CWE-532, CWE-209). Return sanitized Maestro errors without response bodies, or redact error content before logging in cleanup.go and adapter_with_maestro.go.
✅ Passed checks (10 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
Sec-02: Secrets In Log Output ✅ Passed Changed non-test files contain no log fields or interpolated values named token, password, credential, or secret; logs expose only IDs, names, counts, statuses, and errors.
No Hardcoded Secrets ✅ Passed Changed Go and YAML contain no hardcoded credentials, credential-bearing URLs, private keys, sensitive string assignments, or valid base64 literals over 32 characters (CWE-798).
No Weak Cryptography ✅ Passed No changed line uses crypto/md5, crypto/des, crypto/rc4, SHA-1, ECB, custom crypto, or secret comparisons; only existing crypto/rand and SHA-256 occur (CWE-327/CWE-328).
No Injection Vectors ✅ Passed PR hunks add no SQL, exec.Command, template.HTML, or yaml.Unmarshal sinks; labelQuery uses url.QueryEscape and RunID is validated as a Kubernetes label.
No Privileged Containers ✅ Passed No prohibited privilege settings were added. Changed YAML only updates testdata names; Dockerfile matches are unchanged. No new CWE-250 container privilege exposure exists.
Title check ✅ Passed The title clearly identifies the namespace and ConfigMap naming change for negative adapters.
Description check ✅ Passed The description explains the naming convention change, cleanup refactor, motivation, and test plan.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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

@ma-hill
ma-hill force-pushed the tier1-failures branch 3 times, most recently from 3a88970 to bfac8ba Compare August 6, 2026 17:29
@ma-hill
ma-hill marked this pull request as ready for review August 6, 2026 17:29
@openshift-ci
openshift-ci Bot requested review from Ruclo and rafabene August 6, 2026 17:29

@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: 3

🤖 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/adapter/adapter_with_maestro.go`:
- Around line 487-495: Correct the condition around
FindAllResourceBundlesByClusterID so lookup errors are logged and the cleanup
description plus deletion loop execute only when the lookup succeeds. Preserve
the existing per-resource deletion warnings while moving the ginkgo.By call and
iteration over rbs into the successful branch.

In `@pkg/helper/cleanup.go`:
- Around line 166-175: Update the Maestro cleanup flow around
FindResourceBundlesByRunId and DeleteResourceBundle to collect lookup and
deletion errors instead of only logging them. After Kubernetes cleanup and
polling complete, return or propagate the aggregated Maestro failures so
SweepLabeledResources cannot report success while ResourceBundles remain;
preserve best-effort behavior only with an explicit comment and result signal.

In `@testdata/adapter-configs/cl-m-bad-api/adapter-task-config.yaml`:
- Line 97: The nested discovery configurations in
testdata/adapter-configs/cl-m-bad-api/adapter-task-config.yaml:97-97 and
testdata/adapter-configs/cl-m-unreg-consumer/adapter-task-config.yaml:121-121
use the same name for different resource kinds, allowing DiscoverNestedManifest
to select the wrong object. Update both configurations to use distinct resource
names, or make identity matching kind-aware in both configurations, while
preserving the intended Namespace and ConfigMap discovery behavior.
🪄 Autofix

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: 16d0fe9f-a6ee-427e-a78a-f863af3f3b3b

📥 Commits

Reviewing files that changed from the base of the PR and between 8f4917c and bfac8ba.

📒 Files selected for processing (14)
  • e2e/adapter/adapter_with_maestro.go
  • e2e/cluster/adapter_failure.go
  • e2e/cluster/crash_recovery.go
  • e2e/cluster/stuck_deletion.go
  • pkg/client/maestro/client.go
  • pkg/helper/cleanup.go
  • pkg/labels/labels.go
  • testdata/adapter-configs/cl-crash/adapter-task-config.yaml
  • testdata/adapter-configs/cl-m-bad-api/adapter-task-config.yaml
  • testdata/adapter-configs/cl-m-unreg-consumer/adapter-task-config.yaml
  • testdata/adapter-configs/cl-m-wrong-ds/adapter-task-config.yaml
  • testdata/adapter-configs/cl-m-wrong-nest/adapter-task-config.yaml
  • testdata/adapter-configs/cl-param-error/adapter-task-config.yaml
  • testdata/adapter-configs/cl-stuck/adapter-task-config.yaml
🔗 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)

Comment thread e2e/adapter/adapter_with_maestro.go Outdated
Comment thread pkg/helper/cleanup.go Outdated
Comment thread testdata/adapter-configs/cl-m-bad-api/adapter-task-config.yaml Outdated
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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 `@pkg/helper/cleanup.go`:
- Around line 62-64: Update the labels override handling near
countRemainingResources so an options value with an empty selector does not
replace the default run-ID LabelSelector; retain the existing selector in that
case, or explicitly reject the empty-selector input before resource listing.
🪄 Autofix

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: 09f983c2-9483-4b0d-a699-a3c948aa2056

📥 Commits

Reviewing files that changed from the base of the PR and between 8f4917c and 8b9bec4.

📒 Files selected for processing (14)
  • e2e/adapter/adapter_with_maestro.go
  • e2e/cluster/adapter_failure.go
  • e2e/cluster/crash_recovery.go
  • e2e/cluster/stuck_deletion.go
  • pkg/client/maestro/client.go
  • pkg/helper/cleanup.go
  • pkg/labels/labels.go
  • testdata/adapter-configs/cl-crash/adapter-task-config.yaml
  • testdata/adapter-configs/cl-m-bad-api/adapter-task-config.yaml
  • testdata/adapter-configs/cl-m-unreg-consumer/adapter-task-config.yaml
  • testdata/adapter-configs/cl-m-wrong-ds/adapter-task-config.yaml
  • testdata/adapter-configs/cl-m-wrong-nest/adapter-task-config.yaml
  • testdata/adapter-configs/cl-param-error/adapter-task-config.yaml
  • testdata/adapter-configs/cl-stuck/adapter-task-config.yaml
🔗 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)
🚧 Files skipped from review as they are similar to previous changes (13)
  • testdata/adapter-configs/cl-crash/adapter-task-config.yaml
  • pkg/labels/labels.go
  • testdata/adapter-configs/cl-stuck/adapter-task-config.yaml
  • e2e/cluster/stuck_deletion.go
  • e2e/cluster/adapter_failure.go
  • testdata/adapter-configs/cl-param-error/adapter-task-config.yaml
  • testdata/adapter-configs/cl-m-bad-api/adapter-task-config.yaml
  • testdata/adapter-configs/cl-m-wrong-ds/adapter-task-config.yaml
  • pkg/client/maestro/client.go
  • e2e/adapter/adapter_with_maestro.go
  • e2e/cluster/crash_recovery.go
  • testdata/adapter-configs/cl-m-wrong-nest/adapter-task-config.yaml
  • testdata/adapter-configs/cl-m-unreg-consumer/adapter-task-config.yaml

Comment thread pkg/helper/cleanup.go Outdated
Comment on lines +62 to +64
if len(labels) > 0 {
labelSelectorListOptions = labels[0]
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve the run-ID selector when an override has no selector.

A caller can pass metav1.ListOptions{}. This replaces the default selector with an empty selector.

countRemainingResources then lists cluster-wide resources. Unrelated resources can keep Phase 3 polling until timeout. This is CWE-20.

Keep the default LabelSelector when the supplied options have an empty selector, or reject that input.

Proposed fix
 if len(labels) > 0 {
   labelSelectorListOptions = labels[0]
+  if strings.TrimSpace(labelSelectorListOptions.LabelSelector) == "" {
+    labelSelectorListOptions.LabelSelector = labelSelector
+  }
 }
📝 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 len(labels) > 0 {
labelSelectorListOptions = labels[0]
}
if len(labels) > 0 {
labelSelectorListOptions = labels[0]
if strings.TrimSpace(labelSelectorListOptions.LabelSelector) == "" {
labelSelectorListOptions.LabelSelector = labelSelector
}
}
🤖 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 `@pkg/helper/cleanup.go` around lines 62 - 64, Update the labels override
handling near countRemainingResources so an options value with an empty selector
does not replace the default run-ID LabelSelector; retain the existing selector
in that case, or explicitly reject the empty-selector input before resource
listing.

Source: Path instructions

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Comment thread pkg/helper/cleanup.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would deleting the resourceBundle via the API remove amw as well?
If so, should we remove countRemainingResources since they will be managed by the cascading?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes good catch, let me cleanup

Comment thread pkg/client/maestro/client.go Outdated
bundles = append(bundles, result.Items[i])
}
}
// FindResourceBundlesByAdapterName finds all resource bundles created by a specific adapter

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
// FindResourceBundlesByAdapterName finds all resource bundles created by a specific adapter
// FindResourceBundlesByRunId finds all resource bundles created during a specific test run
// Uses the e2e.hyperfleet.io/run-id label to filter by test runID

Comment thread pkg/client/maestro/client.go Outdated
}
// FindResourceBundlesByAdapterName finds all resource bundles created by a specific adapter
// Uses the e2e.hyperfleet.io/run-id label to filter by test runID
func (c *Client) FindResourceBundlesByRunId(ctx context.Context, runID string) ([]ResourceBundle, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
func (c *Client) FindResourceBundlesByRunId(ctx context.Context, runID string) ([]ResourceBundle, error) {
func (c *Client) FindResourceBundlesByRunID(ctx context.Context, runID string) ([]ResourceBundle, error) {

Comment thread pkg/helper/cleanup.go Outdated
logger.Info("Phase 1: Removing finalizers from AppliedManifestWorks")
c.removeAppliedManifestWorkFinalizers(ctx)
// Phase 1: Delete ResourceBundles Created by Run ID
logger.Info("Phase 1: Best effore delete Resource Bundles by Run ID")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
logger.Info("Phase 1: Best effore delete Resource Bundles by Run ID")
logger.Info("Phase 1: Best effort delete Resource Bundles by Run ID")

Comment thread e2e/adapter/adapter_with_maestro.go Outdated
}

// Best effort delete outstanding resource bundles created on cluster creation
if rbs, err := h.MaestroClient.FindAllResourceBundlesByClusterID(ctx, clusterID); err == nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we log the error if it's not null?

// FindResourceBundlesByAdapterName finds all resource bundles created by a specific adapter
// Uses the maestro.io/source-id label to filter by adapter name
func (c *Client) FindResourceBundlesByAdapterName(ctx context.Context, adapterName string) ([]ResourceBundle, error) {
func (c *Client) FindResourcesByLabel(ctx context.Context, labelQuery string) ([]ResourceBundle, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since every method in this file has comments:

Suggested change
func (c *Client) FindResourcesByLabel(ctx context.Context, labelQuery string) ([]ResourceBundle, error) {
// FindResourcesByLabel finds all resource bundles matching a Maestro JSONB label search expression.
func (c *Client) FindResourcesByLabel(ctx context.Context, labelQuery string) ([]ResourceBundle, error) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually cleaned up these functions even more, will verify

Comment thread pkg/labels/labels.go Outdated
)

const (
Adapter = "adapter"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Which file?

Comment on lines +263 to 277
// Trust the search query worked as expected
return result.Items, nil
}

// Filter and return all matching resource bundles
var bundles []ResourceBundle
for i := range result.Items {
if result.Items[i].Metadata.Labels != nil &&
result.Items[i].Metadata.Labels["maestro.io/source-id"] == adapterName {
bundles = append(bundles, result.Items[i])
}
}
// FindResourceBundlesByAdapterName finds all resource bundles created by a specific adapter
// Uses the e2e.hyperfleet.io/run-id label to filter by test runID
func (c *Client) FindResourceBundlesByRunId(ctx context.Context, runID string) ([]ResourceBundle, error) {
return c.FindResourcesByLabel(ctx, toJSONBLabelSearch("e2e.hyperfleet.io/run-id", runID))
}

return bundles, nil
// FindResourceBundlesByAdapterName finds all resource bundles created by a specific adapter
// Uses the maestro.io/source-id label to filter by adapter name
func (c *Client) FindResourceBundlesByAdapterName(ctx context.Context, adapterName string) ([]ResourceBundle, error) {
return c.FindResourcesByLabel(ctx, toJSONBLabelSearch("maestro.io/source-id", adapterName))
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The refactor makes FindResourcesByLabel trust Maestro search results, but FindAllResourceBundlesByClusterID still client-filters by label in the same file. Worth picking one approach and applying it consistently, either keep the post-search label check in the RunId/AdapterName helpers or remove it from the cluster-ID path too.

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.

3 participants