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

Remove repeated random string generations in scheduler volume predicate #53989

Merged

Conversation

shyamjvs
Copy link
Member

Ref #53327

@wojtek-t @liggitt @jsafrane - Does this look ok to you?

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 16, 2017
@shyamjvs
Copy link
Member Author

I'll try running kubemark-5000 with this change and see the outcome.

@shyamjvs shyamjvs added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 16, 2017
}

return c.predicate
}

func (c *MaxPDVolumeCountChecker) getNextVolumeIDPrefix() string {
c.lock.Lock()
defer c.lock.Unlock()
Copy link
Member

Choose a reason for hiding this comment

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

can be lock-free with atomic.AddInt64(&c.volumeIDPrefixCounter, 1)

Copy link
Member Author

Choose a reason for hiding this comment

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

Smooth! Changed it.

@shyamjvs shyamjvs force-pushed the use-counter-in-scheduler branch 2 times, most recently from 874f578 to 82b2716 Compare October 16, 2017 14:00
@shyamjvs shyamjvs changed the title [WIP] Replace random string generation with counter in scheduler volume predicate Replace random string generation with counter in scheduler volume predicate Oct 16, 2017
@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. labels Oct 16, 2017
@shyamjvs shyamjvs added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 16, 2017
@shyamjvs
Copy link
Member Author

@liggitt Fixed stuff. PTAL.

@liggitt
Copy link
Member

liggitt commented Oct 16, 2017

change LGTM, will let sig-storage weigh in

@shyamjvs
Copy link
Member Author

cc @kubernetes/sig-storage-pr-reviews

@k8s-ci-robot k8s-ci-robot added the sig/storage Categorizes an issue or PR as relevant to SIG Storage. label Oct 16, 2017
// predicate() call so a deleted PVC used by two pods is counted as one volume
// and not as two. Also, appending a counter to a const string removes
// the need to create a random string each time (which is expensive).
randomPrefix := c.getNextVolumeIDPrefix()
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if a random prefix is needed for each predicate call. It may be good enough to just generate a random prefix once during initialization. All the structures used to count volumes in this predicate are local and shouldn't conflict if the predicate is running in parallel.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's precisely what I'm doing in this PR - a random prefix initialized once and then just appending it to a counter. Do you mean sth else?

Copy link
Member

Choose a reason for hiding this comment

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

I mean, I don't think you even need a counter. Just a random prefix initialized in the beginning.

Copy link
Member Author

Choose a reason for hiding this comment

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

In that case do we even need the initialized string to be random? For e.g why not just set it to some hard-coded value like 'foobar'?

Copy link
Member

Choose a reason for hiding this comment

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

don't you risk conflicting with actual object names?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we just want a prefix that won't conflict with actual object names. So we could generate some random prefix, or have some hardcoded value that we are sure nobody would ever use. I don't think it needs to be generated every time we run the predicate though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed it - PTAL.

@shyamjvs shyamjvs changed the title Replace random string generation with counter in scheduler volume predicate Remove repeated random string generations in scheduler volume predicate Oct 17, 2017
@k8s-ci-robot
Copy link
Contributor

@shyamjvs: Adding do-not-merge/release-note-label-needed because the release note process has not been followed.

One of the following labels is required "release-note", "release-note-action-required", or "release-note-none".
Please see: https://github.com/kubernetes/community/blob/master/contributors/devel/pull-requests.md#write-release-notes-if-needed.

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-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Oct 17, 2017
@shyamjvs
Copy link
Member Author

shyamjvs commented Oct 17, 2017

@kubernetes/test-infra-maintainers Seems like there's a bug with the do-not-merge/release-note-label-needed label. Is it intended to be added (and the release-note-none label removed) each time I change the PR title? Also, even if I added the release-note-none label during PR creation, it still removed it and added the do-not-merge one. Other e.g.s - #54045, #53977. This only started happening recently.

@shyamjvs shyamjvs added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 17, 2017
maxVolumes: maxVolumes,
pvInfo: pvInfo,
pvcInfo: pvcInfo,
randomVolumeIDPrefix: rand.String(8),
Copy link
Member

Choose a reason for hiding this comment

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

Can this be 32 like originally? That way we reduce the chance of conflicting with the user's object names.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@cjwagner
Copy link
Member

@shyamjvs The release note process is WAI.
If you want to specify that there is no release note you should either:

  • make the release note "none" via the release-note block in the PR body like this: ```release-note none ```
  • or use the /release-note-none command

/release-note-none

@shyamjvs
Copy link
Member Author

@cjwagner Sounds good. But any idea why the label is getting removed on renaming the PR title?

@msau42
Copy link
Member

msau42 commented Oct 17, 2017

/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 17, 2017
@cjwagner
Copy link
Member

@shyamjvs Yeah, the PR 'edit' event is used to detect when the PR body text (including the release-note block) is changed, but it is also triggered by title changes. The Prow plugin that handled the event saw the release-note-none label on the PR and assumed that it was previously added to the PR based on the release-note block being "none" since there was no /release-note-none command on the PR. Since the plugin didn't find a release-note block after the edit event, it thinks that you removed the release-note block which is why it applies the release-note-needed label.

@shyamjvs
Copy link
Member Author

@davidopp / @bsalamat Could one of you please approve the PR?

@bsalamat
Copy link
Member

/approve

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bsalamat, msau42, shyamjvs

Associated issue: 53327

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 17, 2017
@shyamjvs
Copy link
Member Author

/test pull-kubernetes-e2e-gce

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 4105cca into kubernetes:master Oct 18, 2017
openshift-merge-robot added a commit to openshift/origin that referenced this pull request Oct 25, 2017
Automatic merge from submit-queue.

UPSTREAM: 53989: Remove repeated random string generations in scheduler volume predicate

@sjenning @smarterclayton

Though the upstream PR 53793 has been backported to kube 1.7 branch (53884). I am not sure if we have a plan for another origin rebase to latest kube 1.7, and if we would want to wait for that.

So this backports following 3 PRs:
kubernetes/kubernetes#53793 
kubernetes/kubernetes#53720 (partial)
kubernetes/kubernetes#53989
@shyamjvs shyamjvs deleted the use-counter-in-scheduler branch November 24, 2017 14:19
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. release-note-none Denotes a PR that doesn't merit a release note. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants