Skip to content

Commit

Permalink
use folder with index name ; sidecar should not logs to /outputs ; to…
Browse files Browse the repository at this point in the history
…Net should not panic (#471)
  • Loading branch information
nonsense committed Feb 5, 2020
1 parent 12013e6 commit 54feaff
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/daemon/run.go
Expand Up @@ -29,7 +29,7 @@ func (srv *Daemon) runHandler(engine api.Engine) func(w http.ResponseWriter, r *

out, err := engine.DoRun(r.Context(), &req.Composition, tgw)
if err != nil {
tgw.WriteError(fmt.Sprintf("engine build error: %s", err))
tgw.WriteError(fmt.Sprintf("engine run error: %s", err))
return
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/runner/cluster_k8s.go
Expand Up @@ -201,7 +201,7 @@ func (*ClusterK8sRunner) Run(ctx context.Context, input *api.RunInput, ow io.Wri
eg.Go(func() error {
defer func() { <-sem }()

return createPod(ctx, pool, podName, input, runenv, env, k8sConfig.Namespace, g)
return createPod(ctx, pool, podName, input, runenv, env, k8sConfig.Namespace, g, i)
})
}
}
Expand Down Expand Up @@ -388,7 +388,7 @@ func monitorTestplanRunState(ctx context.Context, pool *pool, log *zap.SugaredLo
}
}

func createPod(ctx context.Context, pool *pool, podName string, input *api.RunInput, runenv runtime.RunEnv, env []v1.EnvVar, k8sNamespace string, g api.RunGroup) error {
func createPod(ctx context.Context, pool *pool, podName string, input *api.RunInput, runenv runtime.RunEnv, env []v1.EnvVar, k8sNamespace string, g api.RunGroup, i int) error {
client, err := pool.Acquire(ctx)
if err != nil {
return err
Expand All @@ -400,7 +400,7 @@ func createPod(ctx context.Context, pool *pool, podName string, input *api.RunIn
sharedVolumeName := "s3-shared"

mnt := v1.HostPathVolumeSource{
Path: fmt.Sprintf("/mnt/%s/%s/%s", input.RunID, g.ID, podName),
Path: fmt.Sprintf("/mnt/%s/%s/%d", input.RunID, g.ID, i),
Type: &hostpathtype,
}

Expand Down
9 changes: 9 additions & 0 deletions pkg/sidecar/k8s_instance.go
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/vishvananda/netlink"
"github.com/vishvananda/netns"

"github.com/ipfs/testground/pkg/conv"
"github.com/ipfs/testground/pkg/dockermanager"
"github.com/ipfs/testground/pkg/logging"
"github.com/ipfs/testground/sdk/runtime"
Expand Down Expand Up @@ -97,6 +98,14 @@ func (d *K8sInstanceManager) manageContainer(ctx context.Context, container *doc
return nil, fmt.Errorf("not running")
}

// Remove TEST_OUTPUTS_PATH env var.
m, err := conv.ParseKeyValues(info.Config.Env)
if err != nil {
return nil, err
}
delete(m, runtime.EnvTestOutputsPath)
info.Config.Env = conv.ToOptionsSlice(m)

// Construct the runtime environment
runenv, err := runtime.ParseRunEnv(info.Config.Env)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion sdk/runtime/runenv.go
Expand Up @@ -171,8 +171,12 @@ func toBool(s string) bool {
return v
}

// toNet might parse any input, so it is possible to get an error and nil return value
func toNet(s string) *IPNet {
_, ipnet, _ := net.ParseCIDR(s)
_, ipnet, err := net.ParseCIDR(s)
if err != nil {
return nil
}
return &IPNet{IPNet: *ipnet}
}

Expand Down

0 comments on commit 54feaff

Please sign in to comment.