Merge "veyron/lib/exec: fix potential race with TestWaitAndCleanRace and clean up logging"
diff --git a/runtimes/google/ipc/client.go b/runtimes/google/ipc/client.go
index 8227e88..064f282 100644
--- a/runtimes/google/ipc/client.go
+++ b/runtimes/google/ipc/client.go
@@ -373,7 +373,11 @@
 	if skipResolve {
 		servers = []string{name}
 	} else {
-		if resolved, err := c.ns.Resolve(ctx, name, naming.RootBlessingPatternOpt(mtPattern)); err != nil {
+		resolveOpts := []naming.ResolveOpt{naming.RootBlessingPatternOpt(mtPattern)}
+		if noDischarges {
+			resolveOpts = append(resolveOpts, vc.NoDischarges{})
+		}
+		if resolved, err := c.ns.Resolve(ctx, name, resolveOpts...); err != nil {
 			if verror.Is(err, naming.ErrNoSuchName.ID) {
 				return nil, verror.RetryRefetch, verror.Make(verror.NoServers, ctx, name)
 			}
diff --git a/runtimes/google/ipc/client_test.go b/runtimes/google/ipc/client_test.go
index a98eca7..f9aa034 100644
--- a/runtimes/google/ipc/client_test.go
+++ b/runtimes/google/ipc/client_test.go
@@ -5,7 +5,6 @@
 	"io"
 	"os"
 	"path/filepath"
-	"reflect"
 	"runtime"
 	"testing"
 	"time"
@@ -14,7 +13,6 @@
 	"veyron.io/veyron/veyron2/ipc"
 	"veyron.io/veyron/veyron2/naming"
 	"veyron.io/veyron/veyron2/rt"
-	old_verror "veyron.io/veyron/veyron2/verror"
 	verror "veyron.io/veyron/veyron2/verror2"
 	"veyron.io/veyron/veyron2/vlog"
 
@@ -189,7 +187,7 @@
 	i := 0
 	for {
 		if err := call.Recv(&i); err != nil {
-			return i, err
+			return i, verror.Convert(verror.Internal, call, err)
 		}
 	}
 }
@@ -448,8 +446,8 @@
 	if verr != nil {
 		t.Fatalf("unexpected error: %s", verr)
 	}
-	if got, want := err, (old_verror.Standard{Msg: "EOF"}); !reflect.DeepEqual(got, want) {
-		t.Fatalf("got %v, want %v", got, want)
+	if !verror.Is(err, "veyron.io/veyron/veyron2/verror.Internal") || err.Error() != `ipc.test:"".Sink: Internal error: EOF` {
+		t.Errorf("wrong error: %#v", err)
 	}
 	if got := result; got != want {
 		t.Errorf("got %d, want %d", got, want)
diff --git a/runtimes/google/ipc/stream/vc/vc.go b/runtimes/google/ipc/stream/vc/vc.go
index 4460e6e..38d8db6 100644
--- a/runtimes/google/ipc/stream/vc/vc.go
+++ b/runtimes/google/ipc/stream/vc/vc.go
@@ -70,6 +70,7 @@
 
 func (NoDischarges) IPCCallOpt()     {}
 func (NoDischarges) IPCStreamVCOpt() {}
+func (NoDischarges) NSResolveOpt()   {}
 
 var _ stream.VC = (*VC)(nil)
 
diff --git a/runtimes/google/naming/namespace/resolve.go b/runtimes/google/naming/namespace/resolve.go
index d010811..e1c4109 100644
--- a/runtimes/google/naming/namespace/resolve.go
+++ b/runtimes/google/naming/namespace/resolve.go
@@ -14,7 +14,7 @@
 	"veyron.io/veyron/veyron2/vlog"
 )
 
-func (ns *namespace) resolveAgainstMountTable(ctx context.T, client ipc.Client, e *naming.MountEntry, pattern string) (*naming.MountEntry, error) {
+func (ns *namespace) resolveAgainstMountTable(ctx context.T, client ipc.Client, e *naming.MountEntry, pattern string, opts ...ipc.CallOpt) (*naming.MountEntry, error) {
 	// Try each server till one answers.
 	finalErr := errors.New("no servers to resolve query")
 	for _, s := range e.Servers {
@@ -32,7 +32,7 @@
 		}
 		// Not in cache, call the real server.
 		callCtx, _ := ctx.WithTimeout(callTimeout)
-		call, err := client.StartCall(callCtx, pattern_and_name, "ResolveStepX", nil, options.NoResolve(true))
+		call, err := client.StartCall(callCtx, pattern_and_name, "ResolveStepX", nil, append(opts, options.NoResolve(true))...)
 		if err != nil {
 			finalErr = err
 			vlog.VI(2).Infof("ResolveStep.StartCall %s failed: %s", name, err)
@@ -82,6 +82,12 @@
 	}
 	pattern := getRootPattern(opts)
 	client := veyron2.RuntimeFromContext(ctx).Client()
+	var callOpts []ipc.CallOpt
+	for _, opt := range opts {
+		if callOpt, ok := opt.(ipc.CallOpt); ok {
+			callOpts = append(callOpts, callOpt)
+		}
+	}
 	// Iterate walking through mount table servers.
 	for remaining := ns.maxResolveDepth; remaining > 0; remaining-- {
 		vlog.VI(2).Infof("ResolveX(%s) loop %v", name, *e)
@@ -91,7 +97,7 @@
 		}
 		var err error
 		curr := e
-		if e, err = ns.resolveAgainstMountTable(ctx, client, curr, pattern); err != nil {
+		if e, err = ns.resolveAgainstMountTable(ctx, client, curr, pattern, callOpts...); err != nil {
 			// Lots of reasons why another error can happen.  We are trying
 			// to single out "this isn't a mount table".
 			if notAnMT(err) {
diff --git a/security/agent/agent_test.go b/security/agent/agent_test.go
index 52badfb..d0acb43 100644
--- a/security/agent/agent_test.go
+++ b/security/agent/agent_test.go
@@ -66,9 +66,7 @@
 	tests := []testInfo{
 		{"BlessSelf", V{"self"}, newBlessing(t, "blessing"), nil},
 		{"Bless", V{newPrincipal(t).PublicKey(), newBlessing(t, "root"), "extension", security.UnconstrainedUse()}, newBlessing(t, "root/extension"), nil},
-		// TODO(toddw): This change is necessary for vom2:
-		//{"Sign", V{make([]byte, 10)}, security.Signature{Purpose: []byte{}, R: []byte{1}, S: []byte{1}}, nil},
-		{"Sign", V{make([]byte, 10)}, security.Signature{R: []byte{1}, S: []byte{1}}, nil},
+		{"Sign", V{make([]byte, 10)}, security.Signature{Purpose: []byte{}, R: []byte{1}, S: []byte{1}}, nil},
 		{"MintDischarge", V{thirdPartyCaveat, security.UnconstrainedUse()}, discharge, nil},
 		{"PublicKey", V{}, mockP.PublicKey(), nil},
 		{"AddToRoots", V{newBlessing(t, "blessing")}, nil, verror2.Make(addToRootsErr, nil)},
diff --git a/services/identity/identityd/main.go b/services/identity/identityd/main.go
index 58a5a75..c9fbb40 100644
--- a/services/identity/identityd/main.go
+++ b/services/identity/identityd/main.go
@@ -114,6 +114,7 @@
 			ClientSecret:            clientSecret,
 			BlessingLogReader:       blessingLogReader,
 			RevocationManager:       revocationManager,
+			DischargerLocation:      naming.JoinAddressName(published[0], dischargerService),
 			MacaroonBlessingService: naming.JoinAddressName(published[0], macaroonService),
 		})
 		if err != nil {
diff --git a/services/mgmt/stats/impl/stats_test.go b/services/mgmt/stats/impl/stats_test.go
index 661f6f4..c2c342a 100644
--- a/services/mgmt/stats/impl/stats_test.go
+++ b/services/mgmt/stats/impl/stats_test.go
@@ -106,9 +106,7 @@
 			t.Fatalf("expected more stream values")
 		}
 		got := iterator.Value()
-		// TODO(toddw): This change is necessary for vom2:
-		//expected := types.Change{Name: "testing/foo/bar", Value: int64(10), ResumeMarker: noRM}
-		expected := types.Change{Name: "testing/foo/bar", Value: int64(10)}
+		expected := types.Change{Name: "testing/foo/bar", Value: int64(10), ResumeMarker: noRM}
 		if !reflect.DeepEqual(got, expected) {
 			t.Errorf("unexpected result. Got %#v, want %#v", got, expected)
 		}
@@ -119,9 +117,7 @@
 			t.Fatalf("expected more stream values")
 		}
 		got = iterator.Value()
-		// TODO(toddw): This change is necessary for vom2:
-		//expected := types.Change{Name: "testing/foo/bar", Value: int64(15), ResumeMarker: noRM}
-		expected = types.Change{Name: "testing/foo/bar", Value: int64(15)}
+		expected = types.Change{Name: "testing/foo/bar", Value: int64(15), ResumeMarker: noRM}
 		if !reflect.DeepEqual(got, expected) {
 			t.Errorf("unexpected result. Got %#v, want %#v", got, expected)
 		}
@@ -132,9 +128,7 @@
 			t.Fatalf("expected more stream values")
 		}
 		got = iterator.Value()
-		// TODO(toddw): This change is necessary for vom2:
-		//expected := types.Change{Name: "testing/foo/bar", Value: int64(17), ResumeMarker: noRM}
-		expected = types.Change{Name: "testing/foo/bar", Value: int64(17)}
+		expected = types.Change{Name: "testing/foo/bar", Value: int64(17), ResumeMarker: noRM}
 		if !reflect.DeepEqual(got, expected) {
 			t.Errorf("unexpected result. Got %#v, want %#v", got, expected)
 		}
diff --git a/tools/mgmt/device/acl_test.go b/tools/mgmt/device/acl_test.go
index ea054ff..ce6fdce 100644
--- a/tools/mgmt/device/acl_test.go
+++ b/tools/mgmt/device/acl_test.go
@@ -186,7 +186,7 @@
 				},
 				"Write": access.ACL{
 					In:    []security.BlessingPattern{"friends/...", "friends/alice", "self/..."},
-					NotIn: []string{},
+					NotIn: []string(nil),
 				},
 			},
 			etag: "anEtagForToday",
@@ -201,11 +201,11 @@
 				},
 				"Read": access.ACL{
 					In:    []security.BlessingPattern{"other/...", "self/..."},
-					NotIn: []string{},
+					NotIn: []string(nil),
 				},
 				"Write": access.ACL{
 					In:    []security.BlessingPattern{"friends/...", "friends/alice", "self/..."},
-					NotIn: []string{},
+					NotIn: []string(nil),
 				},
 			},
 			etag: "anEtagForTomorrow",
@@ -277,7 +277,7 @@
 			acl: access.TaggedACLMap{
 				"Read": access.ACL{
 					In:    []security.BlessingPattern{"friend", "other", "self/..."},
-					NotIn: []string{},
+					NotIn: []string(nil),
 				},
 			},
 			etag: "anEtagForToday",