Improve pathrecorder duplicate registration info
Print information from both the original path registration and the new path registration stack traces when encountering a duplicate. This helps the developer determine where the duplication is coming from and makes it much easier to resolve. Signed-off-by: Andy Goldstein <andy.goldstein@redhat.com> Kubernetes-commit: 04aa8f9dcdbc575fde37e25e45315359b0aa1ca6
This commit is contained in:
parent
1d3f2ce7a8
commit
b6300d119d
|
|
@ -103,10 +103,11 @@ func (m *PathRecorderMux) ListedPaths() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *PathRecorderMux) trackCallers(path string) {
|
func (m *PathRecorderMux) trackCallers(path string) {
|
||||||
|
stack := string(debug.Stack())
|
||||||
if existingStack, ok := m.pathStacks[path]; ok {
|
if existingStack, ok := m.pathStacks[path]; ok {
|
||||||
utilruntime.HandleError(fmt.Errorf("registered %q from %v", path, existingStack))
|
utilruntime.HandleError(fmt.Errorf("duplicate path registration of %q: original registration from %v\n\nnew registration from %v", path, existingStack, stack))
|
||||||
}
|
}
|
||||||
m.pathStacks[path] = string(debug.Stack())
|
m.pathStacks[path] = stack
|
||||||
}
|
}
|
||||||
|
|
||||||
// refreshMuxLocked creates a new mux and must be called while locked. Otherwise the view of handlers may
|
// refreshMuxLocked creates a new mux and must be called while locked. Otherwise the view of handlers may
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue