Skip to content

Commit

Permalink
fixed mount paths
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabh-prakash committed Feb 23, 2022
1 parent d793120 commit 8626b13
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NUCLEUS_DOCKER_FILE ?= ./build/nucleus/Dockerfile
NUCLEUS_IMAGE_NAME ?= nucleus
NUCLEUS_IMAGE_NAME ?= lambdatest/nucleus:latest

SYNAPSE_DOCKER_FILE ?= ./build/synapse/Dockerfile
SYNAPSE_IMAGE_NAME ?= lambdatest/synapse:latest
Expand Down
8 changes: 4 additions & 4 deletions pkg/core/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,14 @@ func (pl *Pipeline) Start(ctx context.Context) (err error) {
err = pl.TestBlockListService.GetBlockListedTests(ctx, tasConfig, payload.RepoID)
if err != nil {
pl.Logger.Errorf("Unable to fetch blocklisted tests: %v", err)
errRemark = errs.GenericUserFacingBEErrRemark
errRemark = errs.GenericErrRemark
return err
}

// TODO: download from cdn
if err = pl.CacheStore.Download(ctx, cacheKey); err != nil {
pl.Logger.Errorf("Unable to download cache: %v", err)
errRemark = errs.GenericUserFacingBEErrRemark
errRemark = errs.GenericErrRemark
return err
}

Expand All @@ -234,7 +234,7 @@ func (pl *Pipeline) Start(ctx context.Context) (err error) {
err = pl.ExecutionManager.ExecuteInternalCommands(ctx, InstallRunners, global.InstallRunnerCmd, global.RepoDir, nil, nil)
if err != nil {
pl.Logger.Errorf("Unable to install custom runners %v", err)
errRemark = errs.GenericUserFacingBEErrRemark
errRemark = errs.GenericErrRemark
return err
}

Expand All @@ -259,7 +259,7 @@ func (pl *Pipeline) Start(ctx context.Context) (err error) {
// Upload cache once for other builds
if err = pl.CacheStore.Upload(ctx, cacheKey, tasConfig.Cache.Paths...); err != nil {
pl.Logger.Errorf("Unable to upload cache: %v", err)
errRemark = errs.GenericUserFacingBEErrRemark
errRemark = errs.GenericErrRemark
return err
}
pl.Logger.Debugf("Cache uploaded successfully")
Expand Down
38 changes: 22 additions & 16 deletions pkg/runner/docker/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package docker

import (
"context"
"fmt"
"io"
"os"

"github.com/LambdaTest/synapse/config"
"github.com/LambdaTest/synapse/pkg/core"
"github.com/LambdaTest/synapse/pkg/synapse"
"github.com/LambdaTest/synapse/pkg/utils"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
Expand All @@ -19,7 +21,7 @@ const (
networkName = "test-at-scale"
defaultContainerVolumePath = "/home/nucleus"
defaultVaultPath = "/vault/secrets"
repoSourcePath = "/tmp/synapse/nucleus"
repoSourcePath = "/tmp/synapse/%s/nucleus"
nanoCPUUnit = 1e9
// GB defines number of bytes in 1 GB
GB int64 = 1e+9
Expand Down Expand Up @@ -85,29 +87,33 @@ func (d *docker) PullImage(containerImageConfig *core.ContainerImageConfig) erro
}

func (d *docker) getContainerHostConfiguration(r *core.RunnerOptions) *container.HostConfig {
if err := utils.CreateDirectory(repoSourcePath); err != nil {
d.logger.Errorf("error creating directory: %v", err)
}
specs := getSpces(r.Tier)
/*
https://pkg.go.dev/github.com/docker/docker@v20.10.12+incompatible/api/types/container#Resources
AS per documentation , 1 core = 1e9 NanoCPUs
*/
nanoCPU := int64(specs.CPU * nanoCPUUnit)
d.logger.Infof("Specs %+v", specs)
return &container.HostConfig{
Mounts: []mount.Mount{
{
Type: mount.TypeBind,
Source: repoSourcePath,
Target: defaultContainerVolumePath,
},
{
Type: mount.TypeBind,
Source: r.HostVolumePath,
Target: defaultVaultPath,
},
mounts := []mount.Mount{
{
Type: mount.TypeBind,
Source: r.HostVolumePath,
Target: defaultVaultPath,
},
}
if r.PodType == core.NucleusPod || r.PodType == core.CoveragePod {
repoBuildSourcePath := fmt.Sprintf(repoSourcePath, r.Label[synapse.BuildID])
if err := utils.CreateDirectory(repoBuildSourcePath); err != nil {
d.logger.Errorf("error creating directory: %v", err)
}
mounts = append(mounts, mount.Mount{
Type: mount.TypeBind,
Source: repoBuildSourcePath,
Target: defaultContainerVolumePath,
})
}
return &container.HostConfig{
Mounts: mounts,
AutoRemove: true,
SecurityOpt: []string{"seccomp=unconfined"},
Resources: container.Resources{Memory: specs.RAM * GB, NanoCPUs: nanoCPU},
Expand Down

0 comments on commit 8626b13

Please sign in to comment.