Merge "Veyron.core: Stop using ServerContext as a contex.T"
diff --git a/runtimes/google/ipc/cancel_test.go b/runtimes/google/ipc/cancel_test.go
index f7cf101..a1340fd 100644
--- a/runtimes/google/ipc/cancel_test.go
+++ b/runtimes/google/ipc/cancel_test.go
@@ -39,14 +39,14 @@
}
if c.child != "" {
- if _, err = client.StartCall(ctx, c.child, "Run", []interface{}{}); err != nil {
+ if _, err = client.StartCall(ctx.Context(), c.child, "Run", []interface{}{}); err != nil {
vlog.Error(err)
return err
}
}
vlog.Info(c.name, " waiting for cancellation")
- <-ctx.Done()
+ <-ctx.Context().Done()
vlog.Info(c.name, " cancelled")
close(c.cancelled)
return nil
diff --git a/runtimes/google/ipc/full_test.go b/runtimes/google/ipc/full_test.go
index 5f03ee0..bd95b94 100644
--- a/runtimes/google/ipc/full_test.go
+++ b/runtimes/google/ipc/full_test.go
@@ -697,7 +697,7 @@
func (s *dischargeTestServer) Discharge(ctx ipc.ServerContext, cav vdlutil.Any, impetus security.DischargeImpetus) (vdlutil.Any, error) {
s.impetus = append(s.impetus, impetus)
- s.traceid = append(s.traceid, ivtrace.FromContext(ctx).Trace().ID())
+ s.traceid = append(s.traceid, ivtrace.FromContext(ctx.Context()).Trace().ID())
return nil, fmt.Errorf("discharges not issued")
}
@@ -1076,7 +1076,7 @@
if err := call.Recv(&b); err != io.EOF {
s.t.Errorf("Got error %v, want io.EOF", err)
}
- <-call.Done()
+ <-call.Context().Done()
close(s.cancelled)
return nil
}
@@ -1086,7 +1086,7 @@
// even when the stream is stalled.
func (s *cancelTestServer) CancelStreamIgnorer(call ipc.ServerCall) error {
close(s.started)
- <-call.Done()
+ <-call.Context().Done()
close(s.cancelled)
return nil
}
diff --git a/runtimes/google/ipc/glob.go b/runtimes/google/ipc/glob.go
index 6e89d01..d8dea58 100644
--- a/runtimes/google/ipc/glob.go
+++ b/runtimes/google/ipc/glob.go
@@ -298,7 +298,7 @@
// copyMutableContext returns a new mutableContext copied from ctx. Changes to
// the original ctx don't affect the mutable fields in the returned object.
func copyMutableContext(ctx ipc.ServerContext) *mutableContext {
- c := &mutableContext{T: ctx}
+ c := &mutableContext{T: ctx.Context()}
c.M.ContextParams.Copy(ctx)
c.M.Blessings = ctx.Blessings()
c.M.Server = ctx.Server()
diff --git a/runtimes/google/vtrace/vtrace_test.go b/runtimes/google/vtrace/vtrace_test.go
index 6e2e64b..99a1cd0 100644
--- a/runtimes/google/vtrace/vtrace_test.go
+++ b/runtimes/google/vtrace/vtrace_test.go
@@ -64,7 +64,7 @@
func (c *testServer) Run(ctx ipc.ServerContext) error {
if c.forceCollect {
- ivtrace.FromContext(ctx).Trace().ForceCollect()
+ ivtrace.FromContext(ctx.Context()).Trace().ForceCollect()
}
client, err := iipc.InternalNewClient(c.sm, c.ns)
@@ -73,11 +73,11 @@
return err
}
- ivtrace.FromContext(ctx).Annotate(c.name + "-begin")
+ ivtrace.FromContext(ctx.Context()).Annotate(c.name + "-begin")
if c.child != "" {
var call ipc.Call
- if call, err = client.StartCall(ctx, c.child, "Run", []interface{}{}); err != nil {
+ if call, err = client.StartCall(ctx.Context(), c.child, "Run", []interface{}{}); err != nil {
vlog.Error(err)
return err
}
@@ -91,7 +91,7 @@
return outerr
}
}
- ivtrace.FromContext(ctx).Annotate(c.name + "-end")
+ ivtrace.FromContext(ctx.Context()).Annotate(c.name + "-end")
return nil
}
diff --git a/services/mgmt/application/impl/service.go b/services/mgmt/application/impl/service.go
index dd44662..2943a81 100644
--- a/services/mgmt/application/impl/service.go
+++ b/services/mgmt/application/impl/service.go
@@ -45,7 +45,7 @@
case 1:
return tokens[0], "", nil
default:
- return "", "", verror2.Make(errInvalidSuffix, context)
+ return "", "", verror2.Make(errInvalidSuffix, context.Context())
}
}
@@ -57,7 +57,7 @@
return empty, err
}
if version == "" {
- return empty, verror2.Make(errInvalidSuffix, context)
+ return empty, verror2.Make(errInvalidSuffix, context.Context())
}
i.store.Lock()
@@ -75,7 +75,7 @@
}
return envelope, nil
}
- return empty, verror2.Make(errNotFound, context)
+ return empty, verror2.Make(errNotFound, context.Context())
}
func (i *appRepoService) Put(context ipc.ServerContext, profiles []string, envelope application.Envelope) error {
@@ -85,7 +85,7 @@
return err
}
if version == "" {
- return verror2.Make(errInvalidSuffix, context)
+ return verror2.Make(errInvalidSuffix, context.Context())
}
i.store.Lock()
defer i.store.Unlock()
@@ -101,11 +101,11 @@
object := i.store.BindObject(path)
_, err := object.Put(context, envelope)
if err != nil {
- return verror2.Make(errOperationFailed, context)
+ return verror2.Make(errOperationFailed, context.Context())
}
}
if err := i.store.BindTransaction(tname).Commit(context); err != nil {
- return verror2.Make(errOperationFailed, context)
+ return verror2.Make(errOperationFailed, context.Context())
}
return nil
}
@@ -130,16 +130,16 @@
object := i.store.BindObject(path)
found, err := object.Exists(context)
if err != nil {
- return verror2.Make(errOperationFailed, context)
+ return verror2.Make(errOperationFailed, context.Context())
}
if !found {
- return verror2.Make(errNotFound, context)
+ return verror2.Make(errNotFound, context.Context())
}
if err := object.Remove(context); err != nil {
- return verror2.Make(errOperationFailed, context)
+ return verror2.Make(errOperationFailed, context.Context())
}
if err := i.store.BindTransaction(tname).Commit(context); err != nil {
- return verror2.Make(errOperationFailed, context)
+ return verror2.Make(errOperationFailed, context.Context())
}
return nil
}
diff --git a/services/mgmt/binary/impl/service.go b/services/mgmt/binary/impl/service.go
index 149a69d..5fca698 100644
--- a/services/mgmt/binary/impl/service.go
+++ b/services/mgmt/binary/impl/service.go
@@ -80,33 +80,33 @@
func (i *binaryService) Create(context ipc.ServerContext, nparts int32, mediaInfo repository.MediaInfo) error {
vlog.Infof("%v.Create(%v, %v)", i.suffix, nparts, mediaInfo)
if nparts < 1 {
- return verror.Make(errInvalidParts, context)
+ return verror.Make(errInvalidParts, context.Context())
}
parent, perm := filepath.Dir(i.path), os.FileMode(0700)
if err := os.MkdirAll(parent, perm); err != nil {
vlog.Errorf("MkdirAll(%v, %v) failed: %v", parent, perm, err)
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
prefix := "creating-"
tmpDir, err := ioutil.TempDir(parent, prefix)
if err != nil {
vlog.Errorf("TempDir(%v, %v) failed: %v", parent, prefix, err)
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
nameFile := filepath.Join(tmpDir, "name")
if err := ioutil.WriteFile(nameFile, []byte(i.suffix), os.FileMode(0600)); err != nil {
vlog.Errorf("WriteFile(%q) failed: %v", nameFile)
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
infoFile := filepath.Join(tmpDir, "mediainfo")
jInfo, err := json.Marshal(mediaInfo)
if err != nil {
vlog.Errorf("json.Marshal(%v) failed: %v", mediaInfo, err)
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
if err := ioutil.WriteFile(infoFile, jInfo, os.FileMode(0600)); err != nil {
vlog.Errorf("WriteFile(%q) failed: %v", infoFile, err)
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
for j := 0; j < int(nparts); j++ {
partPath, partPerm := generatePartPath(tmpDir, j), os.FileMode(0700)
@@ -115,7 +115,7 @@
if err := os.RemoveAll(tmpDir); err != nil {
vlog.Errorf("RemoveAll(%v) failed: %v", tmpDir, err)
}
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
}
// Use os.Rename() to atomically create the binary directory
@@ -127,10 +127,10 @@
}
}()
if linkErr, ok := err.(*os.LinkError); ok && linkErr.Err == syscall.ENOTEMPTY {
- return verror.Make(verror.Exist, context, i.path)
+ return verror.Make(verror.Exist, context.Context(), i.path)
}
vlog.Errorf("Rename(%v, %v) failed: %v", tmpDir, i.path, err)
- return verror.Make(errOperationFailed, context, i.path)
+ return verror.Make(errOperationFailed, context.Context(), i.path)
}
return nil
}
@@ -139,21 +139,21 @@
vlog.Infof("%v.Delete()", i.suffix)
if _, err := os.Stat(i.path); err != nil {
if os.IsNotExist(err) {
- return verror.Make(verror.NoExist, context, i.path)
+ return verror.Make(verror.NoExist, context.Context(), i.path)
}
vlog.Errorf("Stat(%v) failed: %v", i.path, err)
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
// Use os.Rename() to atomically remove the binary directory
// structure.
path := filepath.Join(filepath.Dir(i.path), "removing-"+filepath.Base(i.path))
if err := os.Rename(i.path, path); err != nil {
vlog.Errorf("Rename(%v, %v) failed: %v", i.path, path, err)
- return verror.Make(errOperationFailed, context, i.path)
+ return verror.Make(errOperationFailed, context.Context(), i.path)
}
if err := os.RemoveAll(path); err != nil {
vlog.Errorf("Remove(%v) failed: %v", path, err)
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
for {
// Remove the binary and all directories on the path back to the
@@ -167,7 +167,7 @@
break
}
vlog.Errorf("Remove(%v) failed: %v", path, err)
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
}
return nil
@@ -183,7 +183,7 @@
file, err := os.Open(dataPath)
if err != nil {
vlog.Errorf("Open(%v) failed: %v", dataPath, err)
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
defer file.Close()
buffer := make([]byte, bufferLength)
@@ -192,14 +192,14 @@
n, err := file.Read(buffer)
if err != nil && err != io.EOF {
vlog.Errorf("Read() failed: %v", err)
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
if n == 0 {
break
}
if err := sender.Send(buffer[:n]); err != nil {
vlog.Errorf("Send() failed: %v", err)
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
}
return nil
@@ -228,7 +228,7 @@
continue
}
vlog.Errorf("ReadFile(%v) failed: %v", checksumFile, err)
- return []binary.PartInfo{}, repository.MediaInfo{}, verror.Make(errOperationFailed, context)
+ return []binary.PartInfo{}, repository.MediaInfo{}, verror.Make(errOperationFailed, context.Context())
}
dataFile := filepath.Join(part, data)
fi, err := os.Stat(dataFile)
@@ -238,7 +238,7 @@
continue
}
vlog.Errorf("Stat(%v) failed: %v", dataFile, err)
- return []binary.PartInfo{}, repository.MediaInfo{}, verror.Make(errOperationFailed, context)
+ return []binary.PartInfo{}, repository.MediaInfo{}, verror.Make(errOperationFailed, context.Context())
}
result = append(result, binary.PartInfo{Checksum: string(bytes), Size: fi.Size()})
}
@@ -246,12 +246,12 @@
jInfo, err := ioutil.ReadFile(infoFile)
if err != nil {
vlog.Errorf("ReadFile(%q) failed: %v", infoFile)
- return []binary.PartInfo{}, repository.MediaInfo{}, verror.Make(errOperationFailed, context)
+ return []binary.PartInfo{}, repository.MediaInfo{}, verror.Make(errOperationFailed, context.Context())
}
var mediaInfo repository.MediaInfo
if err := json.Unmarshal(jInfo, &mediaInfo); err != nil {
vlog.Errorf("json.Unmarshal(%v) failed: %v", jInfo, err)
- return []binary.PartInfo{}, repository.MediaInfo{}, verror.Make(errOperationFailed, context)
+ return []binary.PartInfo{}, repository.MediaInfo{}, verror.Make(errOperationFailed, context.Context())
}
return result, mediaInfo, nil
}
@@ -261,7 +261,7 @@
path, suffix := i.generatePartPath(int(part)), ""
err := checksumExists(path)
if err == nil {
- return verror.Make(verror.Exist, context, path)
+ return verror.Make(verror.Exist, context.Context(), path)
} else if !verror.Is(err, verror.NoExist.ID) {
return err
}
@@ -270,17 +270,17 @@
lockFile, err := os.OpenFile(lockPath, flags, perm)
if err != nil {
if os.IsExist(err) {
- return verror.Make(errInProgress, context, path)
+ return verror.Make(errInProgress, context.Context(), path)
}
vlog.Errorf("OpenFile(%v, %v, %v) failed: %v", lockPath, flags, suffix, err)
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
defer os.Remove(lockFile.Name())
defer lockFile.Close()
file, err := ioutil.TempFile(path, suffix)
if err != nil {
vlog.Errorf("TempFile(%v, %v) failed: %v", path, suffix, err)
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
defer file.Close()
h := md5.New()
@@ -292,7 +292,7 @@
if err := os.Remove(file.Name()); err != nil {
vlog.Errorf("Remove(%v) failed: %v", file.Name(), err)
}
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
h.Write(bytes)
}
@@ -302,7 +302,7 @@
if err := os.Remove(file.Name()); err != nil {
vlog.Errorf("Remove(%v) failed: %v", file.Name(), err)
}
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
hash := hex.EncodeToString(h.Sum(nil))
@@ -312,7 +312,7 @@
if err := os.Remove(file.Name()); err != nil {
vlog.Errorf("Remove(%v) failed: %v", file.Name(), err)
}
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
dataFile := filepath.Join(path, data)
if err := os.Rename(file.Name(), dataFile); err != nil {
@@ -320,7 +320,7 @@
if err := os.Remove(file.Name()); err != nil {
vlog.Errorf("Remove(%v) failed: %v", file.Name(), err)
}
- return verror.Make(errOperationFailed, context)
+ return verror.Make(errOperationFailed, context.Context())
}
return nil
}
@@ -332,7 +332,7 @@
}
n := i.createObjectNameTree().find(elems, false)
if n == nil {
- return nil, verror.Make(errOperationFailed, context)
+ return nil, verror.Make(errOperationFailed, context.Context())
}
ch := make(chan string)
go func() {
diff --git a/services/mgmt/build/impl/service.go b/services/mgmt/build/impl/service.go
index 59bec9f..a0d2aa1 100644
--- a/services/mgmt/build/impl/service.go
+++ b/services/mgmt/build/impl/service.go
@@ -49,7 +49,7 @@
root, err := ioutil.TempDir(dir, prefix)
if err != nil {
vlog.Errorf("TempDir(%v, %v) failed: %v", dir, prefix, err)
- return nil, verror.Make(verror.Internal, ctx)
+ return nil, verror.Make(verror.Internal, ctx.Context())
}
defer os.RemoveAll(root)
if err := os.Chdir(root); err != nil {
@@ -58,7 +58,7 @@
srcDir := filepath.Join(root, "go", "src")
if err := os.MkdirAll(srcDir, dirPerm); err != nil {
vlog.Errorf("MkdirAll(%v, %v) failed: %v", srcDir, dirPerm, err)
- return nil, verror.Make(verror.Internal, ctx)
+ return nil, verror.Make(verror.Internal, ctx.Context())
}
iterator := ctx.RecvStream()
for iterator.Advance() {
@@ -67,16 +67,16 @@
dir := filepath.Dir(filePath)
if err := os.MkdirAll(dir, dirPerm); err != nil {
vlog.Errorf("MkdirAll(%v, %v) failed: %v", dir, dirPerm, err)
- return nil, verror.Make(verror.Internal, ctx)
+ return nil, verror.Make(verror.Internal, ctx.Context())
}
if err := ioutil.WriteFile(filePath, srcFile.Contents, filePerm); err != nil {
vlog.Errorf("WriteFile(%v, %v) failed: %v", filePath, filePerm, err)
- return nil, verror.Make(verror.Internal, ctx)
+ return nil, verror.Make(verror.Internal, ctx.Context())
}
}
if err := iterator.Err(); err != nil {
vlog.Errorf("Advance() failed: %v", err)
- return nil, verror.Make(verror.Internal, ctx)
+ return nil, verror.Make(verror.Internal, ctx.Context())
}
cmd := exec.Command(i.gobin, "install", "-v", "./...")
cmd.Env = append(cmd.Env, "GOARCH="+string(arch))
@@ -93,7 +93,7 @@
if output.Len() != 0 {
vlog.Errorf("%v", output.String())
}
- return output.Bytes(), verror.Make(errBuildFailed, ctx)
+ return output.Bytes(), verror.Make(errBuildFailed, ctx.Context())
}
binDir := filepath.Join(root, "go", "bin")
if runtime.GOARCH != string(arch) || runtime.GOOS != string(opsys) {
@@ -102,14 +102,14 @@
files, err := ioutil.ReadDir(binDir)
if err != nil && !os.IsNotExist(err) {
vlog.Errorf("ReadDir(%v) failed: %v", binDir, err)
- return nil, verror.Make(verror.Internal, ctx)
+ return nil, verror.Make(verror.Internal, ctx.Context())
}
for _, file := range files {
binPath := filepath.Join(binDir, file.Name())
bytes, err := ioutil.ReadFile(binPath)
if err != nil {
vlog.Errorf("ReadFile(%v) failed: %v", binPath, err)
- return nil, verror.Make(verror.Internal, ctx)
+ return nil, verror.Make(verror.Internal, ctx.Context())
}
result := build.File{
Name: "bin/" + file.Name(),
@@ -117,7 +117,7 @@
}
if err := ctx.SendStream().Send(result); err != nil {
vlog.Errorf("Send() failed: %v", err)
- return nil, verror.Make(verror.Internal, ctx)
+ return nil, verror.Make(verror.Internal, ctx.Context())
}
}
return output.Bytes(), nil
diff --git a/services/mgmt/device/impl/app_service.go b/services/mgmt/device/impl/app_service.go
index b07ab26..de712d8 100644
--- a/services/mgmt/device/impl/app_service.go
+++ b/services/mgmt/device/impl/app_service.go
@@ -380,9 +380,9 @@
func (i *appService) Install(call ipc.ServerContext, applicationVON string) (string, error) {
if len(i.suffix) > 0 {
- return "", verror2.Make(ErrInvalidSuffix, call)
+ return "", verror2.Make(ErrInvalidSuffix, call.Context())
}
- ctx, cancel := call.WithTimeout(ipcContextTimeout)
+ ctx, cancel := call.Context().WithTimeout(ipcContextTimeout)
defer cancel()
envelope, err := fetchAppEnvelope(ctx, applicationVON)
if err != nil {
@@ -398,7 +398,7 @@
deferrer()
}
}()
- if _, err := newVersion(call, installationDir, envelope, ""); err != nil {
+ if _, err := newVersion(call.Context(), installationDir, envelope, ""); err != nil {
return "", err
}
if err := saveOrigin(installationDir, applicationVON); err != nil {
@@ -619,30 +619,30 @@
return "", "", err
}
if !installationStateIs(installationDir, active) {
- return "", "", verror2.Make(ErrInvalidOperation, call)
+ return "", "", verror2.Make(ErrInvalidOperation, call.Context())
}
instanceID := generateID()
instanceDir := filepath.Join(installationDir, "instances", instanceDirName(instanceID))
if mkdir(instanceDir) != nil {
- return "", instanceID, verror2.Make(ErrOperationFailed, call)
+ return "", instanceID, verror2.Make(ErrOperationFailed, call.Context())
}
currLink := filepath.Join(installationDir, "current")
versionDir, err := filepath.EvalSymlinks(currLink)
if err != nil {
vlog.Errorf("EvalSymlinks(%v) failed: %v", currLink, err)
- return instanceDir, instanceID, verror2.Make(ErrOperationFailed, call)
+ return instanceDir, instanceID, verror2.Make(ErrOperationFailed, call.Context())
}
versionLink := filepath.Join(instanceDir, "version")
if err := os.Symlink(versionDir, versionLink); err != nil {
vlog.Errorf("Symlink(%v, %v) failed: %v", versionDir, versionLink, err)
- return instanceDir, instanceID, verror2.Make(ErrOperationFailed, call)
+ return instanceDir, instanceID, verror2.Make(ErrOperationFailed, call.Context())
}
if err := installPackages(versionDir, instanceDir); err != nil {
vlog.Errorf("installPackages(%v, %v) failed: %v", versionDir, instanceDir, err)
- return instanceDir, instanceID, verror2.Make(ErrOperationFailed, call)
+ return instanceDir, instanceID, verror2.Make(ErrOperationFailed, call.Context())
}
instanceInfo := new(instanceInfo)
- if err := setupPrincipal(call, instanceDir, versionDir, call, i.securityAgent, instanceInfo); err != nil {
+ if err := setupPrincipal(call.Context(), instanceDir, versionDir, call, i.securityAgent, instanceInfo); err != nil {
return instanceDir, instanceID, err
}
if err := saveInstanceInfo(instanceDir, instanceInfo); err != nil {
@@ -678,7 +678,7 @@
helperStat, err := os.Stat(helperPath)
if err != nil {
vlog.Errorf("Stat(%v) failed: %v. helper is required.", helperPath, err)
- return "", verror2.Make(ErrOperationFailed, ctx)
+ return "", verror2.Make(ErrOperationFailed, ctx.Context())
}
haveHelper := isSetuid(helperStat)
systemName, present := uat.SystemAccountForBlessings(identityNames)
@@ -692,7 +692,7 @@
// app as itself to prevent an app trivially granting itself
// root permissions. There must be an associated uname for the
// account in this case.
- return "", verror2.Make(verror2.NoAccess, ctx, "use of setuid helper requires an associated uname.")
+ return "", verror2.Make(verror2.NoAccess, ctx.Context(), "use of setuid helper requires an associated uname.")
case !haveHelper:
// When the helper is not setuid, the helper can't change the
// app's uid so just run the app as the device manager's uname
@@ -701,11 +701,11 @@
user, err := user.Current()
if err != nil {
vlog.Errorf("user.Current() failed: %v", err)
- return "", verror2.Make(ErrOperationFailed, ctx)
+ return "", verror2.Make(ErrOperationFailed, ctx.Context())
}
return user.Username, nil
}
- return "", verror2.Make(ErrOperationFailed, ctx)
+ return "", verror2.Make(ErrOperationFailed, ctx.Context())
}
func genCmd(instanceDir, helperPath, systemName string, nsRoots []string) (*exec.Cmd, error) {
@@ -887,7 +887,7 @@
// For now, use the namespace roots of the device manager runtime to
// pass to the app.
- if err = i.run(veyron2.RuntimeFromContext(call).Namespace().Roots(), instanceDir, systemName); err != nil {
+ if err = i.run(veyron2.RuntimeFromContext(call.Context()).Namespace().Roots(), instanceDir, systemName); err != nil {
// TODO(caprita): We should call cleanupDir here, but we don't
// in order to not lose the logs for the instance (so we can
// debug why run failed). Clean this up.
@@ -933,9 +933,9 @@
}
if startSystemName != systemName {
- return verror2.Make(verror2.NoAccess, call, "Not allowed to resume an application under a different system name.")
+ return verror2.Make(verror2.NoAccess, call.Context(), "Not allowed to resume an application under a different system name.")
}
- return i.run(veyron2.RuntimeFromContext(call).Namespace().Roots(), instanceDir, systemName)
+ return i.run(veyron2.RuntimeFromContext(call.Context()).Namespace().Roots(), instanceDir, systemName)
}
func stopAppRemotely(ctx context.T, appVON string) error {
@@ -983,7 +983,7 @@
if err := transitionInstance(instanceDir, started, stopping); err != nil {
return err
}
- if err := stop(ctx, instanceDir); err != nil {
+ if err := stop(ctx.Context(), instanceDir); err != nil {
transitionInstance(instanceDir, stopping, started)
return err
}
@@ -998,7 +998,7 @@
if err := transitionInstance(instanceDir, started, suspending); err != nil {
return err
}
- if err := stop(ctx, instanceDir); err != nil {
+ if err := stop(ctx.Context(), instanceDir); err != nil {
transitionInstance(instanceDir, suspending, started)
return err
}
@@ -1019,13 +1019,13 @@
return err
}
if !installationStateIs(installationDir, active) {
- return verror2.Make(ErrInvalidOperation, call)
+ return verror2.Make(ErrInvalidOperation, call.Context())
}
originVON, err := loadOrigin(installationDir)
if err != nil {
return err
}
- ctx, cancel := call.WithTimeout(ipcContextTimeout)
+ ctx, cancel := call.Context().WithTimeout(ipcContextTimeout)
defer cancel()
newEnvelope, err := fetchAppEnvelope(ctx, originVON)
if err != nil {
@@ -1035,7 +1035,7 @@
oldVersionDir, err := filepath.EvalSymlinks(currLink)
if err != nil {
vlog.Errorf("EvalSymlinks(%v) failed: %v", currLink, err)
- return verror2.Make(ErrOperationFailed, call)
+ return verror2.Make(ErrOperationFailed, call.Context())
}
// NOTE(caprita): A race can occur between two competing updates, where
// both use the old version as their baseline. This can result in both
@@ -1050,12 +1050,12 @@
return err
}
if oldEnvelope.Title != newEnvelope.Title {
- return verror2.Make(ErrAppTitleMismatch, call)
+ return verror2.Make(ErrAppTitleMismatch, call.Context())
}
if reflect.DeepEqual(oldEnvelope, newEnvelope) {
- return verror2.Make(ErrUpdateNoOp, call)
+ return verror2.Make(ErrUpdateNoOp, call.Context())
}
- versionDir, err := newVersion(call, installationDir, newEnvelope, oldVersionDir)
+ versionDir, err := newVersion(call.Context(), installationDir, newEnvelope, oldVersionDir)
if err != nil {
cleanupDir(versionDir, "")
return err
@@ -1074,7 +1074,7 @@
return err
}
if !installationStateIs(installationDir, active) {
- return verror2.Make(ErrInvalidOperation, ctx)
+ return verror2.Make(ErrInvalidOperation, ctx.Context())
}
// NOTE(caprita): A race can occur between an update and a revert, where
// both use the same current version as their starting point. This will
@@ -1085,21 +1085,21 @@
currVersionDir, err := filepath.EvalSymlinks(currLink)
if err != nil {
vlog.Errorf("EvalSymlinks(%v) failed: %v", currLink, err)
- return verror2.Make(ErrOperationFailed, ctx)
+ return verror2.Make(ErrOperationFailed, ctx.Context())
}
previousLink := filepath.Join(currVersionDir, "previous")
if _, err := os.Lstat(previousLink); err != nil {
if os.IsNotExist(err) {
// No 'previous' link -- must be the first version.
- return verror2.Make(ErrUpdateNoOp, ctx)
+ return verror2.Make(ErrUpdateNoOp, ctx.Context())
}
vlog.Errorf("Lstat(%v) failed: %v", previousLink, err)
- return verror2.Make(ErrOperationFailed, ctx)
+ return verror2.Make(ErrOperationFailed, ctx.Context())
}
prevVersionDir, err := filepath.EvalSymlinks(previousLink)
if err != nil {
vlog.Errorf("EvalSymlinks(%v) failed: %v", previousLink, err)
- return verror2.Make(ErrOperationFailed, ctx)
+ return verror2.Make(ErrOperationFailed, ctx.Context())
}
return updateLink(prevVersionDir, currLink)
}
diff --git a/services/mgmt/device/impl/device_service.go b/services/mgmt/device/impl/device_service.go
index 332699d..f8883b3 100644
--- a/services/mgmt/device/impl/device_service.go
+++ b/services/mgmt/device/impl/device_service.go
@@ -368,7 +368,7 @@
}
func (*deviceService) Install(ctx ipc.ServerContext, _ string) (string, error) {
- return "", verror2.Make(ErrInvalidSuffix, ctx)
+ return "", verror2.Make(ErrInvalidSuffix, ctx.Context())
}
func (*deviceService) Refresh(ipc.ServerContext) error {
@@ -382,18 +382,18 @@
}
func (*deviceService) Resume(ctx ipc.ServerContext) error {
- return verror2.Make(ErrInvalidSuffix, ctx)
+ return verror2.Make(ErrInvalidSuffix, ctx.Context())
}
func (i *deviceService) Revert(call ipc.ServerContext) error {
if i.config.Previous == "" {
- return verror2.Make(ErrUpdateNoOp, call)
+ return verror2.Make(ErrUpdateNoOp, call.Context())
}
updatingState := i.updating
if updatingState.testAndSetUpdating() {
- return verror2.Make(ErrOperationInProgress, call)
+ return verror2.Make(ErrOperationInProgress, call.Context())
}
- err := i.revertDeviceManager(call)
+ err := i.revertDeviceManager(call.Context())
if err != nil {
updatingState.unsetUpdating()
}
@@ -401,11 +401,11 @@
}
func (*deviceService) Start(ctx ipc.ServerContext) ([]string, error) {
- return nil, verror2.Make(ErrInvalidSuffix, ctx)
+ return nil, verror2.Make(ErrInvalidSuffix, ctx.Context())
}
func (*deviceService) Stop(ctx ipc.ServerContext, _ uint32) error {
- return verror2.Make(ErrInvalidSuffix, ctx)
+ return verror2.Make(ErrInvalidSuffix, ctx.Context())
}
func (*deviceService) Suspend(ipc.ServerContext) error {
@@ -414,16 +414,16 @@
}
func (*deviceService) Uninstall(ctx ipc.ServerContext) error {
- return verror2.Make(ErrInvalidSuffix, ctx)
+ return verror2.Make(ErrInvalidSuffix, ctx.Context())
}
func (i *deviceService) Update(call ipc.ServerContext) error {
- ctx, cancel := call.WithTimeout(ipcContextTimeout)
+ ctx, cancel := call.Context().WithTimeout(ipcContextTimeout)
defer cancel()
updatingState := i.updating
if updatingState.testAndSetUpdating() {
- return verror2.Make(ErrOperationInProgress, call)
+ return verror2.Make(ErrOperationInProgress, call.Context())
}
err := i.updateDeviceManager(ctx)
@@ -452,7 +452,7 @@
return err
case local == false:
vlog.Errorf("SameMachine() indicates that endpoint is not on the same device")
- return verror2.Make(ErrOperationFailed, ctx)
+ return verror2.Make(ErrOperationFailed, ctx.Context())
}
return nil
}
diff --git a/services/mgmt/device/impl/dispatcher.go b/services/mgmt/device/impl/dispatcher.go
index 59bad06..179b51c 100644
--- a/services/mgmt/device/impl/dispatcher.go
+++ b/services/mgmt/device/impl/dispatcher.go
@@ -162,12 +162,12 @@
// Get the blessings to be used by the claimant.
blessings := ctx.Blessings()
if blessings == nil {
- return verror.Make(ErrInvalidBlessing, ctx)
+ return verror.Make(ErrInvalidBlessing, ctx.Context())
}
principal := ctx.LocalPrincipal()
if err := principal.AddToRoots(blessings); err != nil {
vlog.Errorf("principal.AddToRoots(%s) failed: %v", blessings, err)
- return verror.Make(ErrInvalidBlessing, ctx)
+ return verror.Make(ErrInvalidBlessing, ctx.Context())
}
names := blessings.ForContext(ctx)
if len(names) == 0 {
diff --git a/services/mgmt/device/impl/mock_repo_test.go b/services/mgmt/device/impl/mock_repo_test.go
index 58438b0..7d78923 100644
--- a/services/mgmt/device/impl/mock_repo_test.go
+++ b/services/mgmt/device/impl/mock_repo_test.go
@@ -105,7 +105,7 @@
file, err := os.Open(os.Args[0])
if err != nil {
vlog.Errorf("Open() failed: %v", err)
- return verror2.Make(ErrOperationFailed, ctx)
+ return verror2.Make(ErrOperationFailed, ctx.Context())
}
defer file.Close()
bufferLength := 4096
@@ -119,11 +119,11 @@
case nil:
if err := sender.Send(buffer[:n]); err != nil {
vlog.Errorf("Send() failed: %v", err)
- return verror2.Make(ErrOperationFailed, ctx)
+ return verror2.Make(ErrOperationFailed, ctx.Context())
}
default:
vlog.Errorf("Read() failed: %v", err)
- return verror2.Make(ErrOperationFailed, ctx)
+ return verror2.Make(ErrOperationFailed, ctx.Context())
}
}
}
@@ -138,7 +138,7 @@
h := md5.New()
bytes, err := ioutil.ReadFile(os.Args[0])
if err != nil {
- return []binary.PartInfo{}, repository.MediaInfo{}, verror2.Make(ErrOperationFailed, ctx)
+ return []binary.PartInfo{}, repository.MediaInfo{}, verror2.Make(ErrOperationFailed, ctx.Context())
}
h.Write(bytes)
part := binary.PartInfo{Checksum: hex.EncodeToString(h.Sum(nil)), Size: int64(len(bytes))}
diff --git a/services/mgmt/device/impl/proxy_invoker.go b/services/mgmt/device/impl/proxy_invoker.go
index 6ee62ae..b3f52f0 100644
--- a/services/mgmt/device/impl/proxy_invoker.go
+++ b/services/mgmt/device/impl/proxy_invoker.go
@@ -47,8 +47,8 @@
for i, ap := range argptrs {
args[i] = ap
}
- runtime := veyron2.RuntimeFromContext(inCall)
- outCall, err := runtime.Client().StartCall(inCall, p.remote, method, args)
+ runtime := veyron2.RuntimeFromContext(inCall.Context())
+ outCall, err := runtime.Client().StartCall(inCall.Context(), p.remote, method, args)
if err != nil {
return nil, err
}
diff --git a/services/mgmt/logreader/impl/logfile.go b/services/mgmt/logreader/impl/logfile.go
index a79df13..0a6aba0 100644
--- a/services/mgmt/logreader/impl/logfile.go
+++ b/services/mgmt/logreader/impl/logfile.go
@@ -63,13 +63,13 @@
fi, err := os.Stat(fname)
if err != nil {
if os.IsNotExist(err) {
- return 0, verror.Make(verror.NoExist, ctx, fname)
+ return 0, verror.Make(verror.NoExist, ctx.Context(), fname)
}
vlog.Errorf("Stat(%v) failed: %v", fname, err)
- return 0, verror.Make(errOperationFailed, ctx, fname)
+ return 0, verror.Make(errOperationFailed, ctx.Context(), fname)
}
if fi.IsDir() {
- return 0, verror.Make(errOperationFailed, ctx, fname)
+ return 0, verror.Make(errOperationFailed, ctx.Context(), fname)
}
return fi.Size(), nil
}
@@ -84,9 +84,9 @@
f, err := os.Open(fname)
if err != nil {
if os.IsNotExist(err) {
- return 0, verror.Make(verror.NoExist, ctx, fname)
+ return 0, verror.Make(verror.NoExist, ctx.Context(), fname)
}
- return 0, verror.Make(errOperationFailed, ctx, fname)
+ return 0, verror.Make(errOperationFailed, ctx.Context(), fname)
}
reader := newFollowReader(ctx, f, startpos, follow)
if numEntries == types.AllEntries {
@@ -98,10 +98,10 @@
return reader.tell(), nil
}
if err == io.EOF {
- return reader.tell(), verror.Make(errEOF, ctx)
+ return reader.tell(), verror.Make(errEOF, ctx.Context())
}
if err != nil {
- return reader.tell(), verror.Make(errOperationFailed, ctx, fname)
+ return reader.tell(), verror.Make(errOperationFailed, ctx.Context(), fname)
}
if err := ctx.SendStream().Send(types.LogEntry{Position: offset, Line: line}); err != nil {
return reader.tell(), err
@@ -121,9 +121,9 @@
stat, err := os.Stat(dirName)
if err != nil {
if os.IsNotExist(err) {
- return nil, verror.Make(verror.NoExist, ctx, dirName)
+ return nil, verror.Make(verror.NoExist, ctx.Context(), dirName)
}
- return nil, verror.Make(errOperationFailed, ctx, dirName)
+ return nil, verror.Make(errOperationFailed, ctx.Context(), dirName)
}
if !stat.IsDir() {
return nil, nil
diff --git a/services/mgmt/logreader/impl/reader.go b/services/mgmt/logreader/impl/reader.go
index 301a9c4..03bd80d 100644
--- a/services/mgmt/logreader/impl/reader.go
+++ b/services/mgmt/logreader/impl/reader.go
@@ -46,7 +46,7 @@
for {
if f.ctx != nil {
select {
- case <-f.ctx.Done():
+ case <-f.ctx.Context().Done():
return 0, verror.Make(verror.Cancelled, nil)
default:
}
diff --git a/services/mgmt/pprof/impl/server.go b/services/mgmt/pprof/impl/server.go
index fd05f30..0d70ed3 100644
--- a/services/mgmt/pprof/impl/server.go
+++ b/services/mgmt/pprof/impl/server.go
@@ -51,10 +51,10 @@
func (pprofService) Profile(ctx spprof.PProfProfileContext, name string, debug int32) error {
profile := pprof.Lookup(name)
if profile == nil {
- return verror.Make(errNoProfile, ctx, name)
+ return verror.Make(errNoProfile, ctx.Context(), name)
}
if err := profile.WriteTo(&streamWriter{ctx.SendStream()}, int(debug)); err != nil {
- return verror.Convert(verror.Unknown, ctx, err)
+ return verror.Convert(verror.Unknown, ctx.Context(), err)
}
return nil
}
@@ -63,10 +63,10 @@
// streams the profile data.
func (pprofService) CPUProfile(ctx spprof.PProfCPUProfileContext, seconds int32) error {
if seconds <= 0 || seconds > 3600 {
- return verror.Make(errInvalidSeconds, ctx, seconds)
+ return verror.Make(errInvalidSeconds, ctx.Context(), seconds)
}
if err := pprof.StartCPUProfile(&streamWriter{ctx.SendStream()}); err != nil {
- return verror.Convert(verror.Unknown, ctx, err)
+ return verror.Convert(verror.Unknown, ctx.Context(), err)
}
time.Sleep(time.Duration(seconds) * time.Second)
pprof.StopCPUProfile()
diff --git a/services/mgmt/stats/impl/stats.go b/services/mgmt/stats/impl/stats.go
index be098d5..e530cf0 100644
--- a/services/mgmt/stats/impl/stats.go
+++ b/services/mgmt/stats/impl/stats.go
@@ -77,9 +77,9 @@
}
if err := it.Err(); err != nil {
if err == libstats.ErrNotFound {
- return verror.Make(verror.NoExist, ctx, i.suffix)
+ return verror.Make(verror.NoExist, ctx.Context(), i.suffix)
}
- return verror.Make(errOperationFailed, ctx, i.suffix)
+ return verror.Make(errOperationFailed, ctx.Context(), i.suffix)
}
for _, change := range changes {
if err := ctx.SendStream().Send(change); err != nil {
@@ -87,7 +87,7 @@
}
}
select {
- case <-ctx.Done():
+ case <-ctx.Context().Done():
break Loop
case <-time.After(i.watchFreq):
}
@@ -102,12 +102,12 @@
v, err := libstats.Value(i.suffix)
switch err {
case libstats.ErrNotFound:
- return nil, verror.Make(verror.NoExist, ctx, i.suffix)
+ return nil, verror.Make(verror.NoExist, ctx.Context(), i.suffix)
case libstats.ErrNoValue:
- return nil, verror.Make(errNoValue, ctx, i.suffix)
+ return nil, verror.Make(errNoValue, ctx.Context(), i.suffix)
case nil:
return v, nil
default:
- return nil, verror.Make(errOperationFailed, ctx, i.suffix)
+ return nil, verror.Make(errOperationFailed, ctx.Context(), i.suffix)
}
}
diff --git a/services/mgmt/vtrace/impl/vtrace.go b/services/mgmt/vtrace/impl/vtrace.go
index d389436..b4adeb5 100644
--- a/services/mgmt/vtrace/impl/vtrace.go
+++ b/services/mgmt/vtrace/impl/vtrace.go
@@ -15,7 +15,7 @@
func (v *vtraceService) Trace(ctx ipc.ServerContext, id uniqueid.ID) (vtrace.TraceRecord, error) {
tr := v.store.TraceRecord(id)
if tr == nil {
- return vtrace.TraceRecord{}, verror2.Make(verror2.NoExist, ctx, "No trace with id %x", id)
+ return vtrace.TraceRecord{}, verror2.Make(verror2.NoExist, ctx.Context(), "No trace with id %x", id)
}
return *tr, nil
}
diff --git a/services/mounttable/lib/collectionserver_test.go b/services/mounttable/lib/collectionserver_test.go
index 3bb1fb2..2d94dfc 100644
--- a/services/mounttable/lib/collectionserver_test.go
+++ b/services/mounttable/lib/collectionserver_test.go
@@ -47,7 +47,7 @@
c.contents[c.name] = val
return nil
}
- return verror.Make(naming.ErrNameExists, ctx, c.name)
+ return verror.Make(naming.ErrNameExists, ctx.Context(), c.name)
}
// Lookup implements CollectionServerMethods.Lookup.
@@ -57,5 +57,5 @@
if val := c.contents[c.name]; val != nil {
return val, nil
}
- return nil, verror.Make(naming.ErrNoSuchName, ctx, c.name)
+ return nil, verror.Make(naming.ErrNoSuchName, ctx.Context(), c.name)
}
diff --git a/services/mounttable/lib/mounttable.go b/services/mounttable/lib/mounttable.go
index 4d63067..0af6aef 100644
--- a/services/mounttable/lib/mounttable.go
+++ b/services/mounttable/lib/mounttable.go
@@ -218,9 +218,9 @@
n, elems := mt.walk(mt.root, ms.elems)
if n == nil {
if len(ms.elems) == 0 {
- return nil, ms.name, verror.Make(naming.ErrNoSuchNameRoot, context, ms.name)
+ return nil, ms.name, verror.Make(naming.ErrNoSuchNameRoot, context.Context(), ms.name)
}
- return nil, ms.name, verror.Make(naming.ErrNoSuchName, context, ms.name)
+ return nil, ms.name, verror.Make(naming.ErrNoSuchName, context.Context(), ms.name)
}
return n.mount.servers.copyToSlice(), strings.Join(elems, "/"), nil
}
@@ -240,9 +240,9 @@
if n == nil {
entry.Name = ms.name
if len(ms.elems) == 0 {
- err = verror.Make(naming.ErrNoSuchNameRoot, context, ms.name)
+ err = verror.Make(naming.ErrNoSuchNameRoot, context.Context(), ms.name)
} else {
- err = verror.Make(naming.ErrNoSuchName, context, ms.name)
+ err = verror.Make(naming.ErrNoSuchName, context.Context(), ms.name)
}
return
}
@@ -270,7 +270,7 @@
// Make sure the server name is reasonable.
epString, _ := naming.SplitAddressName(server)
- runtime := veyron2.RuntimeFromContext(context)
+ runtime := veyron2.RuntimeFromContext(context.Context())
_, err := runtime.NewEndpoint(epString)
if err != nil {
return fmt.Errorf("malformed address %q for mounted server %q", epString, server)
@@ -281,7 +281,7 @@
defer mt.Unlock()
n := mt.findNode(ms.cleanedElems, true)
if n == nil {
- return verror.Make(naming.ErrNoSuchNameRoot, context, ms.name)
+ return verror.Make(naming.ErrNoSuchNameRoot, context.Context(), ms.name)
}
if hasReplaceFlag(flags) {
n.mount = nil
diff --git a/services/mounttable/lib/neighborhood.go b/services/mounttable/lib/neighborhood.go
index e307143..6479e72 100644
--- a/services/mounttable/lib/neighborhood.go
+++ b/services/mounttable/lib/neighborhood.go
@@ -211,13 +211,13 @@
vlog.VI(2).Infof("ResolveStep %v\n", ns.elems)
if len(ns.elems) == 0 {
//nothing can be mounted at the root
- return nil, "", verror.Make(naming.ErrNoSuchNameRoot, ctx, ns.elems)
+ return nil, "", verror.Make(naming.ErrNoSuchNameRoot, ctx.Context(), ns.elems)
}
// We can only resolve the first element and it always refers to a mount table (for now).
neighbor := nh.neighbor(ns.elems[0])
if neighbor == nil {
- return nil, "", verror.Make(naming.ErrNoSuchName, ctx, ns.elems)
+ return nil, "", verror.Make(naming.ErrNoSuchName, ctx.Context(), ns.elems)
}
return neighbor, naming.Join(ns.elems[1:]...), nil
}
@@ -228,14 +228,14 @@
vlog.VI(2).Infof("ResolveStep %v\n", ns.elems)
if len(ns.elems) == 0 {
//nothing can be mounted at the root
- err = verror.Make(naming.ErrNoSuchNameRoot, ctx, ns.elems)
+ err = verror.Make(naming.ErrNoSuchNameRoot, ctx.Context(), ns.elems)
return
}
// We can only resolve the first element and it always refers to a mount table (for now).
neighbor := nh.neighbor(ns.elems[0])
if neighbor == nil {
- err = verror.Make(naming.ErrNoSuchName, ctx, ns.elems)
+ err = verror.Make(naming.ErrNoSuchName, ctx.Context(), ns.elems)
entry.Name = ns.name
return
}
@@ -281,13 +281,13 @@
case 1:
neighbor := nh.neighbor(ns.elems[0])
if neighbor == nil {
- return nil, verror.Make(naming.ErrNoSuchName, ctx, ns.elems[0])
+ return nil, verror.Make(naming.ErrNoSuchName, ctx.Context(), ns.elems[0])
}
ch := make(chan naming.VDLMountEntry, 1)
ch <- naming.VDLMountEntry{Name: "", Servers: neighbor, MT: true}
close(ch)
return ch, nil
default:
- return nil, verror.Make(naming.ErrNoSuchName, ctx, ns.elems)
+ return nil, verror.Make(naming.ErrNoSuchName, ctx.Context(), ns.elems)
}
}
diff --git a/tools/build/impl_test.go b/tools/build/impl_test.go
index 094a0c3..7b4958f 100644
--- a/tools/build/impl_test.go
+++ b/tools/build/impl_test.go
@@ -26,7 +26,7 @@
}
if err := iterator.Err(); err != nil {
vlog.Errorf("Advance() failed: %v", err)
- return nil, verror.Make(verror.Internal, ctx)
+ return nil, verror.Make(verror.Internal, ctx.Context())
}
return nil, nil
}