Skip to content

HIVE-3134: Axe sjson dependency#2886

Open
dlom wants to merge 1 commit intoopenshift:masterfrom
dlom:HIVE-3134-remove-sjson-dep
Open

HIVE-3134: Axe sjson dependency#2886
dlom wants to merge 1 commit intoopenshift:masterfrom
dlom:HIVE-3134-remove-sjson-dep

Conversation

@dlom
Copy link
Copy Markdown
Contributor

@dlom dlom commented Mar 27, 2026

xref: HIVE-3134

This one warrants a test to make sure we don't lost any functionality. The dep was also pulling in a 16 KB png into our tree. Goodbye!

/assign @2uasimojo

Summary by CodeRabbit

  • Refactor

    • Improved label management system for manifest configurations with streamlined error handling.
  • Tests

    • Added comprehensive test coverage for label configuration logic.
  • Chores

    • Removed unused external dependency to reduce package size.

@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Mar 27, 2026

@dlom: This pull request references HIVE-3134 which is a valid jira issue.

Details

In response to this:

xref: HIVE-3134

This one warrants a test to make sure we don't lost any functionality. The dep was also pulling in a 16 KB png into our tree. Goodbye!

/assign @2uasimojo

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 Mar 27, 2026
@openshift-ci openshift-ci bot requested review from jstuever and suhanime March 27, 2026 00:34
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Mar 27, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dlom

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 27, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

The change removes the direct dependency on github.com/tidwall/sjson v1.2.5 from the project. The JSON patching logic in patchLabelMachineSetManifest has been refactored to use a new internal helper function setJSONLabels that performs JSON manipulation using only Go's standard library. Associated vendor files and module references are removed accordingly.

Changes

Cohort / File(s) Summary
Dependency Management
go.mod, vendor/modules.txt
Removed github.com/tidwall/sjson v1.2.5 from direct dependencies and vendor module listing.
Core Refactoring
pkg/installmanager/installmanager.go
Replaced direct sjson-based JSON patching with new internal helper setJSONLabels that unmarshals JSON to map[string]interface{}, sets labels in metadata, and remarshals back to JSON.
Tests
pkg/installmanager/installmanager_test.go
Added comprehensive unit test Test_setJSONLabels covering multiple scenarios: missing metadata, existing labels preservation, and invalid JSON error handling.
Vendor Cleanup
vendor/github.com/tidwall/sjson/...
Removed entire sjson vendor package including sjson.go (implementation), README.md (documentation), and LICENSE file.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A library once lived in our vendor tree,
Now we craft our own patches—label-wise and free!
JSON marshaled by paws, no sjson to call,
Our metadata blooms cleanly, no external sprawl! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: removing the sjson dependency from the codebase and replacing its usage with a custom helper function.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Mar 27, 2026

@dlom: This pull request references HIVE-3134 which is a valid jira issue.

Details

In response to this:

xref: HIVE-3134

This one warrants a test to make sure we don't lost any functionality. The dep was also pulling in a 16 KB png into our tree. Goodbye!

/assign @2uasimojo

Summary by CodeRabbit

  • Refactor

  • Improved label management system for manifest configurations with streamlined error handling.

  • Tests

  • Added comprehensive test coverage for label configuration logic.

  • Chores

  • Removed unused external dependency to reduce package size.

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.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 50.32%. Comparing base (8296ffc) to head (0981b73).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
pkg/installmanager/installmanager.go 95.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2886      +/-   ##
==========================================
+ Coverage   50.29%   50.32%   +0.02%     
==========================================
  Files         280      280              
  Lines       34323    34337      +14     
==========================================
+ Hits        17264    17281      +17     
+ Misses      15698    15696       -2     
+ Partials     1361     1360       -1     
Files with missing lines Coverage Δ
pkg/installmanager/installmanager.go 36.65% <95.00%> (+0.88%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@2uasimojo 2uasimojo left a comment

Choose a reason for hiding this comment

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

/test e2e

Not so sure about this one @dlom. I remember @lleshchi and I had to churn quite a bit to find a functional and elegant way to do this, and the hand-crafted json introspection you're doing is, no offense, only one of those things :P

I can be talked into it, but would like to explore other options first. See inline.

Comment on lines +1058 to +1078
// setJSONLabels sets the given labels on a JSON-encoded Kubernetes resource's metadata.
func setJSONLabels(jsonData []byte, newLabels map[string]string) ([]byte, error) {
var manifest map[string]interface{}
if err := json.Unmarshal(jsonData, &manifest); err != nil {
return nil, fmt.Errorf("error unmarshalling manifest JSON: %w", err)
}
metadata, _ := manifest["metadata"].(map[string]interface{})
if metadata == nil {
metadata = map[string]interface{}{}
manifest["metadata"] = metadata
}
labels, _ := metadata["labels"].(map[string]interface{})
if labels == nil {
labels = map[string]interface{}{}
metadata["labels"] = labels
}
for k, v := range newLabels {
labels[k] = v
}
return json.Marshal(manifest)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm. Is there a way to call an existing/already-imported upstream lib to decode into a metav1.Object on which we can SetLabels()? What you've done here should be pretty straightforward and stable, but it feels... dirty.

@2uasimojo
Copy link
Copy Markdown
Member

/test e2e

another infra flake

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Mar 27, 2026

@dlom: 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants