Skip to content

add a method to stop the mixer Store explicitly#3468

Merged
jmuk merged 4 commits intoistio:masterfrom
jmuk:store_close
Feb 16, 2018
Merged

add a method to stop the mixer Store explicitly#3468
jmuk merged 4 commits intoistio:masterfrom
jmuk:store_close

Conversation

@jmuk
Copy link
Copy Markdown
Contributor

@jmuk jmuk commented Feb 14, 2018

Previously it accepted context.Context for the validity of the
store, but that does not fit well with the mixer's calling
structure. Also context's document says a struct shouldn't store
the context as a field.

This PR adds Stop method to do this.

Previously it accepted context.Context for the validity of the
store, but that does not fit well with the mixer's calling
structure. Also context's document says a struct shouldn't store
the context as a field.

Considering the situation, I think io.Closer would be better.
@jmuk jmuk requested a review from a team February 14, 2018 00:09
@jmuk
Copy link
Copy Markdown
Contributor Author

jmuk commented Feb 14, 2018

/assign @geeknoid

c.shutdown <- struct{}{}
c.shutdown = nil
if err := c.store.Close(); err != nil {
log.Errorf("Failed on close: %v", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you improve the error message (i.e. "store.Close failed during runtime shutdown: %v")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

if c.shutdown != nil {
c.shutdown <- struct{}{}
c.shutdown = nil
if err := c.store.Close(); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should the close be before c.waitQuiesceListening, or after?
The background go-routine will be listening to both the c.shutdown channel, as well as the channel returned by the store. When the store is closed here, what will happen to the channel that is returned by the store? (Or

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ooh, nice catch! The watch channel shall be closed on store's Close(), that means the ordering is incorrect. watchChanges might not finish at all. Changed the order, waitQuiesceListening first, and then store.Close. Thank you!

@ldemailly
Copy link
Copy Markdown
Member

@ozevren is this good to go now ? if so please / l g t m

var _ store.Backend = &Store{}
var _ probe.SupportsProbe = &Store{}

// Close implements io.Closer
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we have to implement io.Closer? I don't think we're using this interface to reference the Store.

It looks to me, if we simply have a Close() method that returns nothing, we can simplify some of the client code paths.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I personally think it's not a good idea to use the same name Close but does not implement io.Closer, I feel like it's one of very basic interface of golang.

So maybe it's better to rename it rather than simply changing return type -- replaced Stop. Let me know if you have other ideas.

}

// checkAndCreateCaches checks the presence of custom resource definitions through the discovery API,
// and then create caches through lwBUilder which is in kinds. It retries within the timeout duration.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Update comments? There is no timeout anymore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@jmuk
Copy link
Copy Markdown
Contributor Author

jmuk commented Feb 16, 2018

/test e2e-simple

@jmuk jmuk changed the title store interface to support io.Closer add a method to stop the mixer Store explicitly Feb 16, 2018
@jmuk
Copy link
Copy Markdown
Contributor Author

jmuk commented Feb 16, 2018

PTAL; also updated the PR title / comment.

Note that the failures seem to be unrelated side effects of #3529, nothing by this PR.

@yutongz
Copy link
Copy Markdown
Contributor

yutongz commented Feb 16, 2018

/test e2e-simple
/test e2e-bookInfo

We renamed e2e-smoke to e2e-bookInfo and added e2e-simple
ref: #3529

@ozevren
Copy link
Copy Markdown
Contributor

ozevren commented Feb 16, 2018

/lgtm

@istio-merge-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ozevren

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

Details 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants