Skip to content

Commit

Permalink
Merge branch 'infra-debug'
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentaTomas committed Sep 19, 2023
2 parents 926921a + 0185e56 commit 62da542
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 58 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"formatting.local": "github.com/e2b-dev/api",
"formatting.gofumpt": true,
"ui.completion.usePlaceholders": true,
"experimentalWorkspaceModule": true
},
"go.lintTool": "golangci-lint",
"go.lintFlags": [
Expand Down
9 changes: 9 additions & 0 deletions DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,22 @@
- parametrize buckets and mount paths
- enable simpler debugging
- Remove supervisord and just use systemd for both nomad and consul
- Enable terraform cache again later (cca 16 blocking seconds saved per GHA run)
- Secure docker building (+container start problem?)
- Install golang to the vm for easier remote debugging
- add otel logs
- add more otel events
- improve no attributes trace (if branch for zero)
- fix vscode setup errors
- make buckets not public

### API
- Add monitoring to the envs routes
- Make the API server stateless by moving the session state to the DB
- Add better error if the env was not found
- Improve request logging


### Envd
- envd jsonrpc parameters could be objects instead of arrays (compatibility advantages)
- Check FC env envd freeze bug (probably OOM)
Expand Down
17 changes: 17 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,16 @@ github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3
github.com/CloudyKit/jet/v6 v6.2.0/go.mod h1:d3ypHeIRNo2+XyqnGA8s+aphtcVpjP5hPwP/Lzo7Ro4=
github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/Joker/jade v1.1.3/go.mod h1:T+2WLyt7VH6Lp0TRxQrUYEs64nRc83wkMQrfeIQKduM=
github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q=
github.com/Shopify/goreferrer v0.0.0-20220729165902-8cddb4f5de06/go.mod h1:7erjKLwalezA0k99cWs5L11HWOAPNjdUZ6RxH1BXbbM=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw=
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
github.com/alexflint/go-filemutex v1.2.0/go.mod h1:mYyQSWvw9Tx2/H2n9qXPb52tTYfE0pZAWcBq5mK025c=
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/apache/arrow/go/v12 v12.0.0/go.mod h1:d+tV/eHZZ7Dz7RPrFKtPK02tpr+c9/PEd/zm8mDS9Vg=
github.com/apache/thrift v0.16.0 h1:qEy6UW60iVOlUy+b9ZR0d5WzUWYGOo4HfopoyBaNmoY=
github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU=
github.com/apparentlymart/go-cidr v1.0.1/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc=
Expand Down Expand Up @@ -458,6 +461,7 @@ github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHq
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
github.com/containerd/containerd v1.6.18/go.mod h1:1RdCUu95+gc2v9t3IL+zIlpClSmew7/0YS8O5eQZrOw=
github.com/containerd/go-cni v1.1.9/go.mod h1:XYrZJ1d5W6E2VOvjffL3IZq0Dz6bsVlERHbekNK90PM=
github.com/containerd/stargz-snapshotter/estargz v0.14.3/go.mod h1:KY//uOCIkSuNAHhJogcZtrNHdKrA99/FCCRjE3HD36o=
github.com/containerd/ttrpc v1.1.0/go.mod h1:XX4ZTnoOId4HklF4edwc4DcqskFZuvXB1Evzy5KFQpQ=
github.com/coreos/go-oidc/v3 v3.1.0/go.mod h1:rEJ/idjfUyfkBit1eI1fvyr+64/g9dcKpAm8MJMesvo=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
Expand All @@ -468,6 +472,8 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeC
github.com/digitalocean/godo v1.10.0/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU=
github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8=
github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/docker/cli v23.0.3+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0=
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE=
github.com/dop251/goja v0.0.0-20230605162241-28ee0ee714f3/go.mod h1:QMWlm50DNe14hD7t24KEqZuUdC9sOTy8W6XbCU1mlw4=
github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
Expand Down Expand Up @@ -499,6 +505,7 @@ github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg
github.com/gomarkdown/markdown v0.0.0-20230716120725-531d2d74bc12/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
github.com/google/flatbuffers v2.0.8+incompatible h1:ivUb1cGomAB101ZM1T0nOiWz9pSrTMoa9+EiY7igmkM=
github.com/google/flatbuffers v2.0.8+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
github.com/google/go-containerregistry v0.14.0/go.mod h1:aiJ2fp/SXvkWgmYHioXnbMdlgB8eXiiYOY55gfN91Wk=
github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8qtYCYyzA+8c/9qtqgA3qsXGYqCPKARAFg=
Expand Down Expand Up @@ -558,6 +565,8 @@ github.com/lestrrat-go/iter v1.0.1/go.mod h1:zIdgO1mRKhn8l9vrZJZz9TUMMFbQbLeTsbq
github.com/lestrrat-go/jwx v1.2.25/go.mod h1:zoNuZymNl5lgdcu6P7K6ie2QRll5HVfF4xwxBBK1NxY=
github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I=
github.com/linode/linodego v0.7.1/go.mod h1:ga11n3ivecUrPCHN0rANxKmfWBJVkOXfLMZinAbj2sY=
github.com/linuxkit/virtsock v0.0.0-20201010232012-f8cee7dfc7a3/go.mod h1:3r6x7q95whyfWQpmGZTu3gk3v2YkMi05HEzl7Tf7YEo=
github.com/lyft/protoc-gen-star/v2 v2.0.1/go.mod h1:RcCdONR2ScXaYnQC5tUzxzlpA3WVYF7/opLeUgcQs/o=
github.com/mailgun/raymond/v2 v2.0.48/go.mod h1:lsgvL50kgt1ylcFJYZiULi5fjPBkkhNfj4KA0W54Z18=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
Expand All @@ -576,6 +585,7 @@ github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo
github.com/networkplumbing/go-nft v0.2.0/go.mod h1:HnnM+tYvlGAsMU7yoYwXEVLLiDW9gdMmb5HoGcwpuQs=
github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2/go.mod h1:TLb2Sg7HQcgGdloNxkrmtgDNR9uVYF3lfdFIN4Ro6Sk=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/open-policy-agent/opa v0.42.2/go.mod h1:MrmoTi/BsKWT58kXlVayBb+rYVeaMwuBm3nYAN3923s=
github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg=
github.com/opencontainers/runtime-spec v1.1.0-rc.3/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/selinux v1.10.1/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI=
Expand All @@ -588,9 +598,11 @@ github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3d
github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y=
github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY=
github.com/protolambda/bls12-381-util v0.0.0-20220416220906-d8552aa452c7/go.mod h1:IToEjHuttnUzwZI5KBSM/LOOW3qLbbrHOEfp3SbECGY=
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03/go.mod h1:gRAiPF5C5Nd0eyyRdqIu9qTiFSoZzpTq727b5B8fkkU=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
github.com/ryanuber/columnize v2.1.2+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/safchain/ethtool v0.2.0/go.mod h1:WkKB1DnNtvsMlDmQ50sgwowDJV/hGbJSOvJoEXs1AJQ=
github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g=
Expand All @@ -613,14 +625,19 @@ github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0o
github.com/urfave/cli/v2 v2.24.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/valyala/fasthttp v1.49.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA=
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
github.com/vbatts/tar-split v0.11.2/go.mod h1:vV3ZuO2yWSVsz+pfFzDG/upWH1JhjOiEaWq6kXyQ3VI=
github.com/vektah/gqlparser/v2 v2.4.5/go.mod h1:flJWIR04IMQPGz+BXLrORkrARBxv/rtyIAFvd/MceW0=
github.com/veraison/go-cose v1.0.0-rc.1/go.mod h1:7ziE85vSq4ScFTg6wyoMXjucIGOf4JkFEZi/an96Ct4=
github.com/vmihailenco/msgpack v3.3.3+incompatible h1:wapg9xDUZDzGCNFlwc5SqI1rvcciqcxEHac4CYj89xI=
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/vmware/govmomi v0.18.0/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
github.com/yashtewari/glob-intersection v0.1.0/go.mod h1:LK7pIC3piUjovexikBbJ26Yml7g8xa5bsjfx2v1fwok=
github.com/yosssi/ace v0.0.5/go.mod h1:ALfIzm2vT7t5ZE7uoIZqF3TQ7SAOyupFZnkrF5id+K0=
github.com/zclconf/go-cty-yaml v1.0.3/go.mod h1:9YLUH4g7lOhVWqUbctnVlZ5KLpg7JAprQNgxSZ1Gyxs=
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
Expand Down
2 changes: 2 additions & 0 deletions packages/api/internal/nomad/env-build.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ job "{{ .JobName }}/{{ .EnvID }}" {
ENVS_PIPELINE_PATH = "/mnt/disks/envs-pipeline"
KERNEL_IMAGE_PATH = "/fc-vm/vmlinux.bin"
FIRECRACKER_BINARY_PATH = "/usr/bin/firecracker"
ENVD_NAME = "envd"
CONTEXT_FILE_NAME = "context.tar.gz"
}

config {
Expand Down
2 changes: 1 addition & 1 deletion packages/cluster-disk-image/main.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ build {
provisioner "shell" {
inline = [
"sudo apt-get update",
"sudo apt-get install -y unzip jq net-tools qemu-utils gcsfuse",
"sudo apt-get install -y unzip jq net-tools qemu-utils gcsfuse make",
]
}

Expand Down
8 changes: 7 additions & 1 deletion packages/env-build-task-driver/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ update-build-driver:
cp /mnt/disks/envs-pipeline/env-build-task-driver /opt/nomad/plugins/env-build-task-driver && \
chmod +x /opt/nomad/plugins/env-build-task-driver && \
pgrep nomad | xargs kill && \
exit'
exit'

run-build-check:
make build
gcloud compute scp ./bin/env-build-task-driver root@$$($(client)):/tmp/build-task-driver
gcloud compute ssh $$($(client)) -- 'sudo -s && \
chmod +x /tmp/build-task-driver'
4 changes: 4 additions & 0 deletions packages/env-build-task-driver/internal/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
kernelImagePath := cfg.Env["KERNEL_IMAGE_PATH"]
firecrackerBinaryPath := cfg.Env["FIRECRACKER_BINARY_PATH"]
envsPipelinePath := cfg.Env["ENVS_PIPELINE_PATH"]
envdName := cfg.Env["ENVD_NAME"]
contextFileName := cfg.Env["CONTEXT_FILE_NAME"]

env := env.Env{
BuildID: taskConfig.BuildID,
Expand All @@ -273,6 +275,8 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
FirecrackerBinaryPath: firecrackerBinaryPath,
ProvisionScript: taskConfig.ProvisionScript,
EnvsPipelinePath: envsPipelinePath,
EnvdName: envdName,
ContextFileName: contextFileName,
}

cancellableContext, cancel := context.WithTimeout(childCtx, envBuildTimeout)
Expand Down
9 changes: 5 additions & 4 deletions packages/env-build-task-driver/internal/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ const (
memfileName = "memfile"

buildDirName = "builds"

envdName = "envd"
)

type Env struct {
Expand Down Expand Up @@ -57,16 +55,19 @@ type Env struct {

// Path to the directory where files for the envs pipeline are stored.
EnvsPipelinePath string

EnvdName string
ContextFileName string
}

// Path to the envd.
func (e *Env) EnvdPath() string {
return filepath.Join(e.EnvsPipelinePath, envdName)
return filepath.Join(e.EnvsPipelinePath, e.EnvdName)
}

// Path to the docker context.
func (e *Env) DockerContextPath() string {
return filepath.Join(e.DockerContextsPath, e.EnvID)
return filepath.Join(e.DockerContextsPath, e.EnvID, e.BuildID, e.ContextFileName)
}

// Docker tag of the docker image for this env.
Expand Down
6 changes: 3 additions & 3 deletions packages/env-build-task-driver/internal/env/rootfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ func (r *Rootfs) buildDockerImage(ctx context.Context, tracer trace.Tracer) erro
},
)

// Handle fuse mount

// TODO: Stream the logs somewhere
_, err = io.Copy(os.Stdout, buildResponse.Body)
if err != nil {
Expand Down Expand Up @@ -148,7 +146,9 @@ func (r *Rootfs) createRootfsFile(ctx context.Context, tracer trace.Tracer) erro
telemetry.ReportEvent(childCtx, "opened envd file")

// Copy envd to the container
err = r.client.CopyToContainer(childCtx, cont.ID, envdRootfsPath, envdFile, types.CopyToContainerOptions{})
err = r.client.CopyToContainer(childCtx, cont.ID, envdRootfsPath, envdFile, types.CopyToContainerOptions{
AllowOverwriteDirWithFile: true,
})
if err != nil {
return fmt.Errorf("error copying envd to container %v", err)
}
Expand Down
28 changes: 19 additions & 9 deletions packages/env-build-task-driver/internal/telemetry/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ func ReportEvent(ctx context.Context, name string, attrs ...attribute.KeyValue)

fmt.Println(name, attrs)

span.AddEvent(name,
trace.WithAttributes(attrs...),
)
if len(attrs) == 0 {
span.AddEvent(name)
} else {
span.AddEvent(name,
trace.WithAttributes(attrs...),
)
}
}

func ReportCriticalError(ctx context.Context, err error) {
Expand All @@ -72,10 +76,16 @@ func ReportError(ctx context.Context, err error, attrs ...attribute.KeyValue) {

fmt.Fprint(os.Stderr, err.Error())

span.RecordError(err,
trace.WithStackTrace(true),
trace.WithAttributes(
attrs...,
),
)
if len(attrs) == 0 {
span.RecordError(err,
trace.WithStackTrace(true),
)
} else {
span.RecordError(err,
trace.WithStackTrace(true),
trace.WithAttributes(
attrs...,
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package internal

import (
"context"
"testing"

"github.com/docker/docker/client"
"go.opentelemetry.io/otel"
Expand All @@ -15,14 +14,14 @@ import (
//go:embed test-provision-env.ubuntu.sh
var provisionEnvScriptFile string

func TestBuildEnv(t *testing.T) {
func TestBuildProcess(envID, buildID string) {
ctx := context.Background()

tracer := otel.Tracer("test")

client, err := client.NewClientWithOpts(client.FromEnv)
if err != nil {
t.Fatal(err)
panic(err)
}

contextsPath := "/mnt/disks/docker-contexts/v1"
Expand All @@ -31,10 +30,12 @@ func TestBuildEnv(t *testing.T) {
kernelImagePath := "/fc-vm/vmlinux.bin"
firecrackerBinaryPath := "/usr/bin/firecracker"
envsPipelinePath := "/mnt/disks/envs-pipeline"
envdName := "envd"
contextFileName := "context.tar.gz"

e := env.Env{
BuildID: "testing-build-id",
EnvID: "testing-env-id",
BuildID: buildID,
EnvID: envID,
EnvsPath: envsPath,
VCpuCount: 1,
MemoryMB: 512,
Expand All @@ -45,33 +46,35 @@ func TestBuildEnv(t *testing.T) {
FirecrackerBinaryPath: firecrackerBinaryPath,
ProvisionScript: provisionEnvScriptFile,
EnvsPipelinePath: envsPipelinePath,
EnvdName: envdName,
ContextFileName: contextFileName,
}

err = e.Initialize(ctx, tracer)
if err != nil {
t.Fatal(err)
panic(err)
}
defer e.Cleanup(ctx, tracer)

rootfs, err := env.NewRootfs(ctx, tracer, &e, client)
if err != nil {
t.Fatal(err)
panic(err)
}

network, err := env.NewFCNetwork(ctx, tracer, &e)
if err != nil {
t.Fatal(err)
panic(err)
}
defer network.Cleanup(ctx, tracer)

snapshot, err := env.NewSnapshot(ctx, tracer, &e, network, rootfs)
if err != nil {
t.Fatal(err)
panic(err)
}
defer snapshot.Cleanup(ctx, tracer)

err = e.MoveSnapshotToEnvDir(ctx, tracer)
if err != nil {
t.Fatal(err)
panic(err)
}
}
Loading

0 comments on commit 62da542

Please sign in to comment.