Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

channel neither has values in nor be closed . #2547

Merged
merged 4 commits into from
Apr 2, 2019
Merged

channel neither has values in nor be closed . #2547

merged 4 commits into from
Apr 2, 2019

Conversation

wayilau
Copy link
Contributor

@wayilau wayilau commented Jan 14, 2019

This PR is a

  • Feature Implementation
  • Bug Fix
  • Documentation

What this PR does / why we need it:
channel never closed when create a new one by "make", but also has no values in it.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 14, 2019
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jan 14, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @wayilau. Thanks for your PR.

I'm waiting for a kubernetes-incubator or kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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 the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 14, 2019
@jberkhahn
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 4, 2019
Copy link
Contributor

@MHBauer MHBauer left a comment

Choose a reason for hiding this comment

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

not sure why I got an email, I don't think I'm subscribed anymore.

@@ -35,7 +36,7 @@ func RunServer(opts *ServiceCatalogServerOptions, stopCh <-chan struct{}) error
if stopCh == nil {
/* the caller of RunServer should generate the stop channel
if there is a need to stop the API server */
stopCh = make(chan struct{})
stopCh = server.SetupSignalHandler()
Copy link
Contributor

Choose a reason for hiding this comment

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

should check the callers of this and make sure they're supplying a channel.

My guess is that there is the cli/cmd , and tests.

We should probably crash if this isn't set, but I haven't looked close enough to know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i will have a look about this. thank you for your review @MHBauer

Copy link
Contributor

Choose a reason for hiding this comment

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

Have you looked into this? what happens when it isn't set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, i was busy these days. i Will have a look it today or tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jberkhahn the caller give a channel actually, which created by server.SetupSignalHandler().
but if stopCh == nil, just make one can not be closed at all. so i give the code above.

Copy link
Contributor

Choose a reason for hiding this comment

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

from that description, I think this should panic and crash with an informative message.

Copy link
Contributor Author

@wayilau wayilau Mar 14, 2019

Choose a reason for hiding this comment

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

@MHBauer i modify the code to "panic", also give a message when the stop channel was not set. Please help review it when you are idle.

@wayilau
Copy link
Contributor Author

wayilau commented Mar 14, 2019

/retest

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 21, 2019
@wayilau
Copy link
Contributor Author

wayilau commented Mar 22, 2019

@jberkhahn

@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 Mar 22, 2019
Copy link
Contributor

@MHBauer MHBauer left a comment

Choose a reason for hiding this comment

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

fix the comment and the code can go in as it is.
/approve
/hold

if there is a need to stop the API server */
stopCh = make(chan struct{})
/* whe RespectsStopCh: true and the stop channel is nil, error returned*/
return fmt.Errorf("%v", "the stop channel can not be nil")
Copy link
Contributor

Choose a reason for hiding this comment

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

An error is good enough, but I still think this should be a panic. it's unreachable in normal case. If someone is going to library-ize this code and use it in their own apiserver, they need to know to set it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, i will change the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MHBauer i've changed the code comment as it is.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MHBauer

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 Mar 22, 2019
@wayilau
Copy link
Contributor Author

wayilau commented Apr 2, 2019

@MHBauer @jberkhahn
I've changed the comments as it is. also the panic code when the stopCh not set.

@MHBauer
Copy link
Contributor

MHBauer commented Apr 2, 2019

I'm fine with this
/hold cancel

@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 Apr 2, 2019
@jberkhahn
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 2, 2019
@k8s-ci-robot k8s-ci-robot merged commit 63df33c into kubernetes-retired:master Apr 2, 2019
viviyww pushed a commit to viviyww/service-catalog that referenced this pull request May 10, 2019
* channel neither has values in nor be closed .

* panic api server when stop channel not set

* Return Error when the stop channel is nil and RespectsStopCh=true
Add Tests for this case.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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 Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

4 participants