Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix BuilderInterface and BuildStoresFunc to allow using KSM as a library #1610

Merged
merged 4 commits into from
Oct 18, 2021

Conversation

ahmed-mez
Copy link
Contributor

What this PR does / why we need it:

This PR makes ksm usable again as a library after the breaking changes introduced by #1499

  • It makes BuildStoresFunc returns a generic []cache.Store to allow using custom stores
  • It introduces a new method builder.BuildStores() which returns the stores as an alternative to builder.Build()

How does this change affect the cardinality of KSM: (increases, decreases or does not change cardinality)

Does not change cardinality

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #1605

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 11, 2021
@fpetkovski
Copy link
Contributor

Thanks for this PR @ahmed-mez. We did not take into account that KSM might be used as a library as well.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 13, 2021
@ahmed-mez
Copy link
Contributor Author

Thanks @fpetkovski for approving! Happy to open another PR to backport the fix to v2.1 once this gets merged.

@fpetkovski
Copy link
Contributor

Sure, that would be great!

@ahmed-mez
Copy link
Contributor Author

@fpetkovski what's the next step to get this PR approved / merged?

@fpetkovski
Copy link
Contributor

We still another approval from either @mrueg or @lilic :)

@mrueg
Copy link
Member

mrueg commented Oct 14, 2021

/lgtm
/hold for others to take a look as well.

Are there any test cases etc. we could include to ensure that we don't break compatibility for external consumers?

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 14, 2021
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 14, 2021
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 15, 2021
@ahmed-mez
Copy link
Contributor Author

@mrueg thanks for the review!

Are there any test cases etc. we could include to ensure that we don't break compatibility for external consumers?

I just added a test case in a separate commit.

pkg/builder/builder_test.go Outdated Show resolved Hide resolved
@mrueg
Copy link
Member

mrueg commented Oct 15, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 15, 2021
@ahmed-mez
Copy link
Contributor Author

@lilic Really appreciate it if you could take a look 🙇

/assign @lilic

pkg/builder/builder_test.go Outdated Show resolved Hide resolved
pkg/builder/builder_test.go Outdated Show resolved Hide resolved
pkg/builder/builder_test.go Outdated Show resolved Hide resolved
@dgrisonnet
Copy link
Member

/lgtm cancel

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 18, 2021
@ahmed-mez
Copy link
Contributor Author

Thanks @dgrisonnet - Comments addressed!

limitations under the License.
*/

package builder_test
Copy link
Member

Choose a reason for hiding this comment

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

should be builder

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is actually a best practice to make sure we don't access private methods and functions in the builder package.

Copy link
Member

Choose a reason for hiding this comment

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

👍 It makes sense for your particular case since you want to test what is exported by kube-state-metrics. I am too used to white-box testing where the unit tests are accessing everything 😅.

pkg/builder/builder_test.go Outdated Show resolved Hide resolved
@dgrisonnet
Copy link
Member

Looks good from my side thank you @ahmed-mez for taking the time to look into this.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 18, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahmed-mez, clamoriniere, dgrisonnet, fpetkovski, mrueg

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

The pull request process is described here

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

@dgrisonnet
Copy link
Member

Unholding since we have 3 approvals.

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 18, 2021
@k8s-ci-robot k8s-ci-robot merged commit d116961 into kubernetes:master Oct 18, 2021
@ahmed-mez
Copy link
Contributor Author

Thank you all for the reviews! Here is a PR to backport to v2.1 #1617

@dgrisonnet
Copy link
Member

@ahmed-mez could you also create a backport to release-2.2?

@ahmed-mez
Copy link
Contributor Author

@dgrisonnet sure thing! #1618

k8s-ci-robot added a commit that referenced this pull request Oct 20, 2021
mrueg added a commit that referenced this pull request Nov 16, 2021
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Breaking changes in the BuilderInterface released in a bug fix version (v2.1.1)
7 participants