-
Notifications
You must be signed in to change notification settings - Fork 458
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
Timeout topology watch and return better error messages for missing topology / namespaces #926
Changes from 6 commits
40f6e61
f504970
a399757
94443fe
09a824e
151835b
a1045b1
3482a5a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,6 @@ package topology | |
import ( | ||
"errors" | ||
"sync" | ||
"time" | ||
|
||
"github.com/m3db/m3/src/dbnode/sharding" | ||
"github.com/m3db/m3cluster/placement" | ||
|
@@ -90,17 +89,17 @@ func newDynamicTopology(opts DynamicOptions) (DynamicTopology, error) { | |
if err != nil { | ||
return nil, err | ||
} | ||
watch, err := services.Watch(opts.ServiceID(), opts.QueryOptions()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
logger := opts.InstrumentOptions().Logger() | ||
if err = waitOnInit(watch, opts.InitTimeout()); err != nil { | ||
logger.Errorf("dynamic topology initialization timed out in %s: %v", | ||
opts.InitTimeout().String(), err) | ||
logger.Info(`waiting for dynamic topology initialization. | ||
If this takes a long time, make sure that a topology / placement is configured`) | ||
// Watch will wait for an initial value so we don't need to do that | ||
// in this function. | ||
watch, err := services.Watch(opts.ServiceID(), opts.QueryOptions()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
logger.Info("initial topology / placement value received") | ||
|
||
m, err := getMapFromUpdate(watch.Get(), opts.HashGen()) | ||
if err != nil { | ||
|
@@ -185,19 +184,6 @@ func (t *dynamicTopology) MarkShardsAvailable( | |
return ps.MarkShardsAvailable(instanceID, shardIDs...) | ||
} | ||
|
||
func waitOnInit(w services.Watch, d time.Duration) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We finally removed this, noice! |
||
if d <= 0 { | ||
<-w.C() // Wait for the first placement indefinitely | ||
return nil | ||
} | ||
select { | ||
case <-w.C(): | ||
return nil | ||
case <-time.After(d): | ||
return errInitTimeOut | ||
} | ||
} | ||
|
||
func getMapFromUpdate(data interface{}, hashGen sharding.HashGen) (Map, error) { | ||
service, ok := data.(services.Service) | ||
if !ok { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
can't just delete these (b/w compatibility and all), need to mark deprecated instead
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.
Spoke offline and agreed its ok in this case because it was undocumented config and we're breaking the functionaltiy anyways