Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: kurtosis run docker_compose.yaml #1636

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
c5aefe0
add build image to kurtosis backend
tedim52 Oct 26, 2023
bab5041
implement img building in k8s metrics reporting backend
tedim52 Oct 26, 2023
2b12d58
impl img building partially in docker kb
tedim52 Oct 26, 2023
2ebd94d
add img build spec type
tedim52 Oct 26, 2023
20c3215
pass img build spec from interpretation to validation
tedim52 Oct 26, 2023
89c0b3e
Adding a bunch of hackery, and some READMEs to atone for my sins
Oct 26, 2023
fd2f44f
build images during starlark validation
tedim52 Oct 26, 2023
935af4d
add img build spec to kurtosis backend
tedim52 Oct 26, 2023
b6121b8
fix import cycle build err
tedim52 Oct 26, 2023
ec2cecc
use package content provider to get build context
tedim52 Oct 26, 2023
83efed8
Merge branch 'kevin/upload-compose-packages' into tedi/imagebuilding
tedim52 Oct 26, 2023
7094c56
Found #1637 and clarified some things around it
Oct 27, 2023
28a21ef
get the abs path on disk of context dir during interpretation
tedim52 Oct 27, 2023
23156f4
Compose transpilation checkpoint
Oct 27, 2023
21cbf7b
make build img take in dir path instead of build context
tedim52 Oct 27, 2023
99c5d9e
update call to img build in validation
tedim52 Oct 27, 2023
fcc0527
add debug stmts
tedim52 Oct 27, 2023
28786f0
call build img from metrics backend
tedim52 Oct 27, 2023
199dd98
add image name to build image
tedim52 Oct 27, 2023
16cc6d9
update starlark tests
tedim52 Oct 27, 2023
2e6fb78
impl build img in docker manager
tedim52 Oct 27, 2023
0689576
fix bug
tedim52 Oct 27, 2023
a4cac6e
Maybe-working basic transpilation??
Oct 27, 2023
a7941a6
Add env var transpilation
Oct 27, 2023
ad08398
Checkpoint before I do something crazy
Oct 27, 2023
8520a5d
fix img building
tedim52 Oct 27, 2023
691e610
Merge branch 'kevin/upload-compose-packages' into tedi/imagebuilding
tedim52 Oct 27, 2023
b096761
Mayyybe-working remote Compose packages??
Oct 27, 2023
78be519
add target stage
tedim52 Oct 27, 2023
26bc035
Merge branch 'kevin/upload-compose-packages' into tedi/imagebuilding
tedim52 Oct 27, 2023
aaf2cbf
Fix enclave_contxt hack
Oct 27, 2023
986050c
add img build spec tests to compiler
tedim52 Oct 27, 2023
b7b07e3
Merge branch 'kevin/upload-compose-packages' into tedi/imagebuilding
tedim52 Oct 27, 2023
f184a29
transpile image build spec with minor bug
tedim52 Oct 27, 2023
2e9829c
Fixing various bugs with the transpiler
Oct 27, 2023
a0bcf80
comment out build image test
tedim52 Oct 27, 2023
0aa7295
Fix bugs with upload_files Compose transpilation
Oct 27, 2023
7230ce1
Fix failing tests
Oct 27, 2023
933df9c
Merge branch 'kevin/upload-compose-packages' into tedi/imagebuilding
tedim52 Oct 27, 2023
b1a6b80
fix transpiler tests
tedim52 Oct 27, 2023
f1794a6
fix one more transpiler test
tedim52 Oct 27, 2023
655bd9b
Fix swapped relative path & files artifact name
Oct 27, 2023
5389364
Fix failing test
Oct 27, 2023
2479c8e
Fix another failing test
Oct 27, 2023
9574005
Fix several bugs with transpiler
Oct 27, 2023
7f60042
turn on buildkit
tedim52 Oct 27, 2023
c25f572
Add Buildkit sessions to unblock Docker builds
Oct 27, 2023
dfedbb5
Tidy go.mod
Oct 27, 2023
9897da3
We gucci baby
Oct 27, 2023
403963b
Use dockerClientNoTimeout for building images
Oct 27, 2023
7576bfa
Fix counting bug with number of images to validate
Oct 27, 2023
2ef0d2c
Handle depends_on in Docker Compose
Oct 27, 2023
21e7a42
Hacky bugfixes for image-building
Oct 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 51 additions & 9 deletions api/golang/core/lib/enclaves/enclave_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ const (
dotRelativePathIndicatorString = "."
)

// TODO(kevin) Remove this once package ID is detected ONLY the APIC side (i.e. the CLI doesn't need to tell the APIC what package ID it's using)
//
// Doing so requires that we upload completely anonymous packages to the APIC, and it figures things out from there
var supportedDockerComposeYmlFilenames = []string{

"compose.yml",
"compose.yaml",
"docker-compose.yml",
"docker-compose.yaml",
"docker_compose.yml",
"docker_compose.yaml",
}

// Docs available at https://docs.kurtosis.com/sdk/#enclavecontext
type EnclaveContext struct {
client kurtosis_core_rpc_api_bindings.ApiContainerServiceClient
Expand Down Expand Up @@ -142,12 +155,41 @@ func (enclaveCtx *EnclaveContext) RunStarlarkPackage(

starlarkResponseLineChan := make(chan *kurtosis_core_rpc_api_bindings.StarlarkRunResponseLine)

kurtosisYml, err := getKurtosisYaml(packageRootPath)
if err != nil {
return nil, nil, stacktrace.Propagate(err, "An error occurred getting Kurtosis yaml file from path '%s'", packageRootPath)
var packageName string
var packageReplaceOptions map[string]string
if _, err := os.Stat(path.Join(packageRootPath, kurtosisYamlFilename)); err == nil {
// We have a kurtosis.yml, so try to parse it
kurtosisYml, err := getKurtosisYaml(packageRootPath)
if err != nil {
return nil, nil, stacktrace.Propagate(err, "An error occurred getting Kurtosis yaml file from path '%s'", packageRootPath)
}
packageName = kurtosisYml.PackageName
packageReplaceOptions = kurtosisYml.PackageReplaceOptions
} else {
// Check if we have Docker Compose files
composeAbsFilepath := ""
for _, candidateComposeFilename := range supportedDockerComposeYmlFilenames {
candidateComposeAbsFilepath := path.Join(packageRootPath, candidateComposeFilename)
if _, err := os.Stat(candidateComposeAbsFilepath); err == nil {
composeAbsFilepath = candidateComposeAbsFilepath
break
}
}
if composeAbsFilepath == "" {
return nil, nil, stacktrace.NewError(
"Neither a '%s' file nor one of the default Compose files (%s) was found in the package root; at least one of these is required",
kurtosisYamlFilename,
strings.Join(supportedDockerComposeYmlFilenames, ", "),
)
}

// TODO(kevin): This is a hack, to get around the "only Github URLs" validation!
packageName = "github.com/NOTIONAL_USER/USER_UPLOADED_COMPOSE_PACKAGE"
packageReplaceOptions = make(map[string]string)
}

executeStartosisPackageArgs, err := enclaveCtx.assembleRunStartosisPackageArg(kurtosisYml, runConfig.RelativePathToMainFile, runConfig.MainFunctionName, serializedParams, runConfig.DryRun, runConfig.Parallelism, runConfig.ExperimentalFeatureFlags, runConfig.CloudInstanceId, runConfig.CloudUserId)
// TODO(kevin): Remove the package name from the args; we really shouldn't need it!
executeStartosisPackageArgs, err := enclaveCtx.assembleRunStartosisPackageArg(packageName, runConfig.RelativePathToMainFile, runConfig.MainFunctionName, serializedParams, runConfig.DryRun, runConfig.Parallelism, runConfig.ExperimentalFeatureFlags, runConfig.CloudInstanceId, runConfig.CloudUserId)
if err != nil {
return nil, nil, stacktrace.Propagate(err, "Error preparing package '%s' for execution", packageRootPath)
}
Expand All @@ -157,9 +199,9 @@ func (enclaveCtx *EnclaveContext) RunStarlarkPackage(
return nil, nil, stacktrace.Propagate(err, "Error uploading package '%s' prior to executing it", packageRootPath)
}

if len(kurtosisYml.PackageReplaceOptions) > 0 {
if err = enclaveCtx.uploadLocalStarlarkPackageDependencies(packageRootPath, kurtosisYml.PackageReplaceOptions); err != nil {
return nil, nil, stacktrace.Propagate(err, "An error occurred while uploading the local starlark package dependencies from the replace options '%+v'", kurtosisYml.PackageReplaceOptions)
if len(packageReplaceOptions) > 0 {
if err = enclaveCtx.uploadLocalStarlarkPackageDependencies(packageRootPath, packageReplaceOptions); err != nil {
return nil, nil, stacktrace.Propagate(err, "An error occurred while uploading the local starlark package dependencies from the replace options '%+v'", packageReplaceOptions)
}
}

Expand Down Expand Up @@ -522,7 +564,7 @@ func getErrFromStarlarkRunResult(result *StarlarkRunResult) error {
}

func (enclaveCtx *EnclaveContext) assembleRunStartosisPackageArg(
kurtosisYaml *KurtosisYaml,
packageName,
relativePathToMainFile string,
mainFunctionName string,
serializedParams string,
Expand All @@ -533,7 +575,7 @@ func (enclaveCtx *EnclaveContext) assembleRunStartosisPackageArg(
cloudUserId string,
) (*kurtosis_core_rpc_api_bindings.RunStarlarkPackageArgs, error) {

return binding_constructors.NewRunStarlarkPackageArgs(kurtosisYaml.PackageName, relativePathToMainFile, mainFunctionName, serializedParams, dryRun, parallelism, experimentalFeatures, cloudInstanceId, cloudUserId), nil
return binding_constructors.NewRunStarlarkPackageArgs(packageName, relativePathToMainFile, mainFunctionName, serializedParams, dryRun, parallelism, experimentalFeatures, cloudInstanceId, cloudUserId), nil
}

func (enclaveCtx *EnclaveContext) uploadStarlarkPackage(packageId string, packageRootPath string) error {
Expand Down
2 changes: 2 additions & 0 deletions api/typescript/src/core/lib/enclaves/enclave_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ export class EnclaveContext {
return err(new Error(`Unexpected error while getting the Kurtosis yaml file from path '${packageRootPath}'`))
}

// TODO TODO TODO TODO put in Compose stuff here!!!

const kurtosisYaml: KurtosisYaml = kurtosisYmlResult.value
const packageId: string = kurtosisYaml.name
const packageReplaceOptions: Map<string, string> = kurtosisYaml.packageReplaceOptions
Expand Down
22 changes: 16 additions & 6 deletions cli/cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ require (
github.com/kurtosis-tech/vscode-kurtosis/starlark-lsp v0.0.0-20230406131103-c466e04f1b89
github.com/mholt/archiver v3.1.1+incompatible
github.com/xlab/treeprint v1.2.0
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.27.2
Expand All @@ -69,33 +69,38 @@ require (
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/containerd/containerd v1.7.2 // indirect
github.com/containerd/typeurl/v2 v2.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/distribution/distribution/v3 v3.0.0-20230214150026-36d8c594d7aa // indirect
github.com/docker/docker v24.0.5+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/frankban/quicktest v1.14.5 // indirect
github.com/gammazero/deque v0.1.0 // indirect
github.com/gammazero/workerpool v1.1.2 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/gin-gonic/gin v1.9.1 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-playground/validator/v10 v10.14.1 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand All @@ -110,6 +115,7 @@ require (
github.com/mattn/go-shellwords v1.0.12 // indirect
github.com/mholt/archiver/v3 v3.5.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/buildkit v0.12.3 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand All @@ -118,7 +124,7 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nwaples/rardecode v1.1.3 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/opencontainers/image-spec v1.1.0-rc3 // indirect
github.com/pascaldekloe/name v1.0.1 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pierrec/lz4/v4 v4.1.15 // indirect
Expand All @@ -136,11 +142,15 @@ require (
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
go.etcd.io/bbolt v1.3.6 // indirect
go.etcd.io/bbolt v1.3.7 // indirect
go.lsp.dev/jsonrpc2 v0.9.0 // indirect
go.lsp.dev/pkg v0.0.0-20210323044036-f7deec69b52e // indirect
go.lsp.dev/protocol v0.11.2 // indirect
go.lsp.dev/uri v0.3.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.40.0 // indirect
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/metric v0.37.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.20.0 // indirect
Expand All @@ -153,7 +163,7 @@ require (
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.12.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect
Expand Down
Loading