Commit d8ae847c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 3024e434
......@@ -262,6 +262,12 @@ func (m *Master) recovery(ctx context.Context) (err error) {
//defer xerr.Context(&err, "master: recovery")
defer m.errctx(&err, "recovery")
my.Context(&ctx, "recovery")
defer xerr.Context(&err, ctx)
xcontext.Running(&ctx, "recovery")
defer xerr.Context(&err, ctx)
m.setClusterState(neo.ClusterRecovering)
rctx, rcancel := context.WithCancel(ctx)
defer rcancel()
......@@ -323,15 +329,15 @@ loop:
// ptid ↑ and if so we should take partition table from there
case r := <-recovery:
if r.err != nil {
m.logf("%v", r.err)
logf(ctx, "%v", r.err)
if !xcontext.Canceled(errors.Cause(r.err)) {
m.logf("%v: closing link", r.node.Link)
logf(ctx, "%v: closing link", r.node.Link)
// close stor link / update .nodeTab
err := r.node.Link.Close()
if err != nil {
m.logf("master: %v\n", r.node.Link)
logf(ctx, "master: %v", err)
}
m.nodeTab.SetNodeState(r.node, DOWN)
......
......@@ -135,3 +135,51 @@ func Canceled(err error) bool {
return false
}
// ---- operational stack ----
// Operation provides text representing currently running operation
type Operation struct {
Parent *operation
Name string
}
// String returns string representing whole operational stack
func (o *Operation) String() string {
if o == nil {
return ""
}
prefix := Parent.String()
if prefix != "" {
prefix += ": "
}
return prefix + o.Name
}
type opKey struct{}
func PushOp(ctxp *context.Context, name string) {
*ctxp = context.WithValue(&Operation{Parent: CurrentOp(*ctxp), Name: name})
}
// CurrentOp returns current operation represented by context.
// if there is no current operation - it returns nil.
func CurrentOp(ctx Context) *Operation {
op := ctx.Value(opKey)
if op == nil {
return nil
}
return op.(*Operation)
}
// XXX place
func Logf(ctx context.Context, format string, argv ...interface{}) {
s := CurrentOp(ctx).String()
if s != "" {
s += ": "
}
s += fmt.Sprintf(format, argv...)
log.Log(s)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment