Revert "namespace: Make Resolve go all the way down piggybacked mounts."
This reverts commit 98c8e906fca16b2f0ca8117d767d3f6367851057.
MultiPart: 2/3
Change-Id: I47659f07fef3096fab823389af704f18ce8edb30
diff --git a/cmd/namespace/doc.go b/cmd/namespace/doc.go
index a91480a..64a2ddb 100644
--- a/cmd/namespace/doc.go
+++ b/cmd/namespace/doc.go
@@ -128,8 +128,6 @@
-insecure=false
Insecure mode: May return results from untrusted servers and invoke Resolve
on untrusted mounttables
- -s=false
- True to perform a shallow resolution
Namespace resolvetomt - Finds the address of the mounttable that holds an object name
diff --git a/cmd/namespace/impl.go b/cmd/namespace/impl.go
index b776ddf..30eb4ec 100644
--- a/cmd/namespace/impl.go
+++ b/cmd/namespace/impl.go
@@ -40,13 +40,11 @@
flagInsecureResolve bool
flagInsecureResolveToMT bool
flagDeleteSubtree bool
- flagShallowResolve bool
)
func init() {
cmdGlob.Flags.BoolVar(&flagLongGlob, "l", false, "Long listing format.")
cmdResolve.Flags.BoolVar(&flagInsecureResolve, "insecure", false, "Insecure mode: May return results from untrusted servers and invoke Resolve on untrusted mounttables")
- cmdResolve.Flags.BoolVar(&flagShallowResolve, "s", false, "True to perform a shallow resolution")
cmdResolveToMT.Flags.BoolVar(&flagInsecureResolveToMT, "insecure", false, "Insecure mode: May return results from untrusted servers and invoke Resolve on untrusted mounttables")
cmdDelete.Flags.BoolVar(&flagDeleteSubtree, "r", false, "Delete all children of the name in addition to the name itself.")
}
@@ -215,13 +213,7 @@
if flagInsecureResolve {
opts = append(opts, options.NameResolutionAuthorizer{security.AllowEveryone()})
}
- var err error
- var me *naming.MountEntry
- if flagShallowResolve {
- me, err = ns.ShallowResolve(ctx, name, opts...)
- } else {
- me, err = ns.Resolve(ctx, name, opts...)
- }
+ me, err := ns.Resolve(ctx, name, opts...)
if err != nil {
ctx.Infof("ns.Resolve(%q) failed: %v", name, err)
return err
diff --git a/cmd/vrpc/vrpc.go b/cmd/vrpc/vrpc.go
index 774cfd3..af9538b 100644
--- a/cmd/vrpc/vrpc.go
+++ b/cmd/vrpc/vrpc.go
@@ -139,16 +139,6 @@
ArgsLong: serverDesc,
}
-func getNamespaceOpts(opts []rpc.CallOpt) []naming.NamespaceOpt {
- var out []naming.NamespaceOpt
- for _, o := range opts {
- if co, ok := o.(naming.NamespaceOpt); ok {
- out = append(out, co)
- }
- }
- return out
-}
-
func runSignature(ctx *context.T, env *cmdline.Env, args []string) error {
// Error-check args.
var server, method string
@@ -169,14 +159,6 @@
if flagInsecure {
opts = append(opts, insecureOpts...)
}
- if flagShallowResolve {
- // Find the containing mount table.
- me, err := v23.GetNamespace(ctx).ShallowResolve(ctx, server, getNamespaceOpts(opts)...)
- if err != nil {
- return err
- }
- opts = append(opts, options.Preresolved{me})
- }
if method != "" {
methodSig, err := reserved.MethodSignature(ctx, server, method, opts...)
if err != nil {
diff --git a/cmd/vrpc/vrpc_test.go b/cmd/vrpc/vrpc_test.go
index 7cb9f94..f004bb9 100644
--- a/cmd/vrpc/vrpc_test.go
+++ b/cmd/vrpc/vrpc_test.go
@@ -131,7 +131,7 @@
defer shutdown()
var stdout, stderr bytes.Buffer
env := &cmdline.Env{Stdout: &stdout, Stderr: &stderr}
- args := []string{"signature", "-s", fmt.Sprintf("-show-reserved=%v", showReserved), name}
+ args := []string{"signature", fmt.Sprintf("-show-reserved=%v", showReserved), name}
if err := v23cmd.ParseAndRunForTest(cmdVRPC, ctx, env, args); err != nil {
t.Fatalf("%s: %v", args, err)
}
diff --git a/runtime/internal/naming/endpoint.go b/runtime/internal/naming/endpoint.go
index 0950c0a..382de34 100644
--- a/runtime/internal/naming/endpoint.go
+++ b/runtime/internal/naming/endpoint.go
@@ -47,6 +47,9 @@
func NewEndpoint(input string) (*Endpoint, error) {
ep := new(Endpoint)
+ // We have to guess this is a mount table if we don't know.
+ ep.IsMountTable = true
+
// If the endpoint does not end in a @, it must be in [blessing@]host:port format.
if parts := hostportEP.FindStringSubmatch(input); len(parts) > 0 {
hostport := parts[len(parts)-1]
@@ -57,7 +60,6 @@
err := ep.parseHostPort(blessing, hostport)
return ep, err
}
-
// Trim the prefix and suffix and parse the rest.
input = strings.TrimPrefix(strings.TrimSuffix(input, suffix), separator)
parts := strings.Split(input, separator)
diff --git a/runtime/internal/naming/endpoint_test.go b/runtime/internal/naming/endpoint_test.go
index ee94120..80a0fb6 100644
--- a/runtime/internal/naming/endpoint_test.go
+++ b/runtime/internal/naming/endpoint_test.go
@@ -144,12 +144,12 @@
}()
defaultVersion = 6
testcases := []endpointTest{
- {"localhost:10", "@6@@localhost:10@@00000000000000000000000000000000@s@@@", nil},
- {"localhost:", "@6@@localhost:@@00000000000000000000000000000000@s@@@", nil},
+ {"localhost:10", "@6@@localhost:10@@00000000000000000000000000000000@m@@@", nil},
+ {"localhost:", "@6@@localhost:@@00000000000000000000000000000000@m@@@", nil},
{"localhost", "", errInvalidEndpointString},
- {"(dev.v.io:service:mounttabled)@ns.dev.v.io:8101", "@6@@ns.dev.v.io:8101@@00000000000000000000000000000000@s@dev.v.io:service:mounttabled@@", nil},
- {"(dev.v.io:users:foo@bar.com)@ns.dev.v.io:8101", "@6@@ns.dev.v.io:8101@@00000000000000000000000000000000@s@dev.v.io:users:foo@bar.com@@", nil},
- {"(@1@tcp)@ns.dev.v.io:8101", "@6@@ns.dev.v.io:8101@@00000000000000000000000000000000@s@@1@tcp@@", nil},
+ {"(dev.v.io:service:mounttabled)@ns.dev.v.io:8101", "@6@@ns.dev.v.io:8101@@00000000000000000000000000000000@m@dev.v.io:service:mounttabled@@", nil},
+ {"(dev.v.io:users:foo@bar.com)@ns.dev.v.io:8101", "@6@@ns.dev.v.io:8101@@00000000000000000000000000000000@m@dev.v.io:users:foo@bar.com@@", nil},
+ {"(@1@tcp)@ns.dev.v.io:8101", "@6@@ns.dev.v.io:8101@@00000000000000000000000000000000@m@@1@tcp@@", nil},
}
runEndpointTests(t, testcases)
}
diff --git a/runtime/internal/naming/namespace/all_test.go b/runtime/internal/naming/namespace/all_test.go
index 1baed6a..6c93b0c 100644
--- a/runtime/internal/naming/namespace/all_test.go
+++ b/runtime/internal/naming/namespace/all_test.go
@@ -31,9 +31,9 @@
func resolveWithRetry(ctx *context.T, name string, opts ...naming.NamespaceOpt) *naming.MountEntry {
ns := v23.GetNamespace(ctx)
for {
- me, err := ns.ShallowResolve(ctx, name, opts...)
+ mp, err := ns.Resolve(ctx, name, opts...)
if err == nil {
- return me
+ return mp
}
time.Sleep(100 * time.Millisecond)
}
@@ -189,7 +189,7 @@
}
func testResolve(t *testing.T, ctx *context.T, ns namespace.T, name string, want ...string) {
- doResolveTest(t, "Resolve", ns.ShallowResolve, ctx, name, want)
+ doResolveTest(t, "Resolve", ns.Resolve, ctx, name, want)
}
type serverEntry struct {
@@ -219,9 +219,7 @@
eps := s.Status().Endpoints
t.Logf("server %q -> %s", eps[0].Name(), mountPoint)
// Wait until the mount point appears in the mount table.
- if len(mountPoint) > 0 {
- resolveWithRetry(ctx, mountPoint)
- }
+ resolveWithRetry(ctx, mountPoint)
return &serverEntry{mountPoint: mountPoint, stop: s.Stop, endpoint: eps[0], name: eps[0].Name()}
}
@@ -674,15 +672,14 @@
// (which has different blessings)
hproot := fmt.Sprintf("(otherroot)@%v", rootmt.endpoint.Addr())
eproot := naming.FormatEndpoint(rootmt.endpoint.Addr().Network(), rootmt.endpoint.Addr().String(), rootmt.endpoint.RoutingID(), naming.BlessingOpt("otherroot"), naming.ServesMountTable(rootmt.endpoint.ServesMountTable()))
- ns := v23.GetNamespace(ctx)
for _, root := range []string{hproot, eproot} {
name := naming.JoinAddressName(root, "mt")
- // Rooted name resolutions should fail authorization because of the "otherroot"
- if e, err := ns.ShallowResolve(clientCtx, name); verror.ErrorID(err) != verror.ErrNotTrusted.ID {
+ // Rooted name resolutions should fail authorization because of the "otherrot"
+ if e, err := clientNs.Resolve(clientCtx, name); verror.ErrorID(err) != verror.ErrNotTrusted.ID {
t.Errorf("resolve(%q) returned (%v, errorid=%v %v), wanted errorid=%v", name, e, verror.ErrorID(err), err, verror.ErrNotTrusted.ID)
}
// But not fail if the server authorization is skipped.
- if e, err := ns.ShallowResolve(clientCtx, name, options.NameResolutionAuthorizer{security.AllowEveryone()}); err != nil {
+ if e, err := clientNs.Resolve(clientCtx, name, options.NameResolutionAuthorizer{security.AllowEveryone()}); err != nil {
t.Errorf("resolve(%q): Got (%v, %v), expected resolution to succeed", name, e, err)
}
diff --git a/runtime/internal/naming/namespace/resolve.go b/runtime/internal/naming/namespace/resolve.go
index 2a0825d..4b0dfc7 100644
--- a/runtime/internal/naming/namespace/resolve.go
+++ b/runtime/internal/naming/namespace/resolve.go
@@ -96,7 +96,6 @@
// Resolve implements v.io/v23/naming.Namespace.
func (ns *namespace) Resolve(ctx *context.T, name string, opts ...naming.NamespaceOpt) (*naming.MountEntry, error) {
defer apilog.LogCallf(ctx, "name=%.10s...,opts...=%v", name, opts)(ctx, "") // gologcop: DO NOT EDIT, MUST BE FIRST STATEMENT
-
// If caller supplied a mount entry, use it.
e, skipResolution := preresolved(opts)
if e != nil {
@@ -124,7 +123,7 @@
if ctx.V(2) {
ctx.Infof("Resolve(%s) loop %v", name, *e)
}
- if !e.ServesMountTable {
+ if !e.ServesMountTable || terminal(e) {
if ctx.V(1) {
ctx.Infof("Resolve(%s) -> %v", name, *e)
}
@@ -149,26 +148,6 @@
return nil, verror.New(naming.ErrResolutionDepthExceeded, ctx)
}
-// ShallowResolve implements v.io/v23/naming.Namespace.
-func (ns *namespace) ShallowResolve(ctx *context.T, name string, opts ...naming.NamespaceOpt) (*naming.MountEntry, error) {
- defer apilog.LogCallf(ctx, "name=%.10s...,opts...=%v", name, opts)(ctx, "") // gologcop: DO NOT EDIT, MUST BE FIRST STATEMENT
-
- // Find the containing mount table.
- me, err := ns.ResolveToMountTable(ctx, name, opts...)
- if err != nil {
- return nil, err
- }
- if terminal(me) {
- return me, nil
- }
-
- // Resolve the entry directly.
- client := v23.GetClient(ctx)
- entry := new(naming.MountEntry)
- err = client.Call(ctx, name, "ResolveStep", nil, []interface{}{entry}, append(getCallOpts(opts), options.Preresolved{me})...)
- return entry, err
-}
-
// ResolveToMountTable implements v.io/v23/naming.Namespace.
func (ns *namespace) ResolveToMountTable(ctx *context.T, name string, opts ...naming.NamespaceOpt) (*naming.MountEntry, error) {
defer apilog.LogCallf(ctx, "name=%.10s...,opts...=%v", name, opts)(ctx, "") // gologcop: DO NOT EDIT, MUST BE FIRST STATEMENT
diff --git a/runtime/internal/testing/mocks/naming/namespace.go b/runtime/internal/testing/mocks/naming/namespace.go
index a15e6d3..fd0e407 100644
--- a/runtime/internal/testing/mocks/naming/namespace.go
+++ b/runtime/internal/testing/mocks/naming/namespace.go
@@ -135,10 +135,6 @@
return nil, verror.New(naming.ErrNoSuchName, ctx, fmt.Sprintf("Resolve name %q not found in %v", name, ns.mounts))
}
-func (ns *namespaceMock) ShallowResolve(ctx *context.T, name string, opts ...naming.NamespaceOpt) (*naming.MountEntry, error) {
- return ns.Resolve(ctx, name, opts...)
-}
-
func (ns *namespaceMock) ResolveToMountTable(ctx *context.T, name string, opts ...naming.NamespaceOpt) (*naming.MountEntry, error) {
defer apilog.LogCallf(ctx, "name=%.10s...,opts...=%v", name, opts)(ctx, "") // gologcop: DO NOT EDIT, MUST BE FIRST STATEMENT
// TODO(mattr): Implement this method for tests that might need it.
diff --git a/services/device/mgmt_v23_test.go b/services/device/mgmt_v23_test.go
index 85e3547..f8821d2 100644
--- a/services/device/mgmt_v23_test.go
+++ b/services/device/mgmt_v23_test.go
@@ -283,7 +283,7 @@
if err := testutil.RetryFor(10*time.Second, func() error {
// Set ExitErrorIsOk to true since we expect "namespace resolve" to fail
// if the name doesn't exist.
- c := withArgs(namespaceBin, "resolve", "-s", name)
+ c := withArgs(namespaceBin, "resolve", name)
c.ExitErrorIsOk = true
c.AddStderrWriter(os.Stderr)
if res = tr(c.Stdout()); len(res) > 0 {
@@ -475,7 +475,7 @@
if err := testutil.RetryFor(10*time.Second, func() error {
// Set ExitErrorIsOk to true since we expect "namespace resolve" to fail
// if the name doesn't exist.
- c := withArgs(namespaceBin, "resolve", "-s", name)
+ c := withArgs(namespaceBin, "resolve", name)
c.ExitErrorIsOk = true
c.AddStderrWriter(os.Stderr)
switch res = tr(c.Stdout()); {
@@ -518,7 +518,7 @@
resolve(mtEP + "/global")
namespaceRoot := sh.Vars[ref.EnvNamespacePrefix]
- output = withArgs(namespaceBin, "resolve", "-s", mtEP+"/global").Stdout()
+ output = withArgs(namespaceBin, "resolve", mtEP+"/global").Stdout()
if got, want := tr(output), namespaceRoot; got != want {
t.Fatalf("got %q, want %q", got, want)
}
@@ -537,7 +537,7 @@
if err := testutil.RetryFor(10*time.Second, func() error {
// Set ExitErrorIsOk to true since we expect "namespace resolve" to fail
// if the name doesn't exist.
- c := withArgs(namespaceBin, "resolve", "-s", name)
+ c := withArgs(namespaceBin, "resolve", name)
c.ExitErrorIsOk = true
c.AddStderrWriter(os.Stderr)
if res = tr(c.Stdout()); len(res) == 0 {
diff --git a/services/wspr/internal/namespace/namespace.vdl b/services/wspr/internal/namespace/namespace.vdl
index 0bc7e81..fba8427 100644
--- a/services/wspr/internal/namespace/namespace.vdl
+++ b/services/wspr/internal/namespace/namespace.vdl
@@ -27,12 +27,6 @@
// ResolveToMountTable resolves a name to the address of the mounttable
// directly hosting it.
ResolveToMountTable(name string) ([]string | error)
- // ShallowResolve resolves the object name into its mounted servers. It is the same
- // as Resolve except when mounttables are stacked below the same mount point. For example,
- // if service D is mounted onto /MTA/a/b and /MTA/a/b is mounted onto /MTB/x/y then
- // Resolve(/MTB/x/y) will return a pointer to D while ShallowResolve(/MTB/x/y) will
- // return a pointer to /MTA/a/b.
- ShallowResolve(name string) ([]string | error)
// FlushCacheEntry removes the namespace cache entry for a given name.
FlushCacheEntry(name string) (bool | error)
// DisableCache disables the naming cache.
diff --git a/services/wspr/internal/namespace/namespace.vdl.go b/services/wspr/internal/namespace/namespace.vdl.go
index 8dbf960..3163740 100644
--- a/services/wspr/internal/namespace/namespace.vdl.go
+++ b/services/wspr/internal/namespace/namespace.vdl.go
@@ -39,12 +39,6 @@
// ResolveToMountTable resolves a name to the address of the mounttable
// directly hosting it.
ResolveToMountTable(_ *context.T, name string, _ ...rpc.CallOpt) ([]string, error)
- // ShallowResolve resolves the object name into its mounted servers. It is the same
- // as Resolve except when mounttables are stacked below the same mount point. For example,
- // if service D is mounted onto /MTA/a/b and /MTA/a/b is mounted onto /MTB/x/y then
- // Resolve(/MTB/x/y) will return a pointer to D while ShallowResolve(/MTB/x/y) will
- // return a pointer to /MTA/a/b.
- ShallowResolve(_ *context.T, name string, _ ...rpc.CallOpt) ([]string, error)
// FlushCacheEntry removes the namespace cache entry for a given name.
FlushCacheEntry(_ *context.T, name string, _ ...rpc.CallOpt) (bool, error)
// DisableCache disables the naming cache.
@@ -105,11 +99,6 @@
return
}
-func (c implNamespaceClientStub) ShallowResolve(ctx *context.T, i0 string, opts ...rpc.CallOpt) (o0 []string, err error) {
- err = v23.GetClient(ctx).Call(ctx, c.name, "ShallowResolve", []interface{}{i0}, []interface{}{&o0}, opts...)
- return
-}
-
func (c implNamespaceClientStub) FlushCacheEntry(ctx *context.T, i0 string, opts ...rpc.CallOpt) (o0 bool, err error) {
err = v23.GetClient(ctx).Call(ctx, c.name, "FlushCacheEntry", []interface{}{i0}, []interface{}{&o0}, opts...)
return
@@ -227,12 +216,6 @@
// ResolveToMountTable resolves a name to the address of the mounttable
// directly hosting it.
ResolveToMountTable(_ *context.T, _ rpc.ServerCall, name string) ([]string, error)
- // ShallowResolve resolves the object name into its mounted servers. It is the same
- // as Resolve except when mounttables are stacked below the same mount point. For example,
- // if service D is mounted onto /MTA/a/b and /MTA/a/b is mounted onto /MTB/x/y then
- // Resolve(/MTB/x/y) will return a pointer to D while ShallowResolve(/MTB/x/y) will
- // return a pointer to /MTA/a/b.
- ShallowResolve(_ *context.T, _ rpc.ServerCall, name string) ([]string, error)
// FlushCacheEntry removes the namespace cache entry for a given name.
FlushCacheEntry(_ *context.T, _ rpc.ServerCall, name string) (bool, error)
// DisableCache disables the naming cache.
@@ -265,12 +248,6 @@
// ResolveToMountTable resolves a name to the address of the mounttable
// directly hosting it.
ResolveToMountTable(_ *context.T, _ rpc.ServerCall, name string) ([]string, error)
- // ShallowResolve resolves the object name into its mounted servers. It is the same
- // as Resolve except when mounttables are stacked below the same mount point. For example,
- // if service D is mounted onto /MTA/a/b and /MTA/a/b is mounted onto /MTB/x/y then
- // Resolve(/MTB/x/y) will return a pointer to D while ShallowResolve(/MTB/x/y) will
- // return a pointer to /MTA/a/b.
- ShallowResolve(_ *context.T, _ rpc.ServerCall, name string) ([]string, error)
// FlushCacheEntry removes the namespace cache entry for a given name.
FlushCacheEntry(_ *context.T, _ rpc.ServerCall, name string) (bool, error)
// DisableCache disables the naming cache.
@@ -336,10 +313,6 @@
return s.impl.ResolveToMountTable(ctx, call, i0)
}
-func (s implNamespaceServerStub) ShallowResolve(ctx *context.T, call rpc.ServerCall, i0 string) ([]string, error) {
- return s.impl.ShallowResolve(ctx, call, i0)
-}
-
func (s implNamespaceServerStub) FlushCacheEntry(ctx *context.T, call rpc.ServerCall, i0 string) (bool, error) {
return s.impl.FlushCacheEntry(ctx, call, i0)
}
@@ -430,16 +403,6 @@
},
},
{
- Name: "ShallowResolve",
- Doc: "// ShallowResolve resolves the object name into its mounted servers. It is the same\n// as Resolve except when mounttables are stacked below the same mount point. For example,\n// if service D is mounted onto /MTA/a/b and /MTA/a/b is mounted onto /MTB/x/y then\n// Resolve(/MTB/x/y) will return a pointer to D while ShallowResolve(/MTB/x/y) will\n// return a pointer to /MTA/a/b.",
- InArgs: []rpc.ArgDesc{
- {"name", ``}, // string
- },
- OutArgs: []rpc.ArgDesc{
- {"", ``}, // []string
- },
- },
- {
Name: "FlushCacheEntry",
Doc: "// FlushCacheEntry removes the namespace cache entry for a given name.",
InArgs: []rpc.ArgDesc{
diff --git a/services/wspr/internal/namespace/request_handler.go b/services/wspr/internal/namespace/request_handler.go
index 2fbf221..c262a50 100644
--- a/services/wspr/internal/namespace/request_handler.go
+++ b/services/wspr/internal/namespace/request_handler.go
@@ -62,14 +62,6 @@
return me.Names(), nil
}
-func (s *Server) ShallowResolve(ctx *context.T, _ rpc.ServerCall, name string) ([]string, error) {
- me, err := s.ns.ShallowResolve(ctx, name)
- if err != nil {
- return nil, verror.Convert(verror.ErrInternal, ctx, err)
- }
- return me.Names(), nil
-}
-
func (s *Server) ResolveToMountTable(ctx *context.T, _ rpc.ServerCall, name string) ([]string, error) {
me, err := s.ns.ResolveToMountTable(ctx, name)
if err != nil {