Skip to content

Conversation

@pjsharath28
Copy link

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

The github.com/google/btree library used by k8s and etcd has been archived and is no longer maintained. This raises long-term concerns around security fixes and CVEs.

We discussed multiple options to address this in the issue. Given that we only rely on a single source file from the library, we concluded that copying the code into k8s.io/utils is the simplest option. This avoids introducing or maintaining a separate fork while preserving identical behaviour.

Which issue(s) this PR is related to:

Discussion issue: etcd-io/etcd#20991

Special notes for your reviewer:

Upstream Google attribution is preserved and the file header follows Kubernetes conventions while remaining Apache-2.0 compliant.

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Dec 17, 2025
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 17, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @pjsharath28!

It looks like this is your first PR to kubernetes/utils 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/utils has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Dec 17, 2025
@aojea
Copy link
Member

aojea commented Dec 17, 2025

/assign @dims

side note @dims, it seems the github actions are waiting for manual approval, you can change that option in in the repo settings IIRC so they always run

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pjsharath28
Once this PR has been reviewed and has the lgtm label, please ask for approval from dims. 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

Comment on lines 19 to 23
// In Go 1.18 and beyond, a BTreeG generic is created, and BTree is a specific
// instantiation of that generic for the Item interface, with a backwards-
// compatible API. Before go1.18, generics are not supported,
// and BTree is just an implementation based around the Item interface.

Copy link
Member

Choose a reason for hiding this comment

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

This isn’t relevant and should be removed.

Copy link
Author

Choose a reason for hiding this comment

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

Removed

Comment on lines 61 to 64
// There are two implementations; those suffixed with 'G' are generics, usable
// for any type, and require a passed-in "less" function to define their ordering.
// Those without this prefix are specific to the 'Item' interface, and use
// its 'Less' function for ordering.
Copy link
Member

Choose a reason for hiding this comment

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

k/k only uses the generic implementation, do we need to keep both in utils?

Copy link
Author

Choose a reason for hiding this comment

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

Ideally not needed, I removed the non-generic implementation

@pjsharath28 pjsharath28 force-pushed the migrate-btree-to-k8s-util branch from d458954 to af10f52 Compare December 22, 2025 07:19
@pjsharath28
Copy link
Author

/retest

@k8s-ci-robot
Copy link
Contributor

@pjsharath28: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

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.

@pjsharath28 pjsharath28 requested a review from skitt December 22, 2025 07:32
btree/btree.go Outdated
// BTree has its own FreeList, but multiple BTrees can share the same
// FreeList, in particular when they're created with Clone.
// Two Btrees using the same freelist are safe for concurrent write access.
type FreeListG[T any] struct {
Copy link
Member

Choose a reason for hiding this comment

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

Since we’re only keeping the generic variant, the G suffix isn’t necessary; please remove it throughout.

Copy link
Author

Choose a reason for hiding this comment

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

Resolved

@pjsharath28 pjsharath28 requested a review from skitt December 23, 2025 09:54
btree/btree.go Outdated
type ItemIterator[T any] func(item T) bool

// Ordered represents the set of types for which the '<' operator work.
type Ordered interface {
Copy link
Member

Choose a reason for hiding this comment

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

Ah, I missed this previously, sorry — please use cmp.Ordered instead.

Copy link
Author

Choose a reason for hiding this comment

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

Good catch, thanks
I've resolved it as well

@pjsharath28 pjsharath28 requested a review from skitt December 24, 2025 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants