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

🐛 Use a cheaper method for storage policy #2467

Merged

Conversation

rikatz
Copy link
Contributor

@rikatz rikatz commented Oct 26, 2023

What this PR does / why we need it:
During the debug of #2453 (comment) we have figured out this call is too expensive for environments with a lot of resources, like more than 10k resources.

This may turn into a huge slow query that can take up to 20 minutes.

Instead, we should be using the "QueryAssociatedProfiles" call that, given an object (like a disk), check if it has associated storage policies

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 #

Note vmware/govmomi#3268 implements the call directly on pbmClient, but as this is not released yet I have added it on the new utils file.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 26, 2023
@rikatz
Copy link
Contributor Author

rikatz commented Oct 26, 2023

/hold
I will compile it locally and run on our environment just to make sure the problem is gone

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Oct 26, 2023
@rikatz rikatz force-pushed the improve-storage-policy-query branch 2 times, most recently from 7fe9282 to 1172a62 Compare October 26, 2023 16:26
@codecov
Copy link

codecov bot commented Oct 26, 2023

Codecov Report

Attention: 31 lines in your changes are missing coverage. Please review.

Comparison is base (c23a946) 63.45% compared to head (40b2c61) 63.43%.
Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2467      +/-   ##
==========================================
- Coverage   63.45%   63.43%   -0.03%     
==========================================
  Files         122      123       +1     
  Lines        8754     8773      +19     
==========================================
+ Hits         5555     5565      +10     
- Misses       2785     2788       +3     
- Partials      414      420       +6     
Files Coverage Δ
pkg/services/govmomi/storageprofile_util.go 0.00% <0.00%> (ø)
pkg/services/govmomi/service.go 3.45% <0.00%> (+2.20%) ⬆️

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rikatz rikatz changed the title 🐛 Use a less expensive method for storage policy 🐛 Use a cheaper method for storage policy Oct 26, 2023
@rikatz
Copy link
Contributor Author

rikatz commented Oct 26, 2023

/hold cancel
Tested on our environment, creation is being really fast now with Storage Policies and respecting the associated storage policy specified

@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 26, 2023
Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

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

Thx! Just nits.

Should we backport this change/fix?

pkg/services/govmomi/service.go Outdated Show resolved Hide resolved
pkg/services/govmomi/service.go Outdated Show resolved Hide resolved
pkg/services/govmomi/service.go Outdated Show resolved Hide resolved
pkg/services/govmomi/service.go Outdated Show resolved Hide resolved
pkg/services/govmomi/service_test.go Show resolved Hide resolved
@sbueringer
Copy link
Member

/assign @chrischdi

@rikatz
Copy link
Contributor Author

rikatz commented Oct 30, 2023

/retest
weird

@rikatz
Copy link
Contributor Author

rikatz commented Oct 30, 2023

Should we backport this change/fix?

Yes. On environments that, as an example don't reclaim PVs, there are going to be a lot of objects. Querying all of this objects is an expensive operation and may get cluster reconciliation stuck for a long time. IMHO at least for 1.7 and 1.8 this should be cherry picked.

Thanks!!

@sbueringer
Copy link
Member

Thank you!

/lgtm

/assign @chrischdi

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

LGTM label has been added.

Git tree hash: 2d507e25aa8439bb38a58223eea99981a95e68ff

@sbueringer
Copy link
Member

/cherry-pick release-1.8

@k8s-infra-cherrypick-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.8 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.8

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/test-infra repository.

@sbueringer
Copy link
Member

/cherry-pick release-1.7

@k8s-infra-cherrypick-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.7 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.7

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/test-infra repository.

@rikatz
Copy link
Contributor Author

rikatz commented Oct 30, 2023

/hold
I will just update govmomi for 0.33.1 and drop the copied code (thanks @dougm !!)

@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 30, 2023
@rikatz rikatz force-pushed the improve-storage-policy-query branch from 67dd3d7 to 4c588d9 Compare October 30, 2023 19:56
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 30, 2023
@rikatz
Copy link
Contributor Author

rikatz commented Oct 30, 2023

/hold cancel
@sbueringer @chrischdi last changes after Stefan's review:

  • bumped govmomi to v0.33.1 (it contains the required methods on pbmclient)
  • squashed commits
    Thanks!!

@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 30, 2023
@sbueringer
Copy link
Member

/lgtm

@chrischdi PTAL :)

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

LGTM label has been added.

Git tree hash: 0b28b37b746682e78686634550de1c03054f5598

Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

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

Only nits about comments and a optional question/thing for the test code, lgtm to it in general!

Thanks for also adding test cases!

pkg/services/govmomi/service.go Show resolved Hide resolved
pkg/services/govmomi/service_test.go Show resolved Hide resolved
@rikatz rikatz force-pushed the improve-storage-policy-query branch from 4c588d9 to 40b2c61 Compare October 31, 2023 11:44
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 31, 2023
@chrischdi
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrischdi

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

@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 31, 2023
@sbueringer
Copy link
Member

/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 31, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: e64c8031680e6e298591358973b06b37a64ed8a5

@k8s-ci-robot k8s-ci-robot merged commit e1dfd5c into kubernetes-sigs:main Oct 31, 2023
17 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.9 milestone Oct 31, 2023
@k8s-infra-cherrypick-robot

@sbueringer: #2467 failed to apply on top of branch "release-1.8":

Applying: Use a less expensive method for storage policy
Using index info to reconstruct a base tree...
M	go.mod
M	go.sum
M	pkg/services/govmomi/service.go
M	pkg/services/govmomi/service_test.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/services/govmomi/service_test.go
CONFLICT (content): Merge conflict in pkg/services/govmomi/service_test.go
Auto-merging pkg/services/govmomi/service.go
CONFLICT (content): Merge conflict in pkg/services/govmomi/service.go
Auto-merging go.sum
CONFLICT (content): Merge conflict in go.sum
Auto-merging go.mod
CONFLICT (content): Merge conflict in go.mod
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Use a less expensive method for storage policy
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-1.8

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/test-infra repository.

@k8s-infra-cherrypick-robot

@sbueringer: #2467 failed to apply on top of branch "release-1.7":

Applying: Use a less expensive method for storage policy
Using index info to reconstruct a base tree...
M	go.mod
M	go.sum
M	pkg/services/govmomi/service.go
M	pkg/services/govmomi/service_test.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/services/govmomi/service_test.go
CONFLICT (content): Merge conflict in pkg/services/govmomi/service_test.go
Auto-merging pkg/services/govmomi/service.go
CONFLICT (content): Merge conflict in pkg/services/govmomi/service.go
Auto-merging go.sum
CONFLICT (content): Merge conflict in go.sum
Auto-merging go.mod
CONFLICT (content): Merge conflict in go.mod
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Use a less expensive method for storage policy
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-1.7

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/test-infra repository.

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.

5 participants