Skip to content

Commit

Permalink
Fixing the docker return character issues (by moving from native vers…
Browse files Browse the repository at this point in the history
…ion to the command line based command runner)
  • Loading branch information
kellrott committed Oct 16, 2016
1 parent 516cbc2 commit 9c74482
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 223 deletions.
4 changes: 2 additions & 2 deletions src/tes-server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package main
import (
"flag"
"fmt"
"tes/server"
"tes/ga4gh"
"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"golang.org/x/net/context"
Expand All @@ -14,6 +12,8 @@ import (
"os"
"path/filepath"
"runtime/debug"
"tes/ga4gh"
"tes/server"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions src/tes-worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package main

import (
"flag"
"tes/worker"
"tes/server/proto"
uuid "github.com/nu7hatch/gouuid"
"google.golang.org/grpc"
"log"
"os"
"path/filepath"
"tes/server/proto"
"tes/worker"
"time"
)

Expand Down
4 changes: 2 additions & 2 deletions src/tes/server/task_boltdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package tes_server

import (
"fmt"
"tes/server/proto"
"tes/ga4gh"
"github.com/boltdb/bolt"
proto "github.com/golang/protobuf/proto"
uuid "github.com/nu7hatch/gouuid"
"golang.org/x/net/context"
"log"
"strings"
"tes/ga4gh"
"tes/server/proto"
)

var TASK_BUCKET = []byte("tasks")
Expand Down
4 changes: 2 additions & 2 deletions src/tes/server/task_server.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package tes_server

import (
"tes/server/proto"
"tes/ga4gh"
"google.golang.org/grpc"
"log"
"net"
"tes/ga4gh"
"tes/server/proto"
)

/// Common GA4GH server, multiple services could be placed into the same server
Expand Down
99 changes: 0 additions & 99 deletions src/tes/worker/container.go

This file was deleted.

108 changes: 0 additions & 108 deletions src/tes/worker/container_engine.go

This file was deleted.

52 changes: 52 additions & 0 deletions src/tes/worker/docker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package tes_taskengine_worker

import (
"log"
"os"
"os/exec"
"strings"
"syscall"
)

func NewDockerEngine() *DockerCmd {
return &DockerCmd{}
}

type DockerCmd struct {
}

func (self DockerCmd) Run(containerName string, args []string,
binds []string, workdir string, remove bool, stdout *os.File, stderr *os.File) (int, error) {

log.Printf("Docker Binds: %s", binds)

docker_args := []string{"run", "--rm", "-i", "-w", workdir}

for _, i := range binds {
docker_args = append(docker_args, "-v", i)
}
docker_args = append(docker_args, containerName)
docker_args = append(docker_args, args...)
log.Printf("Runner docker %s", strings.Join(args, " "))

cmd := exec.Command("docker", docker_args...)

if stdout != nil {
cmd.Stdout = stdout
}
if stderr != nil {
cmd.Stderr = stderr
}
cmd_err := cmd.Run()
exitStatus := 0
if exiterr, ok := cmd_err.(*exec.ExitError); ok {
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
exitStatus = status.ExitStatus()
log.Printf("Exit Status: %d", exitStatus)
}
} else {
log.Printf("cmd.Run: %v", cmd_err)
}

return exitStatus, nil
}
2 changes: 1 addition & 1 deletion src/tes/worker/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package tes_taskengine_worker

import (
"fmt"
"tes/ga4gh"
"os"
"tes/ga4gh"
)

const HEADER_SIZE = int64(102400)
Expand Down
4 changes: 2 additions & 2 deletions src/tes/worker/file_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package tes_taskengine_worker

import (
"fmt"
"tes/server/proto"
"tes/ga4gh"
"golang.org/x/net/context"
"io/ioutil"
"os"
"path"
"tes/ga4gh"
"tes/server/proto"
)

type FileMapper struct {
Expand Down
4 changes: 2 additions & 2 deletions src/tes/worker/fork_engine.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package tes_taskengine_worker

import (
"tes/server/proto"
"tes/ga4gh"
context "golang.org/x/net/context"
"log"
"os"
"sync/atomic"
"tes/ga4gh"
"tes/server/proto"
"time"
//proto "github.com/golang/protobuf/proto"
)
Expand Down
6 changes: 3 additions & 3 deletions tests/common_test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ def setUp(self):
if not os.path.exists("./test_tmp"):
os.mkdir("test_tmp")
self.task_server = None
f, db_path = tempfile.mkstemp(dir="./test_tmp", prefix="ga4hg_task_db.")
f, db_path = tempfile.mkstemp(dir="./test_tmp", prefix="tes_task_db.")
os.close(f)
self.storage_dir = db_path + ".storage"
self.volume_dir = db_path + ".volumes"
os.mkdir(self.storage_dir)
os.mkdir(self.volume_dir)
cmd = ["./bin/ga4gh-taskserver", "-db", db_path]
cmd = ["./bin/tes-server", "-db", db_path]
logging.info("Running %s" % (" ".join(cmd)))
self.task_server = subprocess.Popen(cmd)
time.sleep(3)

self.task_worker = None
cmd = ["./bin/ga4gh-worker", "-volumes", self.volume_dir, "-storage", self.storage_dir]
cmd = ["./bin/tes-worker", "-volumes", self.volume_dir, "-storage", self.storage_dir]
logging.info("Running %s" % (" ".join(cmd)))
self.task_worker = subprocess.Popen(cmd)

Expand Down

0 comments on commit 9c74482

Please sign in to comment.