Skip to content

CCXDEV-15641: gather machineconfig size#1240

Merged
openshift-merge-bot[bot] merged 3 commits intoopenshift:masterfrom
opokornyy:CCXDEV-15641-machineconfig-size
Mar 5, 2026
Merged

CCXDEV-15641: gather machineconfig size#1240
openshift-merge-bot[bot] merged 3 commits intoopenshift:masterfrom
opokornyy:CCXDEV-15641-machineconfig-size

Conversation

@opokornyy
Copy link
Copy Markdown
Contributor

Annotate MachineConfig CRs with their original size before removing spec fields to reduce archive size. The newly added annotation is insights.operator.openshift.io/cr-size.

Categories

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

Sample Archive

  • docs/insights-archive-sample/config/machineconfigs

Documentation

  • None

Unit Tests

  • pkg/gatherers/clusterconfig/gather_machine_configs_test.go

Privacy

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

Changelog

Breaking Changes

No

References

CCXDEV-15641

Annotate MachineConfig CRs with their original
size before removing spec fields to reduce
archive size. The newly added annotation is
insights.operator.openshift.io/cr-size.

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 added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Feb 25, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented Feb 25, 2026

@opokornyy: This pull request references CCXDEV-15641 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 "4.22.0" version, but no target version was set.

Details

In response to this:

Annotate MachineConfig CRs with their original size before removing spec fields to reduce archive size. The newly added annotation is insights.operator.openshift.io/cr-size.

Categories

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

Sample Archive

  • docs/insights-archive-sample/config/machineconfigs

Documentation

  • None

Unit Tests

  • pkg/gatherers/clusterconfig/gather_machine_configs_test.go

Privacy

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

Changelog

Breaking Changes

No

References

CCXDEV-15641

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 25, 2026

Walkthrough

Twelve MachineConfig JSON resource definitions are updated to include a new annotation recording their JSON-marshaled size in bytes. A Go gatherer function is introduced to compute and apply this annotation to all MachineConfig resources before redacting sensitive fields.

Changes

Cohort / File(s) Summary
MachineConfig JSON Annotations
docs/insights-archive-sample/config/machineconfigs/00-master.json, 00-worker.json, 01-master-container-runtime.json, 01-master-kubelet.json, 01-worker-container-runtime.json, 01-worker-kubelet.json, 99-master-generated-registries.json, 99-master-ssh.json, 99-worker-generated-registries.json, 99-worker-ssh.json, rendered-master-025110333ea44423ccb1052723956671.json, rendered-worker-39c9df4a2c026c3149a02abe6f88cfc8.json
Each MachineConfig adds new annotation insights.operator.openshift.io/cr-size with computed byte size value under metadata.annotations.
Size Calculation Logic
pkg/gatherers/clusterconfig/gather_machine_configs.go
Introduces getCRSize helper function to marshal and measure MachineConfig JSON size. Integrates size computation into gather pipeline, storing result as annotation before sensitive field redaction. Initializes annotations map when absent and logs size calculation errors.
Test Coverage
pkg/gatherers/clusterconfig/gather_machine_configs_test.go
Adds Test_getCRSize unit test for size calculation. Extends TestGatherMachineConfigs to validate cr-size annotation presence, numeric parsing, and sensitive field removal from gathered records.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Structure And Quality ⚠️ Warning TestGatherMachineConfigs tests multiple unrelated behaviors instead of a single responsibility, and error assertions lack meaningful failure messages. Split TestGatherMachineConfigs into separate focused tests and add descriptive messages to all error assertions like t.Fatalf("failed to marshal: %v", err).
✅ 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 'CCXDEV-15641: gather machineconfig size' directly summarizes the main change: adding size collection for MachineConfig resources as an annotation before field removal.
Stable And Deterministic Test Names ✅ Passed All test function names and test case titles in the file use static, descriptive strings following Go testing conventions with no dynamic information.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.5.0)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


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

@openshift-ci openshift-ci Bot requested review from BaiyangZhou and ncaak February 25, 2026 14:28
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 25, 2026
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/gatherers/clusterconfig/gather_machine_configs.go`:
- Around line 120-128: The code currently sets the
"insights.operator.openshift.io/cr-size" annotation even when getCRSize(&mc)
returns an error (mcSize stays 0); change the logic in the block around
getCRSize to only assign and call mc.SetAnnotations(annotations) when err == nil
(i.e., successful size calculation). Specifically, after calling getCRSize(&mc)
check if err is nil before doing
annotations["insights.operator.openshift.io/cr-size"] = strconv.Itoa(mcSize) and
calling mc.SetAnnotations(annotations); keep the existing klog.Errorf and errs =
append(errs, err) behavior on failure.

ℹ️ Review info

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 222d95b and 75acc3d.

📒 Files selected for processing (14)
  • docs/insights-archive-sample/config/machineconfigs/00-master.json
  • docs/insights-archive-sample/config/machineconfigs/00-worker.json
  • docs/insights-archive-sample/config/machineconfigs/01-master-container-runtime.json
  • docs/insights-archive-sample/config/machineconfigs/01-master-kubelet.json
  • docs/insights-archive-sample/config/machineconfigs/01-worker-container-runtime.json
  • docs/insights-archive-sample/config/machineconfigs/01-worker-kubelet.json
  • docs/insights-archive-sample/config/machineconfigs/99-master-generated-registries.json
  • docs/insights-archive-sample/config/machineconfigs/99-master-ssh.json
  • docs/insights-archive-sample/config/machineconfigs/99-worker-generated-registries.json
  • docs/insights-archive-sample/config/machineconfigs/99-worker-ssh.json
  • docs/insights-archive-sample/config/machineconfigs/rendered-master-025110333ea44423ccb1052723956671.json
  • docs/insights-archive-sample/config/machineconfigs/rendered-worker-39c9df4a2c026c3149a02abe6f88cfc8.json
  • pkg/gatherers/clusterconfig/gather_machine_configs.go
  • pkg/gatherers/clusterconfig/gather_machine_configs_test.go

Comment thread pkg/gatherers/clusterconfig/gather_machine_configs.go
@opokornyy
Copy link
Copy Markdown
Contributor Author

/retest

4 similar comments
@opokornyy
Copy link
Copy Markdown
Contributor Author

/retest

@BaiyangZhou
Copy link
Copy Markdown

/retest

@opokornyy
Copy link
Copy Markdown
Contributor Author

/retest

@BaiyangZhou
Copy link
Copy Markdown

/retest

Copy link
Copy Markdown
Contributor

@ncaak ncaak left a comment

Choose a reason for hiding this comment

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

/lgtm

@ncaak
Copy link
Copy Markdown
Contributor

ncaak commented Mar 3, 2026

/retest

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Mar 3, 2026
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Mar 3, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ncaak, 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

@BaiyangZhou
Copy link
Copy Markdown

/retest

1 similar comment
@opokornyy
Copy link
Copy Markdown
Contributor Author

/retest

@BaiyangZhou
Copy link
Copy Markdown

/label qe-approved

@openshift-ci openshift-ci Bot added the qe-approved Signifies that QE has signed off on this PR label Mar 5, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented Mar 5, 2026

@opokornyy: This pull request references CCXDEV-15641 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 "4.22.0" version, but no target version was set.

Details

In response to this:

Annotate MachineConfig CRs with their original size before removing spec fields to reduce archive size. The newly added annotation is insights.operator.openshift.io/cr-size.

Categories

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

Sample Archive

  • docs/insights-archive-sample/config/machineconfigs

Documentation

  • None

Unit Tests

  • pkg/gatherers/clusterconfig/gather_machine_configs_test.go

Privacy

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

Changelog

Breaking Changes

No

References

CCXDEV-15641

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.

@BaiyangZhou
Copy link
Copy Markdown

/verified later @BaiyangZhou

@openshift-ci-robot openshift-ci-robot added verified-later verified Signifies that the PR passed pre-merge verification criteria labels Mar 5, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@BaiyangZhou: This PR has been marked to be verified later by @BaiyangZhou.

Details

In response to this:

/verified later @BaiyangZhou

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.

@opokornyy
Copy link
Copy Markdown
Contributor Author

/retest

@opokornyy
Copy link
Copy Markdown
Contributor Author

/override pull-ci-openshift-insights-operator-master-lint

I have verified it locally

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Mar 5, 2026

@opokornyy: Overrode contexts on behalf of opokornyy: ci/prow/lint

Details

In response to this:

/override pull-ci-openshift-insights-operator-master-lint

I have verified it locally

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.

@openshift-merge-bot openshift-merge-bot Bot merged commit 23f3aae into openshift:master Mar 5, 2026
15 checks passed
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Mar 5, 2026

@opokornyy: all tests passed!

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. lgtm Indicates that a PR is ready to be merged. qe-approved Signifies that QE has signed off on this PR verified Signifies that the PR passed pre-merge verification criteria verified-later

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants