Skip to content

CCXDEV-16040: Add multicluster gatherer - #1337

Open
opokornyy wants to merge 3 commits into
openshift:masterfrom
opokornyy:CCXDEV-16040-multicluster-gatherer
Open

CCXDEV-16040: Add multicluster gatherer#1337
opokornyy wants to merge 3 commits into
openshift:masterfrom
opokornyy:CCXDEV-16040-multicluster-gatherer

Conversation

@opokornyy

@opokornyy opokornyy commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Add gatherer function for MultiClusterEngine CRs
to collect multicluster engine configuration data.

Categories

  • Bugfix
  • Data Enhancement
  • Feature
  • Backporting
  • Others (CI, Infrastructure, Documentation)

Sample Archive

  • docs/insights-archive-sample/cluster-scoped-resources/multicluster.openshift.io/multiclusterengines/engine.json

Documentation

  • docs/gathered-data.md

Unit Tests

  • pkg/gatherers/clusterconfig/gather_multicluster_engine_test.go

Privacy

Yes. There are no sensitive data in the newly collected information.

Changelog

  • None

Breaking Changes

No

References

https://redhat.atlassian.net/browse/CCXDEV-16040

Summary by CodeRabbit

  • New Features

    • Added collection and archiving of MultiClusterEngine configuration and status information.
    • Included a representative MultiClusterEngine archive sample with deployment, availability, component, and local-cluster details.
  • Documentation

    • Documented the MultiClusterEngine resource type, archive location, configuration details, release version, and API references.
    • Updated RevisionedObjectCounts sample and archive paths.
  • Bug Fixes

    • Missing MultiClusterEngine resources are now handled gracefully without errors or records.

Add gatherer function for MultiClusterEngine CRs
to collect multicluster engine configuration data.

Signed-off-by: Ondrej Pokorny <opokorny@redhat.com>
Signed-off-by: Ondrej Pokorny <opokorny@redhat.com>
Signed-off-by: Ondrej Pokorny <opokorny@redhat.com>
@openshift-ci-robot

openshift-ci-robot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

@opokornyy: This pull request references CCXDEV-16040 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Add gatherer function for MultiClusterEngine CRs
to collect multicluster engine configuration data.

Categories

  • Bugfix
  • Data Enhancement
  • Feature
  • Backporting
  • Others (CI, Infrastructure, Documentation)

Sample Archive

  • docs/insights-archive-sample/cluster-scoped-resources/multicluster.openshift.io/multiclusterengines/engine.json

Documentation

  • docs/gathered-data.md

Unit Tests

  • pkg/gatherers/clusterconfig/gather_multicluster_engine_test.go

Privacy

Yes. There are no sensitive data in the newly collected information.

Changelog

  • None

Breaking Changes

No

References

https://redhat.atlassian.net/browse/CCXDEV-16040

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Changes

MultiClusterEngine gathering

Layer / File(s) Summary
Resource registration
pkg/gatherers/clusterconfig/const.go, pkg/gatherers/clusterconfig/clusterconfig_gatherer.go
Defines the MultiClusterEngine resource descriptor and registers its gatherer.
Gatherer implementation and validation
pkg/gatherers/clusterconfig/gather_multicluster_engine.go, pkg/gatherers/clusterconfig/gather_multicluster_engine_test.go
Lists MultiClusterEngine resources, handles missing resources, creates archive records, and tests these behaviors.
Archive sample and documentation
docs/insights-archive-sample/.../multiclusterengines/engine.json, docs/gathered-data.md
Adds a MultiClusterEngine archive sample and documents its collection details. Updates RevisionedObjectCounts paths.

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

Suggested reviewers: ncaak


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
No-Sensitive-Data-In-Logs ❌ Error The new klog line logs raw List error text; client-go can return http.Client.Do errors that include the API request URL, which may expose an internal cluster hostname. Do not log the raw error. Log only a fixed message or sanitized error category, and retain the unsanitized error only in the returned error path.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (13 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the primary change: adding a multicluster gatherer.
Description check ✅ Passed The description covers the change, category, sample archive, documentation, tests, privacy, changelog, breaking changes, and Jira reference.
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.
Stable And Deterministic Test Names ✅ Passed The added tests use static Go test names and two literal subtest names; no Ginkgo titles or dynamic values appear in test titles.
Test Structure And Quality ✅ Passed The added tests use standard Go testing, not Ginkgo. They use isolated fake clients, have no cluster waits or Eventually calls, and follow nearby repository table-test patterns.
Microshift Test Compatibility ✅ Passed The PR adds standard Go unit tests with testing.T and a fake dynamic client; it adds no Ginkgo e2e tests subject to MicroShift API checks.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The added tests use Go's testing package, not Ginkgo e2e constructs, and contain no multi-node or HA assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed PR adds a gatherer function to collect MultiClusterEngine resource data. No deployment manifests, scheduling constraints, affinity rules, or topology-dependent logic are introduced.
Ote Binary Stdout Contract ✅ Passed Changed code has no stdout writes or OTE suite setup; operator errors use os.Stderr, and klog defaults to logtostderr=true.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR adds only standard Go unit tests (using testing package), not Ginkgo e2e tests. The check applies only to new Ginkgo tests.
No-Weak-Crypto ✅ Passed The PR diff adds only Kubernetes resource gathering, tests, documentation, and sample data; no weak-crypto algorithms, crypto APIs, custom crypto, or secret comparisons are present.
Container-Privileges ✅ Passed The PR changes add a MultiClusterEngine sample and Go gatherer code; no changed file contains privileged:true, host PID/network/IPC, SYS_ADMIN, or allowPrivilegeEscalation:true.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment thread docs/gathered-data.md

### Sample data
- [docs/insights-archive-sample/config/revisioned_objects.json](./insights-archive-sample/config/revisioned_objects.json)
- [docs/insights-archive-sample/config/versioned_object_revision_counts.json](./insights-archive-sample/config/versioned_object_revision_counts.json)

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.

This is a left over from #1316 where I forgot to run the make docs after updating doc string

@openshift-ci
openshift-ci Bot requested a review from ncaak August 5, 2026 08:30
@openshift-ci

openshift-ci Bot commented Aug 5, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: opokornyy

The full list of commands accepted by this bot can be found here.

The pull request process is described 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 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

🧹 Nitpick comments (1)
pkg/gatherers/clusterconfig/gather_multicluster_engine_test.go (1)

103-118: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add the NotFound case to the table-driven test.

This standalone test does not use the required table-driven pattern. Add a case with an optional fake-client reactor setup function to the table in Test_gatherMultiClusterEngine.

As per coding guidelines, **/*_test.go: Use table-driven tests in Go test files`.

🤖 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/gatherers/clusterconfig/gather_multicluster_engine_test.go` around lines
103 - 118, Move the CRD-not-found scenario from
Test_gatherMultiClusterEngine_CRDNotFound into the existing table-driven
Test_gatherMultiClusterEngine cases. Extend the table with an optional
fake-client reactor setup function, configure the NotFound list reactor there,
and preserve the expected empty records and errors assertions. Remove the
standalone test.

Source: Coding guidelines

🤖 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/gatherers/clusterconfig/gather_multicluster_engine.go`:
- Around line 48-66: Before constructing each record in
gatherMultiClusterEngine, redact or remove every value at
spec.overrides.components[].configOverrides.deployments[].containers[].env[].value
from the copied resource, then pass the sanitized resource to
record.ResourceMarshaller. Preserve the rest of the MultiClusterEngine data and
add a fixture asserting the environment-variable value is absent from the
archived output.

---

Nitpick comments:
In `@pkg/gatherers/clusterconfig/gather_multicluster_engine_test.go`:
- Around line 103-118: Move the CRD-not-found scenario from
Test_gatherMultiClusterEngine_CRDNotFound into the existing table-driven
Test_gatherMultiClusterEngine cases. Extend the table with an optional
fake-client reactor setup function, configure the NotFound list reactor there,
and preserve the expected empty records and errors assertions. Remove the
standalone test.
🪄 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: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 2993cbe0-7642-448e-a7f3-01185c09bf13

📥 Commits

Reviewing files that changed from the base of the PR and between 16c8ea1 and 7b10247.

📒 Files selected for processing (6)
  • docs/gathered-data.md
  • docs/insights-archive-sample/cluster-scoped-resources/multicluster.openshift.io/multiclusterengines/engine.json
  • pkg/gatherers/clusterconfig/clusterconfig_gatherer.go
  • pkg/gatherers/clusterconfig/const.go
  • pkg/gatherers/clusterconfig/gather_multicluster_engine.go
  • pkg/gatherers/clusterconfig/gather_multicluster_engine_test.go

Comment on lines +48 to +66
func gatherMultiClusterEngine(ctx context.Context, dynamicClient dynamic.Interface) ([]record.Record, []error) {
mceList, err := dynamicClient.Resource(multiClusterEngineGVR).List(ctx, metav1.ListOptions{})
if errors.IsNotFound(err) {
return nil, nil
}
if err != nil {
klog.V(2).Infof("Unable to list %s resource due to: %s", multiClusterEngineGVR, err)
return nil, []error{err}
}

var records []record.Record
for i := range mceList.Items {
item := &mceList.Items[i]
records = append(records, record.Record{
Name: fmt.Sprintf("cluster-scoped-resources/%s/%s/%s",
multiClusterEngineGVR.Group,
multiClusterEngineGVR.Resource,
item.GetName()),
Item: record.ResourceMarshaller{Resource: item},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect ResourceMarshaller and any existing archive sanitization.
ast-grep outline pkg/record --items all
rg -n -C 6 'ResourceMarshaller|MarshalJSON|sanitize|redact|secret' pkg/record pkg/gatherers

# Inspect whether the gatherer or its tests remove sensitive MCE override values.
rg -n -C 6 'configOverrides|containers|env|value|imagePullSecret' \
  pkg/gatherers/clusterconfig docs/insights-archive-sample

Repository: openshift/insights-operator

Length of output: 50384


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- record package files ---'
git ls-files 'pkg/record/*'

printf '%s\n' '--- ResourceMarshaller definitions and uses ---'
rg -n -C 8 --glob '*.go' 'type ResourceMarshaller|ResourceMarshaller\{|ResourceMarshaller' pkg/record pkg/gatherers

printf '%s\n' '--- focused clusterconfig references ---'
rg -n -C 8 --glob '*.go' 'gatherMultiClusterEngine|configOverrides|MultiClusterEngine' pkg/gatherers/clusterconfig

printf '%s\n' '--- archive serialization path ---'
rg -n -C 8 --glob '*.go' 'record\.Record|json\.Marshal|yaml\.Marshal|Marshal\(|ResourceMarshaller' pkg | head -n 500

Repository: openshift/insights-operator

Length of output: 50384


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path

needles = (
    "type ResourceMarshaller",
    "func (",
    "ResourceMarshaller",
    "json.Marshal",
    "MarshalJSON",
)
for path in Path("pkg").rglob("*.go"):
    text = path.read_text(errors="replace")
    if "ResourceMarshaller" in text:
        print(f"--- {path} ---")
        lines = text.splitlines()
        for i, line in enumerate(lines, 1):
            if any(n in line for n in needles):
                lo, hi = max(1, i - 5), min(len(lines), i + 15)
                for j in range(lo, hi + 1):
                    print(f"{j}:{lines[j-1]}")
                print()
PY

Repository: openshift/insights-operator

Length of output: 50384


Sensitive Data Exposure (CWE-200): Exposure of Sensitive Information to an Unauthorized Actor

Reachability: External · Exploitability: Moderate

Reachability path
● Entry
  pkg/gatherers/clusterconfig/clusterconfig_gatherer.go:63
  GatherMultiClusterEngine
│
▼
● Sink
  pkg/gatherers/clusterconfig/gather_multicluster_engine.go

Redact literal environment-variable values before archiving.

record.ResourceMarshaller does not redact the complete MultiClusterEngine. Remove or redact values under spec.overrides.components[].configOverrides.deployments[].containers[].env[].value before creating the marshaller. Add a fixture that asserts the value is absent.

🤖 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/gatherers/clusterconfig/gather_multicluster_engine.go` around lines 48 -
66, Before constructing each record in gatherMultiClusterEngine, redact or
remove every value at
spec.overrides.components[].configOverrides.deployments[].containers[].env[].value
from the copied resource, then pass the sanitized resource to
record.ResourceMarshaller. Preserve the rest of the MultiClusterEngine data and
add a fixture asserting the environment-variable value is absent from the
archived output.

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 5, 2026
@openshift-ci

openshift-ci Bot commented Aug 5, 2026

Copy link
Copy Markdown

@opokornyy: The following test 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/insights-runtime-extractor-tests 7b10247 link true /test insights-runtime-extractor-tests

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.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants