-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Master save and load state from etcd, and register on etcd. #2539
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
Conversation
go/master/service.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add logs to inform recover event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Done.
go/cmd/master/master.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inMemStore have not much code, but it'll be still more clear if we put it to inmen_store.go corresponding to etcd_store.go, also the interface Store.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Done.
go/master/etcd_store.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't know when to do cli.Close() to release etcd client resources, shall we catch signal INT and then call a DeleteEtcdStore? Or we can leave this to OS in this version.
I've also created an issue to talk about "how to gracefully shutdown master and pservers"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Very good point. Added TODO in the source code as well.
go/cmd/master/master.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is inMemStore for test only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, if endpoints is "", master will use inMemStore and have no fault tolerance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
go/cmd/master/master.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a question, why here do not use code of
store, err := master.NewEtcdStore(eps, master.DefaultLockPath, master.DefaultStatePath, *ttlSec)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dzhwinter great question!
If we use store, err := ... here, it would be incorrect. Because then we actually created a new store variable, because we are in a new scope. The store would be a different variable than var store master.Store. What happened here is called store is "shadowed".
Please see here for me detail.
https://developmentality.wordpress.com/2014/03/03/go-gotcha-1-variable-shadowing-within-inner-scope-due-to-use-of-operator/
go vet -shadow can detect them:
https://golang.org/cmd/vet/#hdr-Shadowed_variables
:= is called short variable declarations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so kind of you. get it, thanks!
bc2ef38 to
eb68983
Compare
typhoonzero
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes: #2537 #2506