From 5798fad225d622967d126402bbc8942998a4087a Mon Sep 17 00:00:00 2001 From: Ferran Borreguero Date: Sat, 16 Dec 2023 09:26:30 +0000 Subject: [PATCH] Migrate to composer, pull repo --- go.mod | 48 +- go.sum | 178 +-- internal/client/client.go | 172 --- internal/client/collector.go | 77 - internal/client/control_plane.go | 18 - internal/client/metrics_hook.go | 107 -- .../client/runner/allocrunner/alloc_runner.go | 459 ------ .../runner/allocrunner/alloc_runner_hooks.go | 89 -- .../runner/allocrunner/alloc_runner_test.go | 554 ------- .../runner/allocrunner/allocdir/alloc_dir.go | 115 -- .../allocrunner/allocdir/alloc_dir_test.go | 49 - .../client/runner/allocrunner/allocdir/fs.go | 67 - .../client/runner/allocrunner/network_hook.go | 58 - .../allocrunner/taskrunner/artifacts_hook.go | 61 - .../allocrunner/taskrunner/task_dir_hook.go | 160 -- .../taskrunner/task_dir_hook_test.go | 60 - .../allocrunner/taskrunner/task_runner.go | 357 ----- .../taskrunner/task_runner_hooks.go | 143 -- .../taskrunner/task_runner_test.go | 275 ---- .../client/runner/allocrunner/volume_hook.go | 37 - internal/client/runner/docker/coordinator.go | 97 -- .../client/runner/docker/coordinator_test.go | 74 - internal/client/runner/docker/driver.go | 298 ---- internal/client/runner/docker/driver_test.go | 246 --- internal/client/runner/docker/handle.go | 120 -- internal/client/runner/docker/network.go | 95 -- internal/client/runner/docker/network_test.go | 138 -- internal/client/runner/docker/state.go | 33 - internal/client/runner/docker/testing.go | 30 - internal/client/runner/driver/driver.go | 42 - internal/client/runner/hooks/runner_hooks.go | 15 - internal/client/runner/hooks/task_hooks.go | 42 - internal/client/runner/mock/mock.go | 37 - internal/client/runner/runner.go | 285 ---- internal/client/runner/runner_test.go | 103 -- internal/client/runner/state/boltdb.go | 218 --- internal/client/runner/state/state.go | 13 - internal/client/runner/state/testing.go | 24 - internal/client/runner/structs/runner.pb.go | 1330 ----------------- internal/client/runner/structs/runner.proto | 116 -- internal/client/runner/structs/utils.go | 72 - internal/client/sync_hook.go | 90 -- internal/cmd/server.go | 46 +- 43 files changed, 98 insertions(+), 6550 deletions(-) delete mode 100644 internal/client/client.go delete mode 100644 internal/client/collector.go delete mode 100644 internal/client/control_plane.go delete mode 100644 internal/client/metrics_hook.go delete mode 100644 internal/client/runner/allocrunner/alloc_runner.go delete mode 100644 internal/client/runner/allocrunner/alloc_runner_hooks.go delete mode 100644 internal/client/runner/allocrunner/alloc_runner_test.go delete mode 100644 internal/client/runner/allocrunner/allocdir/alloc_dir.go delete mode 100644 internal/client/runner/allocrunner/allocdir/alloc_dir_test.go delete mode 100644 internal/client/runner/allocrunner/allocdir/fs.go delete mode 100644 internal/client/runner/allocrunner/network_hook.go delete mode 100644 internal/client/runner/allocrunner/taskrunner/artifacts_hook.go delete mode 100644 internal/client/runner/allocrunner/taskrunner/task_dir_hook.go delete mode 100644 internal/client/runner/allocrunner/taskrunner/task_dir_hook_test.go delete mode 100644 internal/client/runner/allocrunner/taskrunner/task_runner.go delete mode 100644 internal/client/runner/allocrunner/taskrunner/task_runner_hooks.go delete mode 100644 internal/client/runner/allocrunner/taskrunner/task_runner_test.go delete mode 100644 internal/client/runner/allocrunner/volume_hook.go delete mode 100644 internal/client/runner/docker/coordinator.go delete mode 100644 internal/client/runner/docker/coordinator_test.go delete mode 100644 internal/client/runner/docker/driver.go delete mode 100644 internal/client/runner/docker/driver_test.go delete mode 100644 internal/client/runner/docker/handle.go delete mode 100644 internal/client/runner/docker/network.go delete mode 100644 internal/client/runner/docker/network_test.go delete mode 100644 internal/client/runner/docker/state.go delete mode 100644 internal/client/runner/docker/testing.go delete mode 100644 internal/client/runner/driver/driver.go delete mode 100644 internal/client/runner/hooks/runner_hooks.go delete mode 100644 internal/client/runner/hooks/task_hooks.go delete mode 100644 internal/client/runner/mock/mock.go delete mode 100644 internal/client/runner/runner.go delete mode 100644 internal/client/runner/runner_test.go delete mode 100644 internal/client/runner/state/boltdb.go delete mode 100644 internal/client/runner/state/state.go delete mode 100644 internal/client/runner/state/testing.go delete mode 100644 internal/client/runner/structs/runner.pb.go delete mode 100644 internal/client/runner/structs/runner.proto delete mode 100644 internal/client/runner/structs/utils.go delete mode 100644 internal/client/sync_hook.go diff --git a/go.mod b/go.mod index 4d7636c..ba2148f 100644 --- a/go.mod +++ b/go.mod @@ -1,29 +1,26 @@ module github.com/umbracle/vesta -go 1.18 +go 1.21.3 require ( github.com/boltdb/bolt v1.3.1 - github.com/docker/docker v20.10.17+incompatible - github.com/golang/protobuf v1.5.2 + github.com/docker/docker v24.0.7+incompatible + github.com/ferranbt/composer v0.0.0-20231216092404-e0abeabc0aed + github.com/golang/protobuf v1.5.3 github.com/hashicorp/go-getter v1.7.1 github.com/hashicorp/go-hclog v1.3.0 github.com/hashicorp/go-memdb v1.3.3 github.com/mitchellh/cli v1.1.4 github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db github.com/mitchellh/mapstructure v1.5.0 - github.com/prometheus/client_golang v1.12.1 - github.com/prometheus/client_model v0.2.0 - github.com/prometheus/common v0.37.0 github.com/ryanuber/columnize v2.1.2+incompatible github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.8.1 + github.com/stretchr/testify v1.8.4 github.com/umbracle/babel v0.0.1 go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 - golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 - golang.org/x/sys v0.1.0 + golang.org/x/crypto v0.12.0 google.golang.org/grpc v1.51.0 - google.golang.org/protobuf v1.28.1 + google.golang.org/protobuf v1.31.0 ) require ( @@ -31,24 +28,24 @@ require ( cloud.google.com/go/compute v1.10.0 // indirect cloud.google.com/go/iam v0.5.0 // indirect cloud.google.com/go/storage v1.27.0 // indirect + github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/Masterminds/goutils v1.1.0 // indirect github.com/Masterminds/semver/v3 v3.1.1 // indirect github.com/Masterminds/sprig/v3 v3.2.0 // indirect - github.com/Microsoft/go-winio v0.5.2 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 // indirect github.com/aws/aws-sdk-go v1.44.122 // indirect - github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.0 // indirect - github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/docker/distribution v2.8.1+incompatible // indirect + github.com/distribution/reference v0.5.0 // indirect + github.com/docker/distribution v2.8.3+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect - github.com/docker/go-units v0.4.0 // indirect + github.com/docker/go-units v0.5.0 // indirect github.com/fatih/color v1.13.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/google/uuid v1.3.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect github.com/googleapis/gax-go/v2 v2.6.0 // indirect @@ -64,36 +61,33 @@ require ( github.com/imdario/mergo v0.3.11 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/klauspost/compress v1.15.11 // indirect - github.com/kr/pretty v0.2.0 // indirect + github.com/kr/pretty v0.2.1 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mitchellh/copystructure v1.0.0 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/reflectwalk v1.0.0 // indirect - github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae // indirect - github.com/morikuni/aec v1.0.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.0.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/posener/complete v1.1.1 // indirect - github.com/prometheus/procfs v0.7.3 // indirect github.com/shopspring/decimal v1.2.0 // indirect - github.com/sirupsen/logrus v1.9.0 // indirect github.com/spf13/cast v1.3.1 // indirect github.com/ulikunitz/xz v0.5.10 // indirect go.opencensus.io v0.23.0 // indirect - golang.org/x/net v0.1.0 // indirect + golang.org/x/mod v0.8.0 // indirect + golang.org/x/net v0.14.0 // indirect golang.org/x/oauth2 v0.1.0 // indirect - golang.org/x/term v0.1.0 // indirect - golang.org/x/text v0.4.0 // indirect - golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect + golang.org/x/sys v0.11.0 // indirect + golang.org/x/term v0.11.0 // indirect + golang.org/x/text v0.12.0 // indirect + golang.org/x/tools v0.6.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.100.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - gotest.tools/v3 v3.3.0 // indirect ) diff --git a/go.sum b/go.sum index f57627d..01c5089 100644 --- a/go.sum +++ b/go.sum @@ -189,23 +189,14 @@ github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030I github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/Masterminds/sprig/v3 v3.2.0 h1:P1ekkbuU73Ui/wS0nK1HOM37hh4xdfZo485UPf8rc+Y= github.com/Masterminds/sprig/v3 v3.2.0/go.mod h1:tWhwTbUTndesPNeF0C900vKoq283u6zp4APT9vaF3SI= -github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= -github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 h1:BUAU3CGlLvorLI26FmByPp2eC2qla6E1Tw+scpcg/to= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aws/aws-sdk-go v1.44.122 h1:p6mw01WBaNpbdP2xrisz5tIkcNwzj/HysobNoaAHjgo= github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= @@ -215,8 +206,6 @@ github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx2 github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= @@ -231,18 +220,19 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= -github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v20.10.17+incompatible h1:JYCuMrWaVNophQTOrMMoSwudOVEfcegoZZrleKc1xwE= -github.com/docker/docker v20.10.17+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= +github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= +github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= +github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/docker v24.0.7+incompatible h1:Wo6l37AuwP3JaMnZa226lzVXGA3F9Ig1seQen0cKYlM= +github.com/docker/docker v24.0.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= -github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -256,20 +246,14 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/ferranbt/composer v0.0.0-20231214230844-f72319cfc420 h1:3ymDu0JDAfcPoVncOmf2jvc8mXi6tkIpymSIrtOzRb0= +github.com/ferranbt/composer v0.0.0-20231214230844-f72319cfc420/go.mod h1:BxOCoF2a+ibF5DT1cDvt8BCZGVNg1Dg2l5YjE9TY/SU= +github.com/ferranbt/composer v0.0.0-20231216092404-e0abeabc0aed h1:ytk/WiFuYOw7zfVtixWFqnUcm0n7IP2cHK4cV3oDZ48= +github.com/ferranbt/composer v0.0.0-20231216092404-e0abeabc0aed/go.mod h1:BxOCoF2a+ibF5DT1cDvt8BCZGVNg1Dg2l5YjE9TY/SU= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -303,8 +287,9 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -322,9 +307,9 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -402,28 +387,19 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= @@ -434,8 +410,6 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/cli v1.1.4 h1:qj8czE26AU4PbiaPXK5uVmMSM+V5BYsFBiM9HhGRLUA= github.com/mitchellh/cli v1.1.4/go.mod h1:vTLESy5mRhKOs9KDp0/RATawxP1UqBmdrpVRMnpcvKQ= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= @@ -450,85 +424,41 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae h1:O4SWKdcHVCvYqyDV+9CJA1fcDN2L11Bule0iFy3YlAI= -github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= +github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1 h1:ccV59UEOTzVDnDUEFdT95ZzHVZ+5+158q8+SJb2QV5w= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk= -github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= -github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/ryanuber/columnize v2.1.2+incompatible h1:C89EOx/XBWwIXl8wm8OPJBd7kPF25UfsK2X7Ph/zCAk= github.com/ryanuber/columnize v2.1.2+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= -github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/umbracle/babel v0.0.1 h1:vC5hP+0t+tMaBFi0MnhG6gGHsN5SwHZAwXc8mdRVe8k= @@ -550,7 +480,6 @@ go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 h1:Ss6D3hLXTM0KobyBYEAygXzFfGcjnmfEJOBgSbemCtg= go.starlark.net v0.0.0-20230302034142-4b1e35fe2254/go.mod h1:jxU+3+j+71eXOW14274+SmmuW82qJzl6iZSeqEtTGds= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -558,8 +487,9 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -596,9 +526,10 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -606,7 +537,6 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -633,7 +563,6 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= @@ -645,8 +574,9 @@ golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -687,23 +617,20 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -717,8 +644,6 @@ golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -726,7 +651,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -735,7 +659,6 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -747,7 +670,6 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -762,13 +684,15 @@ golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0 h1:g6Z6vPFA9dYBAF7DWcH6sCcOntplXsDKcliusYijMlw= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -778,13 +702,14 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 h1:ftMN5LMiBFjbzleLqtoBZk7KdJwhuybIU+FckUHgoyQ= -golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.4.0 h1:Z81tqI5ddIoXDPvVQ7/7CC9TnLM7ubaFG2qXYd5BbYY= +golang.org/x/time v0.4.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -796,7 +721,6 @@ golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -840,6 +764,8 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1060,20 +986,17 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= @@ -1081,9 +1004,8 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= -gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo= -gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A= +gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= +gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/internal/client/client.go b/internal/client/client.go deleted file mode 100644 index 81bd32c..0000000 --- a/internal/client/client.go +++ /dev/null @@ -1,172 +0,0 @@ -package client - -import ( - "context" - "fmt" - "net" - - "github.com/boltdb/bolt" - "github.com/hashicorp/go-hclog" - "github.com/hashicorp/go-memdb" - babel "github.com/umbracle/babel/sdk" - "github.com/umbracle/vesta/internal/client/runner" - "github.com/umbracle/vesta/internal/client/runner/hooks" - "github.com/umbracle/vesta/internal/client/runner/state" - cproto "github.com/umbracle/vesta/internal/client/runner/structs" - "github.com/umbracle/vesta/internal/server/proto" -) - -type Config struct { - NodeID string - ControlPlane ControlPlane - Volume *HostVolume - PersistentDB *bolt.DB -} - -type HostVolume struct { - Path string -} - -type Client struct { - logger hclog.Logger - config *Config - closeCh chan struct{} - collector *collector - runner *runner.Runner -} - -func NewClient(logger hclog.Logger, config *Config) (*Client, error) { - c := &Client{ - logger: logger.Named("agent"), - config: config, - closeCh: make(chan struct{}), - collector: newCollector(), - } - - c.logger.Info("agent started") - - rConfig := &runner.Config{ - Logger: logger, - AllocStateUpdated: c, - Volume: (*runner.HostVolume)(config.Volume), - Hooks: []hooks.TaskHookFactory{ - c.collector.hookFactory, - c.syncHookFactory, - }, - } - - if config.PersistentDB != nil { - // create custom state - stateDB, err := state.NewBoltdbStoreWithDB(config.PersistentDB) - if err != nil { - return nil, err - } - rConfig.State = stateDB - } - - r, err := runner.NewRunner(rConfig) - if err != nil { - return nil, err - } - c.runner = r - - go c.handle() - - go c.startCollectorPrometheusServer(&net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 5555}) - - return c, nil -} - -func (c *Client) UpdateSyncState(alloc, task string, status *babel.SyncStatus) { - if err := c.config.ControlPlane.UpdateSyncStatus(alloc, task, status); err != nil { - c.logger.Error("failed to update sync state", "error", err) - } -} - -func (c *Client) syncHookFactory(logger hclog.Logger, alloc *cproto.Allocation, task *cproto.Task) hooks.TaskHook { - return newSyncHook(logger, alloc.Deployment.Name, task, c) -} - -func (c *Client) handle() { - for { - ws := memdb.NewWatchSet() - allocations, err := c.config.ControlPlane.Pull(c.config.NodeID, ws) - if err != nil { - panic(err) - } - for _, alloc := range allocations { - dep2 := &cproto.Deployment{ - Name: alloc.Id, - Tasks: []*cproto.Task{}, - Sequence: alloc.Sequence, - Alias: alloc.Alias, - DesiredStatus: cproto.Deployment_DesiredStatus(alloc.DesiredStatus), - } - for name, tt := range alloc.Tasks { - ttt := &cproto.Task{ - Name: name, - Image: tt.Image, - Tag: tt.Tag, - Args: tt.Args, - Env: tt.Env, - Labels: tt.Labels, - SecurityOpt: tt.SecurityOpt, - Data: tt.Data, - Batch: tt.Batch, - Volumes: map[string]*cproto.Task_Volume{}, - Metadata: map[string]string{}, - Artifacts: []*cproto.Task_Artifact{}, - } - for _, t := range tt.Artifacts { - ttt.Artifacts = append(ttt.Artifacts, &cproto.Task_Artifact{ - Source: t.Source, - Destination: t.Destination, - }) - } - for name, v := range tt.Volumes { - ttt.Volumes[name] = &cproto.Task_Volume{ - Path: v.Path, - } - } - if tt.Telemetry != nil { - ttt.Metadata["telemetry"] = fmt.Sprintf("%d/%s", tt.Telemetry.Port, tt.Telemetry.Path) - } - dep2.Tasks = append(dep2.Tasks, ttt) - } - - c.runner.UpsertDeployment(dep2) - } - - select { - case <-c.closeCh: - return - case <-ws.WatchCh(context.Background()): - } - } -} - -func (c *Client) AllocStateUpdated(a *cproto.Allocation) { - // update back to the client important data - alloc := &proto.Allocation{ - Id: a.Deployment.Name, - Status: proto.Allocation_Status(a.Status), - TaskStates: map[string]*proto.TaskState{}, - } - for name, state := range a.TaskStates { - alloc.TaskStates[name] = &proto.TaskState{ - State: proto.TaskState_State(state.State), - Failed: state.Failed, - Restarts: state.Restarts, - Id: state.Id, - Killing: state.Killing, - } - } - - if err := c.config.ControlPlane.UpdateAlloc(alloc); err != nil { - c.logger.Error("failed to update alloc", "id", alloc.Id, "err", err) - } -} - -func (c *Client) Stop() { - close(c.closeCh) -} diff --git a/internal/client/collector.go b/internal/client/collector.go deleted file mode 100644 index eed4996..0000000 --- a/internal/client/collector.go +++ /dev/null @@ -1,77 +0,0 @@ -package client - -import ( - "errors" - "net" - "net/http" - "sync" - "time" - - "github.com/hashicorp/go-hclog" - "github.com/prometheus/client_golang/prometheus/promhttp" - dto "github.com/prometheus/client_model/go" - "github.com/umbracle/vesta/internal/client/runner/hooks" - proto "github.com/umbracle/vesta/internal/client/runner/structs" -) - -type collector struct { - lock sync.Mutex - metrics map[string][]*dto.MetricFamily -} - -func newCollector() *collector { - return &collector{lock: sync.Mutex{}, metrics: map[string][]*dto.MetricFamily{}} -} - -func (c *collector) hookFactory(logger hclog.Logger, alloc *proto.Allocation, task *proto.Task) hooks.TaskHook { - return newMetricsHook(logger, task, c) -} - -func (c *collector) push(id string, metrics map[string]*dto.MetricFamily) { - c.lock.Lock() - defer c.lock.Unlock() - - res := []*dto.MetricFamily{} - for _, m := range metrics { - res = append(res, m) - } - c.metrics[id] = res -} - -func (c *collector) Gather() ([]*dto.MetricFamily, error) { - c.lock.Lock() - defer c.lock.Unlock() - - res := []*dto.MetricFamily{} - for _, metrics := range c.metrics { - for _, mm := range metrics { - res = append(res, mm) - } - } - return res, nil -} - -func (c *collector) UpdateMetrics(id string, metrics map[string]*dto.MetricFamily) { - c.push(id, metrics) -} - -func (c *Client) startCollectorPrometheusServer(listenAddr *net.TCPAddr) *http.Server { - srv := &http.Server{ - Addr: listenAddr.String(), - Handler: promhttp.HandlerFor( - c.collector, - promhttp.HandlerOpts{}, - ), - ReadHeaderTimeout: 60 * time.Second, - } - - go func() { - c.logger.Info("Prometheus server started", "addr=", listenAddr.String()) - - if err := srv.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) { - c.logger.Error("Prometheus HTTP server ListenAndServe", "err", err) - } - }() - - return srv -} diff --git a/internal/client/control_plane.go b/internal/client/control_plane.go deleted file mode 100644 index 761d50e..0000000 --- a/internal/client/control_plane.go +++ /dev/null @@ -1,18 +0,0 @@ -package client - -import ( - "github.com/hashicorp/go-memdb" - babel "github.com/umbracle/babel/sdk" - "github.com/umbracle/vesta/internal/server/proto" -) - -type ControlPlane interface { - // Pull pulls the configs assigned to the agent when updated - Pull(nodeId string, ws memdb.WatchSet) ([]*proto.Allocation, error) - - // UpdateAlloc updates an allocation state - UpdateAlloc(alloc *proto.Allocation) error - - // UpdateSyncStatus updates the sync status of an allocation - UpdateSyncStatus(alloc, task string, status *babel.SyncStatus) error -} diff --git a/internal/client/metrics_hook.go b/internal/client/metrics_hook.go deleted file mode 100644 index f19dec7..0000000 --- a/internal/client/metrics_hook.go +++ /dev/null @@ -1,107 +0,0 @@ -package client - -import ( - "context" - "fmt" - "io" - "net/http" - "time" - - "github.com/hashicorp/go-hclog" - dto "github.com/prometheus/client_model/go" - "github.com/prometheus/common/expfmt" - "github.com/umbracle/vesta/internal/client/runner/hooks" - proto "github.com/umbracle/vesta/internal/client/runner/structs" -) - -var _ hooks.TaskHook = &metricsHook{} -var _ hooks.TaskPoststartHook = &metricsHook{} -var _ hooks.TaskStopHook = &metricsHook{} - -type MetricsUpdater interface { - UpdateMetrics(string, map[string]*dto.MetricFamily) -} - -type metricsHook struct { - logger hclog.Logger - closeCh chan struct{} - task *proto.Task - updater MetricsUpdater - ip string - url string -} - -func newMetricsHook(logger hclog.Logger, task *proto.Task, updater MetricsUpdater) *metricsHook { - h := &metricsHook{ - task: task, - closeCh: make(chan struct{}), - updater: updater, - } - h.logger = logger.Named(h.Name()) - return h -} - -func (m *metricsHook) Name() string { - return "metrics-hook" -} - -func (m *metricsHook) Poststart(ctx context.Context, req *hooks.TaskPoststartHookRequest) error { - if req.Spec.Ip == "" { - return nil - } - - tel, ok := m.task.Metadata["telemetry"] - if !ok { - return nil - } - - m.url = fmt.Sprintf("http://%s:%s", req.Spec.Ip, tel) - - go m.collectMetrics() - return nil -} - -func (m *metricsHook) collectMetrics() { - for { - res, err := http.Get(m.url) - if err != nil { - m.logger.Error("failed to query prometheus endpoint", "url", m.url, "err", err) - } else { - metrics, err := getMetricFamilies(res.Body) - if err != nil { - m.logger.Error("failed to process promtheus format", "err", err) - } else { - for _, mf := range metrics { - for _, metric := range mf.Metric { - metric.Label = append(metric.Label, &dto.LabelPair{Name: stringPtr("host"), Value: stringPtr(m.task.Name)}) - } - } - m.updater.UpdateMetrics(m.task.Tag, metrics) - } - } - - select { - case <-m.closeCh: - return - case <-time.After(5 * time.Second): - } - } -} - -func (m *metricsHook) Stop(ctx context.Context, req *hooks.TaskStopRequest) error { - close(m.closeCh) - return nil -} - -func getMetricFamilies(sourceData io.Reader) (map[string]*dto.MetricFamily, error) { - parser := expfmt.TextParser{} - metricFamiles, err := parser.TextToMetricFamilies(sourceData) - if err != nil { - return nil, err - } - return metricFamiles, nil -} - -func stringPtr(s string) *string { - return &s -} diff --git a/internal/client/runner/allocrunner/alloc_runner.go b/internal/client/runner/allocrunner/alloc_runner.go deleted file mode 100644 index 68412b1..0000000 --- a/internal/client/runner/allocrunner/alloc_runner.go +++ /dev/null @@ -1,459 +0,0 @@ -package allocrunner - -import ( - "context" - "sync" - - "github.com/hashicorp/go-hclog" - "github.com/umbracle/vesta/internal/client/runner/allocrunner/allocdir" - "github.com/umbracle/vesta/internal/client/runner/allocrunner/taskrunner" - "github.com/umbracle/vesta/internal/client/runner/driver" - "github.com/umbracle/vesta/internal/client/runner/hooks" - "github.com/umbracle/vesta/internal/client/runner/state" - proto "github.com/umbracle/vesta/internal/client/runner/structs" -) - -type StateUpdater interface { - AllocStateUpdated(alloc *proto.Allocation) -} - -type Config struct { - Logger hclog.Logger - Alloc *proto.Allocation - State state.State - StateUpdater StateUpdater - Driver driver.Driver - ClientVolumeDir string - Hooks []hooks.TaskHookFactory -} - -type AllocRunner struct { - config *Config - logger hclog.Logger - tasks map[string]*taskrunner.TaskRunner - waitCh chan struct{} - alloc *proto.Allocation - driver driver.Driver - taskUpdated chan struct{} - stateUpdater StateUpdater - state state.State - allocUpdatedCh chan *proto.Allocation - volume string - shutdownStarted chan struct{} - shutdownCh chan struct{} - destroyCh chan struct{} - taskStateUpdateHandlerCh chan struct{} - wg sync.WaitGroup - allocDir *allocdir.AllocDir - runnerHooks []hooks.RunnerHook -} - -func NewAllocRunner(c *Config) *AllocRunner { - logger := c.Logger.Named("alloc_runner").With("alloc", c.Alloc.Deployment.Name) - - runner := &AllocRunner{ - config: c, - logger: logger, - tasks: map[string]*taskrunner.TaskRunner{}, - waitCh: make(chan struct{}), - alloc: c.Alloc, - driver: c.Driver, - taskUpdated: make(chan struct{}), - stateUpdater: c.StateUpdater, - state: c.State, - volume: c.ClientVolumeDir, - shutdownStarted: make(chan struct{}), - shutdownCh: make(chan struct{}), - destroyCh: make(chan struct{}), - taskStateUpdateHandlerCh: make(chan struct{}), - allocUpdatedCh: make(chan *proto.Allocation, 1), - runnerHooks: []hooks.RunnerHook{}, - allocDir: allocdir.NewAllocDir(c.ClientVolumeDir, c.Alloc.Deployment.Name), - } - - runner.initTaskRunners(c.Alloc.Deployment.Tasks) - runner.initHooks() - - return runner -} - -func (a *AllocRunner) initTaskRunners(tasks []*proto.Task) error { - for _, task := range tasks { - config := &taskrunner.Config{ - Logger: a.logger, - Task: task, - Allocation: a.config.Alloc, - Driver: a.config.Driver, - State: a.config.State, - TaskStateUpdated: a.TaskStateUpdated, - Hooks: a.config.Hooks, - TaskDir: a.allocDir.NewTaskDir(task.Name), - } - runner := taskrunner.NewTaskRunner(config) - a.tasks[task.Name] = runner - } - return nil -} - -func (a *AllocRunner) Deployment() *proto.Deployment { - return a.alloc.Deployment.Copy() -} - -func (a *AllocRunner) SetNetworkSpec(spec *proto.NetworkSpec) { - a.alloc.NetworkSpec = spec -} - -func (a *AllocRunner) ShutdownCh() chan struct{} { - return a.shutdownCh -} - -func (a *AllocRunner) Alloc() *proto.Allocation { - return a.alloc -} - -func (a *AllocRunner) handleTaskStateUpdates() { - defer close(a.taskStateUpdateHandlerCh) - - for done := false; !done; { - // wait for more updates - select { - case <-a.taskUpdated: - case <-a.waitCh: - // sync once more to collect the final states - done = true - } - - liveRunners := []*taskrunner.TaskRunner{} - - var killEvent *proto.TaskState_Event - var killTask string - - states := map[string]*proto.TaskState{} - for name, t := range a.tasks { - taskState := t.TaskState() - states[name] = taskState - - if taskState.State != proto.TaskState_Dead { - liveRunners = append(liveRunners, t) - continue - } - - if taskState.Failed { - if killEvent == nil { - killTask = name - killEvent = proto.NewTaskEvent(proto.TaskSiblingFailed). - SetTaskFailed(killTask) - } - } - } - - if len(liveRunners) > 0 { - if killEvent != nil { - // kill the live tasks - for _, tr := range liveRunners { - tr.EmitEvent(killEvent) - } - - states = a.killTasks() - - // wait for the liverunners to stop - for _, tr := range liveRunners { - a.logger.Info("waiting for task to exit", "task", tr.Task().Name) - select { - case <-tr.WaitCh(): - case <-a.waitCh: - } - } - } - } - - calloc := a.clientAlloc(states) - - a.stateUpdater.AllocStateUpdated(calloc) - } -} - -func (a *AllocRunner) runTasks() { - // Start and wait for all tasks. - for _, task := range a.tasks { - go task.Run() - } - for _, task := range a.tasks { - <-task.WaitCh() - } -} - -func (ar *AllocRunner) killTasks() map[string]*proto.TaskState { - var mu sync.Mutex - states := make(map[string]*proto.TaskState, len(ar.tasks)) - - wg := sync.WaitGroup{} - for name, tr := range ar.tasks { - wg.Add(1) - go func(name string, tr *taskrunner.TaskRunner) { - defer wg.Done() - - taskEvent := proto.NewTaskEvent(proto.TaskKilling) - err := tr.Kill(context.TODO(), taskEvent) - if err != nil { // TODO (what if the task is not running anymore) - ar.logger.Warn("error stopping task", "error", err, "task_name", name) - } - - taskState := tr.TaskState() - mu.Lock() - states[name] = taskState - mu.Unlock() - }(name, tr) - } - wg.Wait() - - return states -} - -func (a *AllocRunner) Run() { - defer close(a.waitCh) - - go a.handleAllocUpdates() - - go a.handleTaskStateUpdates() - - if err := a.prerun(); err != nil { - a.logger.Error("prerun failed", "error", err) - - goto POST - } - - a.runTasks() - -POST: - if a.isShuttingDown() { - return - } - - // Run the postrun hooks - if err := a.postrun(); err != nil { - a.logger.Error("postrun failed", "error", err) - } -} - -func (a *AllocRunner) handleAllocUpdates() { - for { - select { - case update := <-a.allocUpdatedCh: - a.handleAllocUpdate(update) - - case <-a.waitCh: - return - } - } -} - -func (a *AllocRunner) handleAllocUpdate(alloc *proto.Allocation) { - a.alloc = alloc - - // update the tasks - a.TaskStateUpdated() - - if alloc.Deployment.DesiredStatus == proto.Deployment_Stop { - a.killTasks() - } -} - -type Status struct { - Status proto.Allocation_Status - States map[string]*proto.TaskState -} - -func (a *AllocRunner) Status() *Status { - states := map[string]*proto.TaskState{} - for name, task := range a.tasks { - states[name] = task.TaskState() - } - - res := &Status{Status: getClientStatus(states), States: states} - - select { - case <-a.waitCh: - default: - // wait is not over yet - if res.Status == proto.Allocation_Complete { - // post run task have not finished yet adn the task are still running - // wait until everything stops to assert it is completed - res.Status = proto.Allocation_Running - } - } - - return res -} - -func (a *AllocRunner) clientAlloc(states map[string]*proto.TaskState) *proto.Allocation { - // Notify about the update on the allocation - calloc := a.alloc.Copy() - calloc.TaskStates = states - - calloc.Status = getClientStatus(states) - - select { - case <-a.waitCh: - default: - // wait is not over yet - if calloc.Status == proto.Allocation_Complete { - // post run task have not finished yet adn the task are still running - // wait until everything stops to assert it is completed - calloc.Status = proto.Allocation_Running - } - } - - return calloc -} - -func (a *AllocRunner) newTaskRunner(task *proto.Task) *taskrunner.TaskRunner { - config := &taskrunner.Config{ - Logger: a.logger, - Task: task, - Allocation: a.config.Alloc, - Driver: a.config.Driver, - State: a.config.State, - TaskStateUpdated: a.TaskStateUpdated, - Hooks: a.config.Hooks, - TaskDir: a.allocDir.NewTaskDir(task.Name), - } - - return taskrunner.NewTaskRunner(config) -} - -func (a *AllocRunner) TaskStateUpdated() { - select { - case a.taskUpdated <- struct{}{}: - default: - } -} - -func (a *AllocRunner) Restore() error { - for _, runner := range a.tasks { - if err := runner.Restore(); err != nil { - return err - } - } - return nil -} - -func (a *AllocRunner) isShuttingDown() bool { - select { - case <-a.shutdownStarted: - return true - default: - return false - } -} - -func (a *AllocRunner) DestroyCh() chan struct{} { - return a.destroyCh -} - -func (a *AllocRunner) Destroy() { - a.logger.Info("alloc destroyed") - - go func() { - states := a.killTasks() - calloc := a.clientAlloc(states) - a.stateUpdater.AllocStateUpdated(calloc) - - <-a.waitCh - - <-a.taskStateUpdateHandlerCh - - // delete the allocation folder - if err := a.state.DeleteAllocationBucket(a.alloc.Deployment.Name); err != nil { - a.logger.Error("failed to delete allocation", "err", err) - } - - close(a.destroyCh) - }() -} - -func (a *AllocRunner) Update(deployment *proto.Deployment) { - a.logger.Info("alloc updated") - - alloc := a.alloc.Copy() - alloc.Deployment = deployment - - select { - // Drain queued update from the channel if possible, and check the modify - // index - case oldUpdate := <-a.allocUpdatedCh: - // If the old update is newer than the replacement, then skip the new one - // and return - if oldUpdate.Deployment.Sequence > alloc.Deployment.Sequence { - a.allocUpdatedCh <- oldUpdate - return - } - - case <-a.waitCh: - return - default: - } - - // Queue the new update - a.allocUpdatedCh <- alloc -} - -func (a *AllocRunner) WaitCh() <-chan struct{} { - return a.waitCh -} - -func (a *AllocRunner) Shutdown() { - close(a.shutdownStarted) - - go func() { - a.logger.Trace("shutting down") - - // Shutdown tasks gracefully if they were run - wg := sync.WaitGroup{} - for _, tr := range a.tasks { - wg.Add(1) - go func(tr *taskrunner.TaskRunner) { - tr.Shutdown() - wg.Done() - }(tr) - } - wg.Wait() - - // Wait for Run to exit - <-a.waitCh - close(a.shutdownCh) - }() -} - -// getClientStatus takes in the task states for a given allocation and computes -// the client status and description -func getClientStatus(taskStates map[string]*proto.TaskState) proto.Allocation_Status { - var pending, running, dead, failed bool - for _, state := range taskStates { - switch state.State { - case proto.TaskState_Running: - running = true - case proto.TaskState_Pending: - pending = true - case proto.TaskState_Dead: - if state.Failed { - failed = true - } else { - dead = true - } - } - } - - // Determine the alloc status - if failed { - return proto.Allocation_Failed - } else if pending { - return proto.Allocation_Pending - } else if running { - return proto.Allocation_Running - } else if dead { - return proto.Allocation_Complete - } - - return proto.Allocation_Unknown -} diff --git a/internal/client/runner/allocrunner/alloc_runner_hooks.go b/internal/client/runner/allocrunner/alloc_runner_hooks.go deleted file mode 100644 index 2040470..0000000 --- a/internal/client/runner/allocrunner/alloc_runner_hooks.go +++ /dev/null @@ -1,89 +0,0 @@ -package allocrunner - -import ( - "fmt" - "time" - - "github.com/umbracle/vesta/internal/client/runner/hooks" -) - -func (a *AllocRunner) initHooks() { - a.runnerHooks = []hooks.RunnerHook{ - newNetworkHook(a.logger, a.driver, a.alloc, a), - newVolumeHook(a.logger, a.driver, a.allocDir, a.alloc), - } -} - -// prerun is used to run the runners prerun hooks. -func (a *AllocRunner) prerun() error { - if a.logger.IsTrace() { - start := time.Now() - a.logger.Trace("running pre-run hooks", "start", start) - defer func() { - end := time.Now() - a.logger.Trace("finished pre-run hooks", "end", end, "duration", end.Sub(start)) - }() - } - - for _, hook := range a.runnerHooks { - pre, ok := hook.(hooks.RunnerPrerunHook) - if !ok { - continue - } - - name := pre.Name() - var start time.Time - if a.logger.IsTrace() { - start = time.Now() - a.logger.Trace("running pre-run hook", "name", name, "start", start) - } - - if err := pre.Prerun(); err != nil { - return fmt.Errorf("pre-run hook %q failed: %v", name, err) - } - - if a.logger.IsTrace() { - end := time.Now() - a.logger.Trace("finished pre-run hook", "name", name, "end", end, "duration", end.Sub(start)) - } - } - - return nil -} - -// postrun is used to run the runners postrun hooks. -func (a *AllocRunner) postrun() error { - if a.logger.IsTrace() { - start := time.Now() - a.logger.Trace("running post-run hooks", "start", start) - defer func() { - end := time.Now() - a.logger.Trace("finished post-run hooks", "end", end, "duration", end.Sub(start)) - }() - } - - for _, hook := range a.runnerHooks { - post, ok := hook.(hooks.RunnerPostrunHook) - if !ok { - continue - } - - name := post.Name() - var start time.Time - if a.logger.IsTrace() { - start = time.Now() - a.logger.Trace("running post-run hook", "name", name, "start", start) - } - - if err := post.Postrun(); err != nil { - return fmt.Errorf("hook %q failed: %v", name, err) - } - - if a.logger.IsTrace() { - end := time.Now() - a.logger.Trace("finished post-run hooks", "name", name, "end", end, "duration", end.Sub(start)) - } - } - - return nil -} diff --git a/internal/client/runner/allocrunner/alloc_runner_test.go b/internal/client/runner/allocrunner/alloc_runner_test.go deleted file mode 100644 index c05076f..0000000 --- a/internal/client/runner/allocrunner/alloc_runner_test.go +++ /dev/null @@ -1,554 +0,0 @@ -package allocrunner - -import ( - "errors" - "fmt" - "io/ioutil" - "os" - "path/filepath" - "sync" - "testing" - "time" - - "github.com/hashicorp/go-hclog" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/umbracle/vesta/internal/client/runner/docker" - "github.com/umbracle/vesta/internal/client/runner/mock" - "github.com/umbracle/vesta/internal/client/runner/state" - proto "github.com/umbracle/vesta/internal/client/runner/structs" - "github.com/umbracle/vesta/internal/testutil" -) - -func destroy(ar *AllocRunner) { - ar.Destroy() - <-ar.DestroyCh() -} - -func testAllocRunnerConfig(t *testing.T, alloc *proto.Allocation) *Config { - alloc.Deployment.Name = "mock-dep" - logger := hclog.New(&hclog.LoggerOptions{Level: hclog.Debug}) - - driver := docker.NewTestDockerDriver(t) - - tmpDir, err := ioutil.TempDir("/tmp", "task-runner-") - assert.NoError(t, err) - - state, err := state.NewBoltdbStore(filepath.Join(tmpDir, "my.db")) - assert.NoError(t, err) - - assert.NoError(t, state.PutAllocation(alloc)) - - volumeDir, err := ioutil.TempDir("/tmp", "task-runner-volume-dir") - require.NoError(t, err) - - t.Cleanup(func() { - os.RemoveAll(tmpDir) - os.RemoveAll(volumeDir) - }) - - cfg := &Config{ - Logger: logger, - Driver: driver, - Alloc: alloc, - State: state, - StateUpdater: &mockUpdater{}, - ClientVolumeDir: volumeDir, - } - - return cfg -} - -func TestAllocRunner_Create(t *testing.T) { - // Deploy an allocation with multiple tasks - alloc := mock.ServiceAlloc() - cfg := testAllocRunnerConfig(t, alloc) - - allocRunner := NewAllocRunner(cfg) - - go allocRunner.Run() - defer destroy(allocRunner) - - // wait for the allocation to be running - updater := cfg.StateUpdater.(*mockUpdater) - testutil.WaitForResult(func() (bool, error) { - last := updater.Last() - if last == nil { - return false, errors.New("last update nil") - } - - if last.Status != proto.Allocation_Running { - return false, fmt.Errorf("got client status %v; want running", last.Status) - } - - running := map[string]struct{}{} - for taskName, s := range last.TaskStates { - for _, e := range s.Events { - if e.Type == proto.TaskStarted { - running[taskName] = struct{}{} - } - } - } - if len(running) != 2 { - return false, fmt.Errorf("two task expected running") - } - - return true, nil - }, func(err error) { - require.NoError(t, err) - }) -} - -func TestAllocRunner_Destroy(t *testing.T) { - // After an allocation gets deployed, we send a terminal execution - // and all the task should be destroyed. - alloc := mock.ServiceAlloc() - task := alloc.Deployment.Tasks[0] - - cfg := testAllocRunnerConfig(t, alloc) - - allocRunner := NewAllocRunner(cfg) - - go allocRunner.Run() - - // wait for the alloc to be running - waitForRunningAlloc(t, cfg) - - // assert state was stored - ts, th, err := cfg.State.GetTaskState(alloc.Deployment.Name, task.Name) - require.NoError(t, err) - require.NotNil(t, th) - require.NotNil(t, ts) - - // destroy the task - allocRunner.Destroy() - - // wait for the destroy - select { - case <-allocRunner.DestroyCh(): - case <-time.After(10 * time.Second): - t.Fatal("failed to destroy") - } - - // alloc status shoulld be dead - status := allocRunner.Status() - require.Equal(t, status.Status, proto.Allocation_Complete) - - // state is cleaned - _, _, err = cfg.State.GetTaskState(alloc.Deployment.Name, task.Name) - require.Error(t, err) -} - -func TestAllocRunner_Restore(t *testing.T) { - // If after a restore the tasks are not running, the runner - // has to start them again - alloc := mock.ServiceAlloc() - cfg := testAllocRunnerConfig(t, alloc) - - oldAllocRunner := NewAllocRunner(cfg) - - go oldAllocRunner.Run() - - // wait for the alloc to be running - waitForRunningAlloc(t, cfg) - - // shutdown the alloc runner - oldAllocRunner.Shutdown() - - select { - case <-oldAllocRunner.ShutdownCh(): - case <-time.After(10 * time.Second): - t.Fatal("alloc runner did not shutdown") - } - - // destroy the tasks - for _, task := range oldAllocRunner.tasks { - require.NoError(t, cfg.Driver.DestroyTask(task.Handle().Id, true)) - } - - // reattach with a new alloc runner. The tasks have been destroyed - // but the desired state is running. Thus, the alloc runner should start - // the containers again - newAllocRunner := NewAllocRunner(cfg) - - // restore the task - require.NoError(t, newAllocRunner.Restore()) - - go newAllocRunner.Run() - defer destroy(newAllocRunner) - - updater := cfg.StateUpdater.(*mockUpdater) - testutil.WaitForResult(func() (bool, error) { - last := updater.Last() - if last == nil { - return false, fmt.Errorf("no updates") - } - if last.Status != proto.Allocation_Running { - return false, fmt.Errorf("alloc not complete") - } - - started := 0 - restarting := 0 - terminated := 0 - - for _, task := range last.TaskStates { - for _, ev := range task.Events { - if ev.Type == proto.TaskStarted { - started++ - } - if ev.Type == proto.TaskRestarting { - restarting++ - } - if ev.Type == proto.TaskTerminated { - terminated++ - } - } - } - - if started != 4 { - return false, fmt.Errorf("expected 4 started events but found %d", started) - } - if restarting != 2 { - return false, fmt.Errorf("expected 2 restarting events but found %d", restarting) - } - if terminated != 2 { - return false, fmt.Errorf("expected 2 terminated events but found %d", terminated) - } - - return true, nil - }, func(err error) { - require.NoError(t, err) - }) -} - -func TestAllocRunner_Reattach(t *testing.T) { - // The allocation runner has to reattach to the running tasks if - // it gets reconnected. - alloc := mock.ServiceAlloc() - cfg := testAllocRunnerConfig(t, alloc) - - oldAllocRunner := NewAllocRunner(cfg) - - go oldAllocRunner.Run() - - // wait for the alloc to be running - waitForRunningAlloc(t, cfg) - - // shutdown the alloc runner - oldAllocRunner.Shutdown() - - select { - case <-oldAllocRunner.ShutdownCh(): - case <-time.After(10 * time.Second): - t.Fatal("alloc runner did not shutdown") - } - - // restart the tasks in another allocRunner - newAllocRunner := NewAllocRunner(cfg) - - // restore the task - require.NoError(t, newAllocRunner.Restore()) - - go newAllocRunner.Run() - defer destroy(newAllocRunner) - - // it should not create any new tasks - updater := cfg.StateUpdater.(*mockUpdater) - testutil.WaitForResult(func() (bool, error) { - last := updater.Last() - if last == nil { - return false, fmt.Errorf("no updates") - } - if last.Status != proto.Allocation_Running { - return false, fmt.Errorf("alloc not complete") - } - - running := 0 - for _, task := range last.TaskStates { - for _, ev := range task.Events { - if ev.Type == proto.TaskStarted { - running++ - } - } - } - if running != 2 { - return false, fmt.Errorf("expected only two started events") - } - - return true, nil - }, func(err error) { - require.NoError(t, err) - }) -} - -func TestAllocRunner_TerminalUpdate_Destroy(t *testing.T) { - // if we update the desired status of the allocation to 'stop', - // the allocation and all the tasks should stop gracefully - - alloc := mock.ServiceAlloc() - cfg := testAllocRunnerConfig(t, alloc) - - allocRunner := NewAllocRunner(cfg) - - go allocRunner.Run() - defer destroy(allocRunner) - - // wait for the alloc to be running - waitForRunningAlloc(t, cfg) - - stopDeployment := alloc.Copy().Deployment - stopDeployment.DesiredStatus = proto.Deployment_Stop - - allocRunner.Update(stopDeployment) - - // Wait for all tasks to stop - updater := cfg.StateUpdater.(*mockUpdater) - testutil.WaitForResult(func() (bool, error) { - last := updater.Last() - - if last.Status != proto.Allocation_Complete { - return false, fmt.Errorf("alloc not completed") - } - - for name, t := range last.TaskStates { - if t.State != proto.TaskState_Dead { - return false, fmt.Errorf("task '%s' is not dead", name) - } - } - - return true, nil - }, func(err error) { - t.Fatalf("error waiting for initial state:\n%v", err) - }) -} - -func TestAllocRunner_TaskFailed_KillGroup(t *testing.T) { - // one task exists fast - alloc := mock.ServiceAlloc() - alloc.Deployment.Tasks[0].Args = []string{"echo", "a"} - alloc.Deployment.Tasks[0].Batch = true - - cfg := testAllocRunnerConfig(t, alloc) - - allocRunner := NewAllocRunner(cfg) - - go allocRunner.Run() - defer destroy(allocRunner) - - task0 := alloc.Deployment.Tasks[0] - task1 := alloc.Deployment.Tasks[1] - - updater := cfg.StateUpdater.(*mockUpdater) - testutil.WaitForResult(func() (bool, error) { - last := updater.Last() - if last == nil { - return false, fmt.Errorf("no updates") - } - - // task 0 has failed and it is dead - if last.TaskStates[task0.Name].Failed { - return false, fmt.Errorf("task 0 should have failed") - } - if last.TaskStates[task0.Name].State == proto.TaskState_Dead { - return false, fmt.Errorf("task 0 should be dead") - } - - // task 1 has is dead - if last.TaskStates[task1.Name].State == proto.TaskState_Dead { - return false, fmt.Errorf("task 0 should be dead") - } - - return true, nil - }, func(err error) { - t.Fatalf("err: %v", err) - }) -} - -func TestAllocRunner_PortConflict(t *testing.T) { - // if two tasks on the same deployment try to listen on - // the same port, one will fail since they share the - // same networking spec. - bindArgs := []string{"nc", "-l", "-p", "3000", "0.0.0.0"} - - alloc := mock.ServiceAlloc() - alloc.Deployment.Tasks[0].Args = bindArgs - alloc.Deployment.Tasks[1].Args = bindArgs - - cfg := testAllocRunnerConfig(t, alloc) - - allocRunner := NewAllocRunner(cfg) - - go allocRunner.Run() - defer destroy(allocRunner) - - updater := cfg.StateUpdater.(*mockUpdater) - testutil.WaitForResult(func() (bool, error) { - last := updater.Last() - if last == nil { - return false, fmt.Errorf("no updates") - } - - // wait for one of the task to restart - restarting := 0 - for _, s := range last.TaskStates { - for _, e := range s.Events { - if e.Type == proto.TaskRestarting { - restarting++ - } - } - } - if restarting != 1 { - return false, fmt.Errorf("restarting expected") - } - - return true, nil - }, func(err error) { - t.Fatalf("err: %v", err) - }) -} - -func TestAllocRunner_VolumeMount(t *testing.T) { - // one of the tasks mounts a volume - // 1. Deploy the tasks (volume not found, create it) - // 2. Touch a file in the folder - // 3. Restart the task and check the touched file - - alloc := mock.ServiceAlloc() - alloc.Deployment.Tasks[0].Volumes = map[string]*proto.Task_Volume{ - "data": { - Path: "/data1", - }, - } - - cfg := testAllocRunnerConfig(t, alloc) - - oldAllocRunner := NewAllocRunner(cfg) - - go oldAllocRunner.Run() - - // wait for the alloc to be running - waitForRunningAlloc(t, cfg) - - handleID := oldAllocRunner.tasks["a"].Handle().Id - res, err := cfg.Driver.ExecTask(handleID, []string{ - "touch", "/data1/file.txt", - }) - require.NoError(t, err) - require.Zero(t, res.ExitCode, 0) - - oldAllocRunner.Shutdown() - <-oldAllocRunner.ShutdownCh() - - // destroy the tasks - for _, task := range oldAllocRunner.tasks { - require.NoError(t, cfg.Driver.DestroyTask(task.Handle().Id, true)) - } - - // restart with a new allocation - newAllocRunner := NewAllocRunner(cfg) - - // restore the task - require.NoError(t, newAllocRunner.Restore()) - - go newAllocRunner.Run() - defer destroy(newAllocRunner) - - // wait for the other two tasks to be started since when - // it gets restored it starts in Running state (its old state before stopping) - updater := cfg.StateUpdater.(*mockUpdater) - testutil.WaitForResult(func() (bool, error) { - last := updater.Last() - if last == nil { - return false, fmt.Errorf("no updates") - } - if last.Status != proto.Allocation_Running { - return false, fmt.Errorf("alloc not complete") - } - - started := 0 - - for _, task := range last.TaskStates { - for _, ev := range task.Events { - if ev.Type == proto.TaskStarted { - started++ - } - } - } - - if started != 4 { - return false, fmt.Errorf("expected 4 started events but found %d", started) - } - - return true, nil - }, func(err error) { - require.NoError(t, err) - }) - - handleID = newAllocRunner.tasks["a"].Handle().Id - fmt.Println(handleID) - - res, err = cfg.Driver.ExecTask(handleID, []string{"cat", "/data1/file.txt"}) - require.NoError(t, err) - require.Empty(t, res.Stderr) - require.Empty(t, res.Stdout) -} - -type mockUpdater struct { - alloc *proto.Allocation - lock sync.Mutex -} - -func (m *mockUpdater) AllocStateUpdated(alloc *proto.Allocation) { - m.lock.Lock() - m.alloc = alloc - m.lock.Unlock() -} - -func (m *mockUpdater) Last() *proto.Allocation { - m.lock.Lock() - alloc := m.alloc - m.lock.Unlock() - return alloc -} - -func TestClientStatus(t *testing.T) { - cases := []struct { - states map[string]*proto.TaskState - status proto.Allocation_Status - }{ - { - map[string]*proto.TaskState{ - "a": {State: proto.TaskState_Running}, - }, - proto.Allocation_Running, - }, - { - map[string]*proto.TaskState{ - "a": {State: proto.TaskState_Pending}, - "b": {State: proto.TaskState_Running}, - }, - proto.Allocation_Pending, - }, - } - - for _, c := range cases { - require.Equal(t, c.status, getClientStatus(c.states)) - } -} - -func waitForRunningAlloc(t *testing.T, cfg *Config) { - updater := cfg.StateUpdater.(*mockUpdater) - testutil.WaitForResult(func() (bool, error) { - last := updater.Last() - if last == nil { - return false, fmt.Errorf("no updates") - } - if last.Status != proto.Allocation_Running { - return false, fmt.Errorf("alloc not running") - } - - return true, nil - }, func(err error) { - t.Fatalf("err: %v", err) - }) -} diff --git a/internal/client/runner/allocrunner/allocdir/alloc_dir.go b/internal/client/runner/allocrunner/allocdir/alloc_dir.go deleted file mode 100644 index fbc3c57..0000000 --- a/internal/client/runner/allocrunner/allocdir/alloc_dir.go +++ /dev/null @@ -1,115 +0,0 @@ -package allocdir - -import ( - "fmt" - "os" - "path/filepath" - "strings" -) - -type AllocDir struct { - AllocDir string - - TaskDirs map[string]*TaskDir -} - -func NewAllocDir(clientAllocDir, allocID string) *AllocDir { - allocDir := filepath.Join(clientAllocDir, allocID) - - return &AllocDir{ - AllocDir: allocDir, - TaskDirs: map[string]*TaskDir{}, - } -} - -func (a *AllocDir) NewTaskDir(name string) *TaskDir { - tt := newTaskDir(a.AllocDir, name) - a.TaskDirs[name] = tt - return tt -} - -func (a *AllocDir) Build() error { - // build alloc directories - if err := os.MkdirAll(a.AllocDir, 0755); err != nil { - return fmt.Errorf("failed to make the alloc directory %v: %v", a.AllocDir, err) - } - - return nil -} - -type volumeMount struct { - name string - path string -} - -type TaskDir struct { - Dir string - VolumesDir string - volumes []*volumeMount -} - -func newTaskDir(allocDir, taskName string) *TaskDir { - taskDir := filepath.Join(allocDir, taskName) - - return &TaskDir{ - Dir: taskDir, - VolumesDir: filepath.Join(taskDir, "volumes"), - } -} - -func (a *TaskDir) Build() error { - // build alloc directories - if err := os.MkdirAll(a.Dir, 0755); err != nil { - return fmt.Errorf("failed to make the task directory %v: %v", a.Dir, err) - } - - // Make the task directory have non-root permissions. - if err := dropDirPermissions(a.Dir, os.ModePerm); err != nil { - return err - } - - // Create a directory to store the volumes of the task - if err := os.MkdirAll(a.VolumesDir, 0777); err != nil { - return err - } - - if err := dropDirPermissions(a.VolumesDir, os.ModePerm); err != nil { - return err - } - - // create a new directory for each volume - for _, vol := range a.volumes { - dir := filepath.Join(a.VolumesDir, vol.name) - - if err := os.MkdirAll(dir, 0777); err != nil { - return err - } - if err := dropDirPermissions(dir, os.ModePerm); err != nil { - return err - } - } - - return nil -} - -func (a *TaskDir) GetVolume(name string) string { - return filepath.Join(a.VolumesDir, name) -} - -func (a *TaskDir) CreateVolume(name string, path string) string { - a.volumes = append(a.volumes, &volumeMount{name: name, path: path}) - - return a.GetVolume(name) -} - -func (a *TaskDir) ResolvePath(path string) (string, bool) { - for _, vol := range a.volumes { - if strings.HasPrefix(path, vol.path) { - relPath := strings.TrimPrefix(path, vol.path) - - dir := filepath.Join(a.VolumesDir, vol.name) - return filepath.Join(dir, relPath), true - } - } - return "", false -} diff --git a/internal/client/runner/allocrunner/allocdir/alloc_dir_test.go b/internal/client/runner/allocrunner/allocdir/alloc_dir_test.go deleted file mode 100644 index 01ae9e0..0000000 --- a/internal/client/runner/allocrunner/allocdir/alloc_dir_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package allocdir - -import ( - "io/ioutil" - "path/filepath" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestAllocDir_Create(t *testing.T) { - tmpDir, err := ioutil.TempDir("/tmp", "alloc-dir-test-") - assert.NoError(t, err) - - a0 := NewAllocDir(tmpDir, "alloc") - t0 := a0.NewTaskDir("a") - - require.NoError(t, t0.Build()) - require.NoError(t, a0.Build()) - - volDir := filepath.Join(tmpDir, "alloc", "a", "volumes") - require.DirExists(t, volDir) - - // write a file and build again, it should - // not override any files - err = ioutil.WriteFile(filepath.Join(volDir, "file.txt"), []byte{}, 0655) - require.NoError(t, err) - - a1 := NewAllocDir(tmpDir, "alloc") - a1.NewTaskDir("a") - require.NoError(t, a1.Build()) - - require.FileExists(t, filepath.Join(volDir, "file.txt")) -} - -func TestTaskDir_ResolvePath(t *testing.T) { - tmpDir, err := ioutil.TempDir("/tmp", "alloc-dir-test-") - assert.NoError(t, err) - - a0 := NewAllocDir(tmpDir, "alloc") - t0 := a0.NewTaskDir("a") - t0.CreateVolume("data", "/data") - - t0.Build() - - _, found := t0.ResolvePath("/data/genesis.ssz") - require.True(t, found) -} diff --git a/internal/client/runner/allocrunner/allocdir/fs.go b/internal/client/runner/allocrunner/allocdir/fs.go deleted file mode 100644 index 8834fd3..0000000 --- a/internal/client/runner/allocrunner/allocdir/fs.go +++ /dev/null @@ -1,67 +0,0 @@ -package allocdir - -import ( - "fmt" - "os" - "os/user" - "strconv" - - "golang.org/x/sys/unix" -) - -var nobody user.User - -func nobodyUser() user.User { - return nobody -} - -// dropDirPermissions gives full access to a directory to all users and sets -// the owner to nobody. -func dropDirPermissions(path string, desired os.FileMode) error { - if err := os.Chmod(path, desired|0777); err != nil { - return fmt.Errorf("Chmod(%v) failed: %v", path, err) - } - - // Can't change owner if not root. - if unix.Geteuid() != 0 { - return nil - } - - nobody := nobodyUser() - - uid, err := getUid(&nobody) - if err != nil { - return err - } - - gid, err := getGid(&nobody) - if err != nil { - return err - } - - if err := os.Chown(path, uid, gid); err != nil { - return fmt.Errorf("Couldn't change owner/group of %v to (uid: %v, gid: %v): %v", path, uid, gid, err) - } - - return nil -} - -// getUid for a user -func getUid(u *user.User) (int, error) { - uid, err := strconv.Atoi(u.Uid) - if err != nil { - return 0, fmt.Errorf("Unable to convert Uid to an int: %v", err) - } - - return uid, nil -} - -// getGid for a user -func getGid(u *user.User) (int, error) { - gid, err := strconv.Atoi(u.Gid) - if err != nil { - return 0, fmt.Errorf("Unable to convert Gid to an int: %v", err) - } - - return gid, nil -} diff --git a/internal/client/runner/allocrunner/network_hook.go b/internal/client/runner/allocrunner/network_hook.go deleted file mode 100644 index 36206f9..0000000 --- a/internal/client/runner/allocrunner/network_hook.go +++ /dev/null @@ -1,58 +0,0 @@ -package allocrunner - -import ( - "github.com/hashicorp/go-hclog" - "github.com/umbracle/vesta/internal/client/runner/driver" - "github.com/umbracle/vesta/internal/client/runner/structs" -) - -type networkStatusSetter interface { - SetNetworkSpec(*structs.NetworkSpec) -} - -type networkHook struct { - logger hclog.Logger - driver driver.Driver - alloc *structs.Allocation - networkStatusSetter networkStatusSetter - spec *structs.NetworkSpec -} - -func newNetworkHook(logger hclog.Logger, - driver driver.Driver, - alloc *structs.Allocation, - networkStatusSetter networkStatusSetter, -) *networkHook { - n := &networkHook{ - driver: driver, - alloc: alloc, - networkStatusSetter: networkStatusSetter, - } - n.logger = logger.Named(n.Name()) - return n -} - -func (n *networkHook) Name() string { - return "network-hook" -} - -func (n *networkHook) Prerun() error { - spec, _, err := n.driver.CreateNetwork(n.alloc.Deployment.Name, []string{n.alloc.Deployment.Alias}, n.alloc.Deployment.Name) - if err != nil { - return err - } - - if spec != nil { - n.spec = spec - n.networkStatusSetter.SetNetworkSpec(spec) - } - return nil -} - -func (n *networkHook) Postrun() error { - if n.spec == nil { - return nil - } - - return n.driver.DestroyNetwork(n.spec) -} diff --git a/internal/client/runner/allocrunner/taskrunner/artifacts_hook.go b/internal/client/runner/allocrunner/taskrunner/artifacts_hook.go deleted file mode 100644 index 87b6057..0000000 --- a/internal/client/runner/allocrunner/taskrunner/artifacts_hook.go +++ /dev/null @@ -1,61 +0,0 @@ -package taskrunner - -import ( - "context" - "fmt" - - "github.com/hashicorp/go-getter" - "github.com/hashicorp/go-hclog" - "github.com/umbracle/vesta/internal/client/runner/allocrunner/allocdir" - "github.com/umbracle/vesta/internal/client/runner/hooks" - proto "github.com/umbracle/vesta/internal/client/runner/structs" -) - -var _ hooks.TaskHook = &artifactsHook{} -var _ hooks.TaskPrestartHook = &artifactsHook{} - -type artifactsHook struct { - logger hclog.Logger - task *proto.Task - taskDir *allocdir.TaskDir -} - -func newArtifactsHook(logger hclog.Logger, alloc *proto.Allocation, taskDir *allocdir.TaskDir, task *proto.Task) *artifactsHook { - h := &artifactsHook{ - task: task, - taskDir: taskDir, - } - h.logger = logger.Named(h.Name()) - return h -} - -func (a *artifactsHook) Name() string { - return "artifacts-dir" -} - -func (a *artifactsHook) Prestart(ctx context.Context, req *hooks.TaskPrestartHookRequest) error { - if len(a.task.Artifacts) == 0 { - return nil - } - - for _, artifact := range a.task.Artifacts { - dst, ok := a.taskDir.ResolvePath(artifact.Destination) - if !ok { - return fmt.Errorf("could not resolve local destination: %s", artifact.Destination) - } - - fmt.Println("ssss", artifact.Destination, artifact.Source, dst) - - client := &getter.Client{ - Ctx: context.Background(), - Src: artifact.Source, - Dst: dst, - Mode: getter.ClientModeFile, - } - if err := client.Get(); err != nil { - panic(err) - } - } - - return nil -} diff --git a/internal/client/runner/allocrunner/taskrunner/task_dir_hook.go b/internal/client/runner/allocrunner/taskrunner/task_dir_hook.go deleted file mode 100644 index 8036466..0000000 --- a/internal/client/runner/allocrunner/taskrunner/task_dir_hook.go +++ /dev/null @@ -1,160 +0,0 @@ -package taskrunner - -import ( - "context" - "io/ioutil" - "path/filepath" - "sort" - "strings" - - "github.com/hashicorp/go-hclog" - "github.com/umbracle/vesta/internal/client/runner/allocrunner/allocdir" - "github.com/umbracle/vesta/internal/client/runner/driver" - "github.com/umbracle/vesta/internal/client/runner/hooks" - proto "github.com/umbracle/vesta/internal/client/runner/structs" -) - -var _ hooks.TaskHook = &taskDirHook{} -var _ hooks.TaskPrestartHook = &taskDirHook{} - -type mountSetter interface { - setMount(*driver.MountConfig) -} - -type taskDirHook struct { - logger hclog.Logger - task *proto.Task - alloc *proto.Allocation - mountSetter mountSetter - done bool - taskDir *allocdir.TaskDir -} - -func newTaskDirHook(logger hclog.Logger, alloc *proto.Allocation, taskDir *allocdir.TaskDir, task *proto.Task, mountSetter mountSetter) *taskDirHook { - h := &taskDirHook{ - task: task, - mountSetter: mountSetter, - alloc: alloc, - taskDir: taskDir, - } - h.logger = logger.Named(h.Name()) - return h -} - -func (t *taskDirHook) Name() string { - return "task-dir" -} - -func (t *taskDirHook) Prestart(ctx context.Context, req *hooks.TaskPrestartHookRequest) error { - if t.done { - return nil - } - - mountPoints := composeMountData(t.task.Data) - for _, mount := range mountPoints { - // create host directory for the mount - hostPath, err := ioutil.TempDir("/tmp", "vesta-") - if err != nil { - return err - } - - // create files - for name, content := range mount.files { - // the path of the file includes the parent directory - // trim it to get the relative name in 'hostPath' - localName := strings.TrimPrefix(name, mount.path) - - if err := ioutil.WriteFile(filepath.Join(hostPath, localName), []byte(content), 0644); err != nil { - return err - } - } - - t.mountSetter.setMount(&driver.MountConfig{ - HostPath: hostPath, - TaskPath: mount.path, - }) - } - - for name, volume := range t.task.Volumes { - mountPath := t.taskDir.CreateVolume(name, volume.Path) - - t.mountSetter.setMount(&driver.MountConfig{ - HostPath: mountPath, - TaskPath: volume.Path, - }) - } - - // build the task directory - if err := t.taskDir.Build(); err != nil { - return err - } - - t.done = true - return nil -} - -type mountPoint struct { - path string - files map[string]string -} - -func composeMountData(files map[string]string) []*mountPoint { - // sort by names - names := sort.StringSlice{} - for name := range files { - names = append(names, name) - } - - names.Sort() - - groups := []*mountPoint{} - for _, name := range names { - content := files[name] - - found := false - for _, grp := range groups { - prefix, ok := getPrefix(grp.path, name) - if ok { - found = true - // replace the group - grp.path = prefix - grp.files[name] = content - break - } - } - if !found { - // get absolute path - groups = append(groups, &mountPoint{ - path: getAbs(name), - files: map[string]string{ - name: content, - }, - }) - } - } - return groups -} - -func getAbs(path string) string { - spl := strings.Split(path, "/") - name := spl[:len(spl)-1] - return strings.Join(name, "/") -} - -func getPrefix(a, b string) (string, bool) { - aSpl := strings.Split(a, "/") - bSpl := strings.Split(b, "/") - - size := len(aSpl) - if size > len(bSpl) { - size = len(bSpl) - } - - prefix := []string{} - for i := 0; i < size; i++ { - if aSpl[i] == bSpl[i] { - prefix = append(prefix, aSpl[i]) - } - } - return strings.Join(prefix, "/"), len(prefix) != 1 -} diff --git a/internal/client/runner/allocrunner/taskrunner/task_dir_hook_test.go b/internal/client/runner/allocrunner/taskrunner/task_dir_hook_test.go deleted file mode 100644 index a68d3b0..0000000 --- a/internal/client/runner/allocrunner/taskrunner/task_dir_hook_test.go +++ /dev/null @@ -1,60 +0,0 @@ -package taskrunner - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestDirHook_ComposeMountData(t *testing.T) { - cases := []struct { - files []string - res []*mountPoint - }{ - { - []string{ - "/a/b/c", - "/a/b/c/d", - "/a/b/e", - "/b/c", - "/a/d", - }, - []*mountPoint{ - { - path: "/a", - files: map[string]string{ - "/a/b/c": "", - "/a/b/c/d": "", - "/a/b/e": "", - "/a/d": "", - }, - }, - { - path: "/b", - files: map[string]string{ - "/b/c": "", - }, - }, - }, - }, - } - - for _, c := range cases { - input := map[string]string{} - for _, file := range c.files { - input[file] = "" - } - found := composeMountData(input) - - // This does not seem to pass on ci with - // require.Equal(c.res, found) - if len(c.res) != len(found) { - t.Fatal("wrong length") - } - for i := 0; i < len(c.res); i++ { - require.Equal(t, c.res[i].files, found[i].files) - require.Equal(t, c.res[i].path, found[i].path) - } - } - -} diff --git a/internal/client/runner/allocrunner/taskrunner/task_runner.go b/internal/client/runner/allocrunner/taskrunner/task_runner.go deleted file mode 100644 index 90db452..0000000 --- a/internal/client/runner/allocrunner/taskrunner/task_runner.go +++ /dev/null @@ -1,357 +0,0 @@ -package taskrunner - -import ( - "context" - "fmt" - "sync" - "time" - - "github.com/hashicorp/go-hclog" - "github.com/umbracle/vesta/internal/client/runner/allocrunner/allocdir" - "github.com/umbracle/vesta/internal/client/runner/driver" - "github.com/umbracle/vesta/internal/client/runner/hooks" - "github.com/umbracle/vesta/internal/client/runner/state" - proto "github.com/umbracle/vesta/internal/client/runner/structs" - "github.com/umbracle/vesta/internal/uuid" -) - -var defaultMaxEvents = 10 - -type TaskRunner struct { - logger hclog.Logger - driver driver.Driver - id string - waitCh chan struct{} - alloc *proto.Allocation - task *proto.Task - shutdownCh chan struct{} - killCtx context.Context - killCtxCancel context.CancelFunc - state state.State - taskDir *allocdir.TaskDir - taskStateUpdated func() - killErr error - killed bool - statusLock sync.Mutex - status *proto.TaskState - handle *proto.TaskHandle - restartCount uint64 - runnerHooks []hooks.TaskHook - mounts []*driver.MountConfig -} - -type Config struct { - Logger hclog.Logger - Driver driver.Driver - Allocation *proto.Allocation - TaskDir *allocdir.TaskDir - Task *proto.Task - State state.State - TaskStateUpdated func() - Hooks []hooks.TaskHookFactory -} - -func NewTaskRunner(config *Config) *TaskRunner { - logger := config.Logger.Named("task_runner").With("task-name", config.Task.Name) - - killCtx, killCancel := context.WithCancel(context.Background()) - - tr := &TaskRunner{ - logger: logger, - driver: config.Driver, - alloc: config.Allocation, - task: config.Task.Copy(), - waitCh: make(chan struct{}), - shutdownCh: make(chan struct{}), - killCtx: killCtx, - killCtxCancel: killCancel, - state: config.State, - status: proto.NewTaskState(), - taskStateUpdated: config.TaskStateUpdated, - mounts: []*driver.MountConfig{}, - runnerHooks: []hooks.TaskHook{}, - taskDir: config.TaskDir, - } - - // generate a unique id for this execution - id := fmt.Sprintf("%s/%s/%s", tr.alloc.Deployment.Name, tr.task.Name, uuid.Generate()[:8]) - tr.id = id - tr.status.Id = id - - for _, hookF := range config.Hooks { - tr.runnerHooks = append(tr.runnerHooks, hookF(logger, config.Allocation, config.Task)) - } - - tr.initHooks() - - return tr -} - -func (t *TaskRunner) setMount(mount *driver.MountConfig) { - t.mounts = append(t.mounts, mount) -} - -func (t *TaskRunner) Handle() *proto.TaskHandle { - return t.handle -} - -func (t *TaskRunner) Task() *proto.Task { - return t.task -} - -func (t *TaskRunner) Run() { - defer close(t.waitCh) - var result *proto.ExitResult - -MAIN: - for { - select { - case <-t.killCtx.Done(): - break MAIN - case <-t.shutdownCh: - return - default: - } - - if err := t.preStart(); err != nil { - t.logger.Error("prestart failed", "error", err) - goto RESTART - } - - select { - case <-t.killCtx.Done(): - break MAIN - case <-t.shutdownCh: - return - default: - } - - if err := t.runDriver(); err != nil { - t.logger.Error("driver failed", "error", err) - goto RESTART - } - - if err := t.postStart(); err != nil { - t.logger.Error("poststart failed", "error", err) - goto RESTART - } - - { - result = nil - - resultCh, err := t.driver.WaitTask(context.Background(), t.handle.Id) - if err != nil { - t.logger.Error("failed to wait for task", "err", err) - } else { - select { - case <-t.killCtx.Done(): - result = t.handleKill(resultCh) - case <-t.shutdownCh: - return - case result = <-resultCh: - } - - t.emitExitResultEvent(result) - } - } - - t.clearDriverHandle() - - RESTART: - restart, delay := t.shouldRestart() - if !restart { - break MAIN - } - - select { - case <-t.shutdownCh: - return - case <-time.After(delay): - } - } - - // task is dead - t.UpdateStatus(proto.TaskState_Dead, nil) - - // Run the stop hooks - if err := t.stop(); err != nil { - t.logger.Error("stop failed", "error", err) - } -} - -func (t *TaskRunner) handleKill(resultCh <-chan *proto.ExitResult) *proto.ExitResult { - t.killed = true - - // Check if it is still running - select { - case result := <-resultCh: - return result - default: - } - - if err := t.driver.StopTask(t.handle.Id, 0); err != nil { - t.killErr = err - } - - select { - case result := <-resultCh: - return result - case <-t.shutdownCh: - return nil - } -} - -func (t *TaskRunner) emitExitResultEvent(result *proto.ExitResult) { - if result == nil { - return - } - event := proto.NewTaskEvent(proto.TaskTerminated). - SetExitCode(result.ExitCode). - SetSignal(result.Signal) - - t.EmitEvent(event) -} - -func (t *TaskRunner) runDriver() error { - if t.handle != nil { - t.UpdateStatus(proto.TaskState_Running, nil) - return nil - } - - invocationid := uuid.Generate()[:8] - - tt := &driver.Task{ - Id: fmt.Sprintf("%s/%s", t.id, invocationid), - Task: t.task, - AllocID: t.alloc.Deployment.Name, - Network: t.alloc.NetworkSpec, - Mounts: t.mounts, - } - - handle, err := t.driver.StartTask(tt) - if err != nil { - return err - } - t.handle = handle - if err := t.state.PutTaskLocalState(t.alloc.Deployment.Name, t.task.Name, handle); err != nil { - panic(err) - } - t.UpdateStatus(proto.TaskState_Running, proto.NewTaskEvent(proto.TaskStarted)) - return nil -} - -func (t *TaskRunner) clearDriverHandle() { - if t.handle != nil { - t.driver.DestroyTask(t.handle.Id, true) - } - t.handle = nil -} - -func (t *TaskRunner) TaskState() *proto.TaskState { - t.statusLock.Lock() - defer t.statusLock.Unlock() - return t.status -} - -func (t *TaskRunner) shouldRestart() (bool, time.Duration) { - if t.killed { - return false, 0 - } - - if t.task.Batch { - // batch tasks are not restarted - t.UpdateStatus(proto.TaskState_Dead, proto.NewTaskEvent(proto.TaskNotRestarting).SetFailsTask()) - return false, 0 - } - - t.restartCount++ - if t.restartCount > 5 { - // too many restarts, consider this task dead and do not realocate - t.UpdateStatus(proto.TaskState_Dead, proto.NewTaskEvent(proto.TaskNotRestarting).SetFailsTask()) - return false, 0 - } - - t.UpdateStatus(proto.TaskState_Pending, proto.NewTaskEvent(proto.TaskRestarting)) - return true, time.Duration(2 * time.Second) -} - -func (t *TaskRunner) Restore() error { - state, handle, err := t.state.GetTaskState(t.alloc.Deployment.Name, t.task.Name) - if err != nil { - return err - } - t.status = state - - if err := t.driver.RecoverTask(handle.Id, handle); err != nil { - t.UpdateStatus(proto.TaskState_Pending, nil) - return nil - } - - // the handle was restored - t.handle = handle - return nil -} - -func (t *TaskRunner) UpdateStatus(status proto.TaskState_State, ev *proto.TaskState_Event) { - t.statusLock.Lock() - defer t.statusLock.Unlock() - - t.logger.Info("Update status", "status", status.String()) - t.status.State = status - - if ev != nil { - if ev.FailsTask() { - t.status.Failed = true - } - t.appendEventLocked(ev) - } - - if err := t.state.PutTaskState(t.alloc.Deployment.Name, t.task.Name, t.status); err != nil { - t.logger.Warn("failed to persist task state during update status", "err", err) - } - t.taskStateUpdated() -} - -func (t *TaskRunner) EmitEvent(ev *proto.TaskState_Event) { - t.statusLock.Lock() - defer t.statusLock.Unlock() - - t.appendEventLocked(ev) - - if err := t.state.PutTaskState(t.alloc.Deployment.Name, t.task.Name, t.status); err != nil { - t.logger.Warn("failed to persist task state during emit event", "err", err) - } - - t.taskStateUpdated() -} - -func (t *TaskRunner) appendEventLocked(ev *proto.TaskState_Event) { - if t.status.Events == nil { - t.status.Events = []*proto.TaskState_Event{} - } - t.status.Events = append(t.status.Events, ev) -} - -func (t *TaskRunner) Kill(ctx context.Context, ev *proto.TaskState_Event) error { - t.logger.Trace("Kill requested") - - t.killCtxCancel() - - select { - case <-t.WaitCh(): - case <-ctx.Done(): - return ctx.Err() - } - - return t.killErr -} - -func (t *TaskRunner) WaitCh() <-chan struct{} { - return t.waitCh -} - -func (t *TaskRunner) Shutdown() { - close(t.shutdownCh) - <-t.WaitCh() - t.taskStateUpdated() -} diff --git a/internal/client/runner/allocrunner/taskrunner/task_runner_hooks.go b/internal/client/runner/allocrunner/taskrunner/task_runner_hooks.go deleted file mode 100644 index 1ed759f..0000000 --- a/internal/client/runner/allocrunner/taskrunner/task_runner_hooks.go +++ /dev/null @@ -1,143 +0,0 @@ -package taskrunner - -import ( - "time" - - "github.com/umbracle/vesta/internal/client/runner/hooks" -) - -func (t *TaskRunner) initHooks() { - sysHooks := []hooks.TaskHook{ - newTaskDirHook(t.logger, t.alloc, t.taskDir, t.task, t), - newArtifactsHook(t.logger, t.alloc, t.taskDir, t.task), - } - - for _, hook := range sysHooks { - t.runnerHooks = append(t.runnerHooks, hook) - } -} - -func (t *TaskRunner) preStart() error { - if t.logger.IsTrace() { - start := time.Now() - t.logger.Trace("running prestart hooks", "start", start) - defer func() { - end := time.Now() - t.logger.Trace("finished prestart hooks", "end", end, "duration", end.Sub(start)) - }() - } - - for _, hook := range t.runnerHooks { - pre, ok := hook.(hooks.TaskPrestartHook) - if !ok { - continue - } - - name := pre.Name() - - // Build the request - req := hooks.TaskPrestartHookRequest{} - - var start time.Time - if t.logger.IsTrace() { - start = time.Now() - t.logger.Trace("running prestart hook", "name", name, "start", start) - } - - // Run the prestart hook - if err := pre.Prestart(t.killCtx, &req); err != nil { - return nil - } - - if t.logger.IsTrace() { - end := time.Now() - t.logger.Trace("finished prestart hook", "name", name, "end", end, "duration", end.Sub(start)) - } - } - - return nil -} - -func (t *TaskRunner) postStart() error { - if t.logger.IsTrace() { - start := time.Now() - t.logger.Trace("running poststart hooks", "start", start) - defer func() { - end := time.Now() - t.logger.Trace("finished poststart hooks", "end", end, "duration", end.Sub(start)) - }() - } - - for _, hook := range t.runnerHooks { - post, ok := hook.(hooks.TaskPoststartHook) - if !ok { - continue - } - - name := post.Name() - - // Build the request - req := hooks.TaskPoststartHookRequest{ - Spec: t.handle.Network, - } - - var start time.Time - if t.logger.IsTrace() { - start = time.Now() - t.logger.Trace("running poststart hook", "name", name, "start", start) - } - - // Run the poststart hook - if err := post.Poststart(t.killCtx, &req); err != nil { - return nil - } - - if t.logger.IsTrace() { - end := time.Now() - t.logger.Trace("finished poststart hook", "name", name, "end", end, "duration", end.Sub(start)) - } - } - - return nil -} - -func (t *TaskRunner) stop() error { - if t.logger.IsTrace() { - start := time.Now() - t.logger.Trace("running stop hooks", "start", start) - defer func() { - end := time.Now() - t.logger.Trace("finished stop hooks", "end", end, "duration", end.Sub(start)) - }() - } - - for _, hook := range t.runnerHooks { - stop, ok := hook.(hooks.TaskStopHook) - if !ok { - continue - } - - name := stop.Name() - - // Build the request - req := hooks.TaskStopRequest{} - - var start time.Time - if t.logger.IsTrace() { - start = time.Now() - t.logger.Trace("running stop hook", "name", name, "start", start) - } - - // Run the stop hook - if err := stop.Stop(t.killCtx, &req); err != nil { - return nil - } - - if t.logger.IsTrace() { - end := time.Now() - t.logger.Trace("finished stop hook", "name", name, "end", end, "duration", end.Sub(start)) - } - } - - return nil -} diff --git a/internal/client/runner/allocrunner/taskrunner/task_runner_test.go b/internal/client/runner/allocrunner/taskrunner/task_runner_test.go deleted file mode 100644 index f530d97..0000000 --- a/internal/client/runner/allocrunner/taskrunner/task_runner_test.go +++ /dev/null @@ -1,275 +0,0 @@ -package taskrunner - -import ( - "context" - "fmt" - "io/ioutil" - "os" - "path/filepath" - "testing" - "time" - - "github.com/hashicorp/go-hclog" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/umbracle/vesta/internal/client/runner/allocrunner/allocdir" - "github.com/umbracle/vesta/internal/client/runner/docker" - "github.com/umbracle/vesta/internal/client/runner/state" - proto "github.com/umbracle/vesta/internal/client/runner/structs" - "github.com/umbracle/vesta/internal/testutil" -) - -func destroyRunner(tr *TaskRunner) { - tr.Kill(context.Background(), proto.NewTaskEvent("")) -} - -func testWaitForTaskToDie(t *testing.T, tr *TaskRunner) { - testutil.WaitForResult(func() (bool, error) { - ts := tr.TaskState() - return ts.State == proto.TaskState_Dead, fmt.Errorf("expected task to be dead, got %v", ts.State) - }, func(err error) { - require.NoError(t, err) - }) -} - -func testWaitForTaskToStart(t *testing.T, tr *TaskRunner) { - testutil.WaitForResult(func() (bool, error) { - ts := tr.TaskState() - return ts.State == proto.TaskState_Running, fmt.Errorf("expected task to be running, got %v", ts.State) - }, func(err error) { - require.NoError(t, err) - }) -} - -func setupTaskRunner(t *testing.T, task *proto.Task) *Config { - task.Name = "test-task" - logger := hclog.New(&hclog.LoggerOptions{Level: hclog.Debug}) - - driver := docker.NewTestDockerDriver(t) - - alloc := &proto.Allocation{ - Deployment: &proto.Deployment{ - Name: "test-alloc", - Tasks: []*proto.Task{ - task, - }, - }, - } - - tmpDir, err := ioutil.TempDir("/tmp", "task-runner-") - assert.NoError(t, err) - - state, err := state.NewBoltdbStore(filepath.Join(tmpDir, "my.db")) - assert.NoError(t, err) - - assert.NoError(t, state.PutAllocation(alloc)) - - allocdir := allocdir.NewAllocDir(t.TempDir(), "alloc") - require.NoError(t, allocdir.Build()) - - taskDir := allocdir.NewTaskDir("task") - - t.Cleanup(func() { - os.RemoveAll(tmpDir) - }) - - cfg := &Config{ - Logger: logger, - Task: task, - Allocation: alloc, - Driver: driver, - State: state, - TaskDir: taskDir, - TaskStateUpdated: func() {}, - } - - return cfg -} - -func TestTaskRunner_Stop_ExitCode(t *testing.T) { - tt := &proto.Task{ - Image: "busybox", - Tag: "1.29.3", - Args: []string{"sleep", "3"}, - } - r := NewTaskRunner(setupTaskRunner(t, tt)) - go r.Run() - - testWaitForTaskToStart(t, r) - - err := r.Kill(context.Background(), proto.NewTaskEvent("drop")) - require.NoError(t, err) - - terminatedEvent := r.TaskState().Events[1] - require.Equal(t, terminatedEvent.Type, proto.TaskTerminated) - require.Equal(t, terminatedEvent.Details["exit_code"], "137") -} - -func TestTaskRunner_Restore_AlreadyRunning(t *testing.T) { - // Restoring a running task should not re run the task - tt := &proto.Task{ - Image: "busybox", - Tag: "1.29.3", - Args: []string{"sleep", "3"}, - Batch: true, - } - cfg := setupTaskRunner(t, tt) - - oldRunner := NewTaskRunner(cfg) - go oldRunner.Run() - - testWaitForTaskToStart(t, oldRunner) - - // stop the task runner - oldRunner.Shutdown() - - // start another task runner with the same state - newRunner := NewTaskRunner(cfg) - - // restore the task - require.NoError(t, newRunner.Restore()) - defer destroyRunner(newRunner) - - go newRunner.Run() - - // wait for the process to finish - testWaitForTaskToDie(t, newRunner) - - // assert the process only started once - state := newRunner.TaskState() - - started := 0 - for _, ev := range state.Events { - if ev.Type == proto.TaskStarted { - started++ - } - } - assert.Equal(t, 1, started) -} - -func TestTaskRunner_Restore_RequiresRestart(t *testing.T) { - // Restore a running task that was dropped should restart - // the task. - tt := &proto.Task{ - Image: "busybox", - Tag: "1.29.3", - Args: []string{"sleep", "6"}, - } - cfg := setupTaskRunner(t, tt) - - oldRunner := NewTaskRunner(cfg) - go oldRunner.Run() - - testWaitForTaskToStart(t, oldRunner) - - // stop runner and stop the instance - oldRunner.Shutdown() - require.NoError(t, oldRunner.driver.DestroyTask(oldRunner.handle.Id, true)) - - // restart (and restore) the runner - newRunner := NewTaskRunner(cfg) - require.NoError(t, newRunner.Restore()) - defer destroyRunner(newRunner) - - go newRunner.Run() - - // wait for the task to start again - testWaitForTaskToStart(t, newRunner) - - events := newRunner.TaskState().Events - for _, ev := range events { - t.Log(ev.Type, ev.Details) - } - - require.Equal(t, events[0].Type, proto.TaskStarted) // initial start - require.Equal(t, events[1].Type, proto.TaskTerminated) // emitted during newRunner.Run - require.Equal(t, events[2].Type, proto.TaskRestarting) - require.Equal(t, events[3].Type, proto.TaskStarted) -} - -func TestTaskRunner_Shutdown(t *testing.T) { - // A task can be shutdown and it notifies with the - // wait channel - tt := &proto.Task{ - Image: "busybox", - Tag: "1.29.3", - Args: []string{"sleep", "6"}, - } - cfg := setupTaskRunner(t, tt) - - runner := NewTaskRunner(cfg) - go runner.Run() - - testWaitForTaskToStart(t, runner) - - runner.Shutdown() - - select { - case <-runner.WaitCh(): - case <-time.After(5 * time.Second): - t.Fatal("it did not notify shutdown") - } -} - -func TestTaskRunner_MountData(t *testing.T) { - mountData := map[string]string{ - "/var/xx.txt": "data", - "/var/yy.txt": "data2", - } - - // we can create a task with mount data and deploy it - tt := &proto.Task{ - Image: "busybox", - Tag: "1.29.3", - Args: []string{"sleep", "6"}, - Data: mountData, - } - cfg := setupTaskRunner(t, tt) - - runner := NewTaskRunner(cfg) - go runner.Run() - - testWaitForTaskToStart(t, runner) - - for fileName, content := range mountData { - res, err := cfg.Driver.ExecTask(runner.handle.Id, []string{"cat", fileName}) - require.NoError(t, err) - - require.Zero(t, res.ExitCode) - require.Equal(t, content, string(res.Stdout)) - } -} - -func TestTaskRunner_Volumes(t *testing.T) { - // we can create a task with mount data and deploy it - tt := &proto.Task{ - Image: "busybox", - Tag: "1.29.3", - Args: []string{"sleep", "6"}, - Volumes: map[string]*proto.Task_Volume{ - "a": { - Path: "/data", - }, - }, - } - cfg := setupTaskRunner(t, tt) - - // create and build the task runner volumes here? We need to move - // this out of alloc runner and into the task runner itself - - cfg.TaskDir.CreateVolume("a", "/data") - require.NoError(t, cfg.TaskDir.Build()) - - // create a file - content := []byte("content") - require.NoError(t, os.WriteFile(filepath.Join(cfg.TaskDir.GetVolume("a"), "file.txt"), content, 0655)) - - runner := NewTaskRunner(cfg) - go runner.Run() - - testWaitForTaskToStart(t, runner) - - res, err := cfg.Driver.ExecTask(runner.handle.Id, []string{"cat", "/data/file.txt"}) - require.NoError(t, err) - require.Equal(t, content, res.Stdout) -} diff --git a/internal/client/runner/allocrunner/volume_hook.go b/internal/client/runner/allocrunner/volume_hook.go deleted file mode 100644 index d3151b4..0000000 --- a/internal/client/runner/allocrunner/volume_hook.go +++ /dev/null @@ -1,37 +0,0 @@ -package allocrunner - -import ( - "github.com/hashicorp/go-hclog" - "github.com/umbracle/vesta/internal/client/runner/allocrunner/allocdir" - "github.com/umbracle/vesta/internal/client/runner/driver" - "github.com/umbracle/vesta/internal/client/runner/structs" -) - -type volumeHook struct { - logger hclog.Logger - driver driver.Driver - alloc *structs.Allocation - allocDir *allocdir.AllocDir -} - -func newVolumeHook(logger hclog.Logger, - driver driver.Driver, - allocDir *allocdir.AllocDir, - alloc *structs.Allocation, -) *volumeHook { - n := &volumeHook{ - driver: driver, - alloc: alloc, - allocDir: allocDir, - } - n.logger = logger.Named(n.Name()) - return n -} - -func (v *volumeHook) Name() string { - return "volume-hook" -} - -func (v *volumeHook) Prerun() error { - return v.allocDir.Build() -} diff --git a/internal/client/runner/docker/coordinator.go b/internal/client/runner/docker/coordinator.go deleted file mode 100644 index dfdb1a9..0000000 --- a/internal/client/runner/docker/coordinator.go +++ /dev/null @@ -1,97 +0,0 @@ -package docker - -import ( - "context" - "io" - "io/ioutil" - "sync" - - "github.com/docker/docker/api/types" -) - -type pullFuture struct { - waitCh chan struct{} - - err error - imageID string -} - -func newPullFuture() *pullFuture { - return &pullFuture{ - waitCh: make(chan struct{}), - } -} - -func (p *pullFuture) wait() *pullFuture { - <-p.waitCh - return p -} - -func (p *pullFuture) result() (imageID string, err error) { - return p.imageID, p.err -} - -func (p *pullFuture) set(imageID string, err error) { - p.imageID = imageID - p.err = err - close(p.waitCh) -} - -type dockerImageCoordinator struct { - client dockerClient - imageLock sync.Mutex - pullFutures map[string]*pullFuture -} - -type dockerClient interface { - ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error) - ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error) -} - -func newDockerImageCoordinator(client dockerClient) *dockerImageCoordinator { - return &dockerImageCoordinator{ - client: client, - pullFutures: map[string]*pullFuture{}, - } -} - -func (d *dockerImageCoordinator) PullImage(image string) (string, error) { - d.imageLock.Lock() - future, ok := d.pullFutures[image] - if !ok { - future = newPullFuture() - d.pullFutures[image] = future - - go d.pullImageImpl(image, future) - } - d.imageLock.Unlock() - - id, err := future.wait().result() - - d.imageLock.Lock() - defer d.imageLock.Unlock() - - delete(d.pullFutures, image) - - return id, err -} - -func (d *dockerImageCoordinator) pullImageImpl(image string, future *pullFuture) { - reader, err := d.client.ImagePull(context.Background(), image, types.ImagePullOptions{}) - if err != nil { - future.set("", err) - return - } - if _, err = io.Copy(ioutil.Discard, reader); err != nil { - future.set("", err) - return - } - - dockerImage, _, err := d.client.ImageInspectWithRaw(context.Background(), image) - if err != nil { - future.set("", err) - return - } - - future.set(dockerImage.ID, nil) -} diff --git a/internal/client/runner/docker/coordinator_test.go b/internal/client/runner/docker/coordinator_test.go deleted file mode 100644 index 18f4a2c..0000000 --- a/internal/client/runner/docker/coordinator_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package docker - -import ( - "context" - "fmt" - "io" - "strings" - "testing" - "time" - - "github.com/docker/docker/api/types" - "github.com/stretchr/testify/assert" - "github.com/umbracle/vesta/internal/uuid" -) - -type mockClient struct { - idMap map[string]string - delay time.Duration - pulls int -} - -func (m *mockClient) ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error) { - time.Sleep(m.delay) - m.pulls++ - - reader := io.NopCloser(strings.NewReader("")) - return reader, nil -} - -func (m *mockClient) ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error) { - id, ok := m.idMap[imageID] - if !ok { - return types.ImageInspect{}, nil, fmt.Errorf("id not found %s", imageID) - } - return types.ImageInspect{ID: id}, nil, nil -} - -func (m *mockClient) setID(image string) string { - id := uuid.Generate() - m.idMap[image] = id - return id -} - -func newMockClient(delay time.Duration) *mockClient { - return &mockClient{idMap: map[string]string{}, delay: delay} -} - -func TestCoordinator_ConcurrentPulls(t *testing.T) { - image := "image" - - client := newMockClient(2 * time.Second) - id := client.setID(image) - - c := newDockerImageCoordinator(client) - - num := 10 - doneCh := make(chan string, num) - - for i := 0; i < num; i++ { - go func(t *testing.T) { - res, err := c.PullImage(image) - assert.NoError(t, err) - - doneCh <- res - }(t) - } - - for i := 0; i < num; i++ { - res := <-doneCh - assert.Equal(t, res, id) - } - - assert.Equal(t, client.pulls, 1) -} diff --git a/internal/client/runner/docker/driver.go b/internal/client/runner/docker/driver.go deleted file mode 100644 index 4d31f76..0000000 --- a/internal/client/runner/docker/driver.go +++ /dev/null @@ -1,298 +0,0 @@ -package docker - -import ( - "context" - "fmt" - "time" - - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/network" - "github.com/docker/docker/api/types/strslice" - "github.com/docker/docker/client" - "github.com/hashicorp/go-hclog" - "github.com/umbracle/vesta/internal/client/runner/driver" - proto "github.com/umbracle/vesta/internal/client/runner/structs" -) - -var _ driver.Driver = &Docker{} - -var ErrTaskNotFound = fmt.Errorf("task not found") - -type Docker struct { - logger hclog.Logger - client *client.Client - coordinator *dockerImageCoordinator - store *taskStore - networkName string -} - -func NewDockerDriver(logger hclog.Logger, networkName string) (*Docker, error) { - if logger == nil { - logger = hclog.NewNullLogger() - } else { - logger = logger.Named("docker") - } - - client, err := client.NewClientWithOpts(client.FromEnv) - if err != nil { - return nil, err - } - - // initialize the private network. This is required to have - // DNS discovery by docker. - networks, err := client.NetworkList(context.Background(), types.NetworkListOptions{}) - if err != nil { - return nil, err - } - found := false - for _, net := range networks { - if net.Name == networkName { - found = true - break - } - } - - if !found { - logger.Info("create private network", "name", networkName) - if _, err := client.NetworkCreate(context.Background(), networkName, types.NetworkCreate{CheckDuplicate: true}); err != nil { - return nil, err - } - } - - d := &Docker{ - logger: logger, - client: client, - coordinator: newDockerImageCoordinator(client), - store: newTaskStore(), - networkName: networkName, - } - return d, nil -} - -func (d *Docker) DestroyTask(taskID string, force bool) error { - h, ok := d.store.Get(taskID) - if !ok { - return ErrTaskNotFound - } - - c, err := d.client.ContainerInspect(context.Background(), h.containerID) - if err != nil { - return err - } else { - if c.State.Running { - if !force { - return fmt.Errorf("cannot destroy if force not set to true") - } - - timeout := 1 * time.Second - if err := d.client.ContainerStop(context.Background(), h.containerID, &timeout); err != nil { - h.logger.Warn("failed to stop container", "err", err) - } - } - } - - d.store.Delete(taskID) - return nil -} - -func (d *Docker) StopTask(taskID string, timeout time.Duration) error { - h, ok := d.store.Get(taskID) - if !ok { - return ErrTaskNotFound - } - - return h.Kill(timeout) -} - -func (d *Docker) WaitTask(ctx context.Context, taskID string) (<-chan *proto.ExitResult, error) { - handle, ok := d.store.Get(taskID) - if !ok { - return nil, ErrTaskNotFound - } - ch := make(chan *proto.ExitResult) - go func() { - defer close(ch) - - select { - case <-handle.waitCh: - ch <- handle.exitResult - case <-ctx.Done(): - ch <- &proto.ExitResult{ - Err: ctx.Err().Error(), - } - } - }() - return ch, nil -} - -func (d *Docker) RecoverTask(taskID string, task *proto.TaskHandle) error { - if _, ok := d.store.Get(taskID); ok { - return nil - } - - if _, err := d.client.ContainerInspect(context.Background(), task.ContainerID); err != nil { - return err - } - - h := &taskHandle{ - logger: d.logger.Named(taskID), - client: d.client, - containerID: task.ContainerID, - waitCh: make(chan struct{}), - } - - d.store.Set(taskID, h) - go h.run() - - return nil -} - -func (d *Docker) ExecTask(taskID string, cmd []string) (*driver.ExecTaskResult, error) { - h, ok := d.store.Get(taskID) - if !ok { - return nil, fmt.Errorf("task not found") - } - - return h.Exec(context.Background(), cmd) -} - -func (d *Docker) StartTask(task *driver.Task) (*proto.TaskHandle, error) { - d.logger.Debug("Create task", "image", task.Image, "tag", task.Tag) - - if err := d.createImage(task.Image + ":" + task.Tag); err != nil { - return nil, err - } - - opts, err := d.createContainerOptions(task) - if err != nil { - return nil, err - } - body, err := d.client.ContainerCreate(context.Background(), opts.config, opts.host, opts.network, nil, "") - if err != nil { - return nil, err - } - - if err := d.client.ContainerStart(context.Background(), body.ID, types.ContainerStartOptions{}); err != nil { - return nil, err - } - - var ip string - if task.Network != nil { - // ip gets derived from the network - ip = task.Network.Ip - } - - h := &taskHandle{ - logger: d.logger.Named(task.Id), - client: d.client, - containerID: body.ID, - waitCh: make(chan struct{}), - } - - d.store.Set(task.Id, h) - go h.run() - - handle := &proto.TaskHandle{ - Id: task.Id, - ContainerID: body.ID, - Network: &proto.TaskHandle_Network{ - Ip: ip, - }, - } - return handle, nil -} - -type createContainerOptions struct { - name string - config *container.Config - host *container.HostConfig - network *network.NetworkingConfig -} - -func (d *Docker) createContainerOptions(task *driver.Task) (*createContainerOptions, error) { - labels := map[string]string{} - for k, v := range task.Labels { - labels[k] = v - } - // append system wide labels - labels["vesta"] = "true" - - config := &container.Config{ - Image: task.Image + ":" + task.Tag, - Cmd: strslice.StrSlice(task.Args), - Labels: labels, - } - for k, v := range task.Env { - config.Env = append(config.Env, k+"="+v) - } - - hostConfig := &container.HostConfig{ - Binds: []string{}, - } - for _, mount := range task.Mounts { - // both volume and bind get mounted the same way - hostConfig.Binds = append(hostConfig.Binds, mount.HostPath+":"+mount.TaskPath) - } - - if task.Network != nil { - // connect network and pid to the network start container - hostConfig.NetworkMode = container.NetworkMode("container:init-" + task.AllocID) - hostConfig.PidMode = container.PidMode("container:init-" + task.AllocID) - } - - opts := &createContainerOptions{ - config: config, - host: hostConfig, - } - return opts, nil -} - -func (d *Docker) createImage(image string) error { - - _, dockerImageRaw, _ := d.client.ImageInspectWithRaw(context.Background(), image) - if dockerImageRaw != nil { - // already available - return nil - } - if _, err := d.coordinator.PullImage(image); err != nil { - return err - } - return nil -} - -func (d *Docker) containerByName(name string) (*types.ContainerJSON, error) { - containers, err := d.client.ContainerList(context.Background(), types.ContainerListOptions{All: true}) - if err != nil { - return nil, err - } - - var ( - bodyID string - found bool - ) - - containerName := "/" + name - -OUTER: - for _, c := range containers { - for _, cName := range c.Names { - if cName == containerName { - bodyID = c.ID - found = true - break OUTER - } - } - } - - if !found { - return nil, nil - } - - container, err := d.client.ContainerInspect(context.Background(), bodyID) - if err != nil { - return nil, err - } - - return &container, nil -} diff --git a/internal/client/runner/docker/driver_test.go b/internal/client/runner/docker/driver_test.go deleted file mode 100644 index 78084a3..0000000 --- a/internal/client/runner/docker/driver_test.go +++ /dev/null @@ -1,246 +0,0 @@ -package docker - -import ( - "context" - "os" - "path/filepath" - "strings" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/umbracle/vesta/internal/client/runner/driver" - proto "github.com/umbracle/vesta/internal/client/runner/structs" - "github.com/umbracle/vesta/internal/uuid" -) - -func TestDriver_CreateContainerOptions_Labels(t *testing.T) { - d := NewTestDockerDriver(t) - - tt := &driver.Task{ - Task: &proto.Task{ - Labels: map[string]string{ - "some": "label", - }, - }, - } - opts, err := d.createContainerOptions(tt) - assert.NoError(t, err) - - assert.Equal(t, opts.config.Labels["some"], "label") - assert.Equal(t, opts.config.Labels["vesta"], "true") -} - -func TestDriver_CreateContainerOptions_Env(t *testing.T) { - d := NewTestDockerDriver(t) - - tt := &driver.Task{ - Task: &proto.Task{ - Env: map[string]string{ - "some": "label", - }, - }, - } - opts, err := d.createContainerOptions(tt) - assert.NoError(t, err) - - assert.Equal(t, opts.config.Env, []string{"some=label"}) -} - -func TestDriver_CreateContainerOptions_Image(t *testing.T) { - d := NewTestDockerDriver(t) - - tt := &driver.Task{ - Task: &proto.Task{ - Image: "a", - Tag: "b", - }, - } - opts, err := d.createContainerOptions(tt) - assert.NoError(t, err) - - assert.Equal(t, opts.config.Image, "a:b") -} - -func TestDriver_CreateContainerOptions_DataMount(t *testing.T) { - d := NewTestDockerDriver(t) - - tt := &driver.Task{ - Task: &proto.Task{}, - Mounts: []*driver.MountConfig{ - {HostPath: "a", TaskPath: "b"}, - }, - } - opts, err := d.createContainerOptions(tt) - assert.NoError(t, err) - - assert.Equal(t, opts.host.Binds[0], "a:b") -} - -func TestDriver_Start_Wait(t *testing.T) { - d := NewTestDockerDriver(t) - - tt := &driver.Task{ - Task: &proto.Task{ - Image: "busybox", - Tag: "1.29.3", - Args: []string{"nc", "-l", "-p", "3000", "127.0.0.1"}, - }, - } - _, err := d.StartTask(tt) - assert.NoError(t, err) - - defer d.DestroyTask(tt.Id, true) - - waitCh, _ := d.WaitTask(context.Background(), tt.Id) - select { - case res := <-waitCh: - t.Fatalf("it should not finish yet: %v", res) - case <-time.After(time.Second): - } -} - -func TestDriver_Start_WaitFinished(t *testing.T) { - d := NewTestDockerDriver(t) - - tt := &driver.Task{ - Id: uuid.Generate(), - Task: &proto.Task{ - Image: "busybox", - Tag: "1.29.3", - Args: []string{"echo", "hello"}, - }, - } - _, err := d.StartTask(tt) - assert.NoError(t, err) - - defer d.DestroyTask(tt.Id, true) - - waitCh, _ := d.WaitTask(context.Background(), tt.Id) - select { - case res := <-waitCh: - assert.True(t, res.Successful()) - case <-time.After(time.Second): - t.Fatalf("timeout") - } -} - -func TestDriver_Start_Kill_Wait(t *testing.T) { - d := NewTestDockerDriver(t) - - tt := &driver.Task{ - Id: uuid.Generate(), - Task: &proto.Task{ - Image: "busybox", - Tag: "1.29.3", - Args: []string{"echo", "hello"}, - }, - } - _, err := d.StartTask(tt) - assert.NoError(t, err) - - defer d.DestroyTask(tt.Id, true) - - waitCh, _ := d.WaitTask(context.Background(), tt.Id) - - err = d.StopTask(tt.Id, time.Second) - assert.NoError(t, err) - - select { - case res := <-waitCh: - assert.True(t, res.Successful()) - case <-time.After(time.Second): - t.Fatal("timeout") - } -} - -func TestDriver_Start_Kill_Timeout(t *testing.T) { - d := NewTestDockerDriver(t) - - tt := &driver.Task{ - Id: uuid.Generate(), - Task: &proto.Task{ - Image: "busybox", - Tag: "1.29.3", - Args: []string{"sleep", "10"}, - }, - } - _, err := d.StartTask(tt) - assert.NoError(t, err) - - defer d.DestroyTask(tt.Id, true) - - waitCh, _ := d.WaitTask(context.Background(), tt.Id) - - err = d.StopTask(tt.Id, time.Second) - assert.NoError(t, err) - - select { - case res := <-waitCh: - assert.Equal(t, res.ExitCode, int64(137)) - case <-time.After(time.Second): - t.Fatal("timeout") - } -} - -func TestDriver_Exec(t *testing.T) { - d := NewTestDockerDriver(t) - - tt := &driver.Task{ - Id: uuid.Generate(), - Task: &proto.Task{ - Image: "busybox", - Tag: "1.29.3", - Args: []string{"sleep", "10"}, - }, - } - _, err := d.StartTask(tt) - assert.NoError(t, err) - - defer d.DestroyTask(tt.Id, true) - - // send a command that returns true - res, err := d.ExecTask(tt.Id, []string{"echo", "a"}) - require.NoError(t, err) - - require.Zero(t, res.ExitCode) - require.Empty(t, res.Stderr) - require.Equal(t, strings.TrimSpace(string(res.Stdout)), "a") - - // send a command that should fail (command not found) - res, err = d.ExecTask(tt.Id, []string{"curl"}) - require.NoError(t, err) - require.NotZero(t, res.ExitCode) -} - -func TestDriver_BindMount(t *testing.T) { - d := NewTestDockerDriver(t) - - bindDir, err := os.MkdirTemp("/tmp", "driver-") - require.NoError(t, err) - - tt := &driver.Task{ - Id: uuid.Generate(), - Task: &proto.Task{ - Image: "busybox", - Tag: "1.29.3", - Args: []string{"sleep", "10"}, - }, - Mounts: []*driver.MountConfig{ - {HostPath: bindDir, TaskPath: "/var"}, - }, - } - - _, err = d.StartTask(tt) - assert.NoError(t, err) - - // touch the file /var/file.txt should be visible - // on the bind folder as {bindDir}/file.txt - res, err := d.ExecTask(tt.Id, []string{"touch", "/var/file.txt"}) - require.NoError(t, err) - require.Zero(t, res.ExitCode) - - _, err = os.Stat(filepath.Join(bindDir, "file.txt")) - require.NoError(t, err) -} diff --git a/internal/client/runner/docker/handle.go b/internal/client/runner/docker/handle.go deleted file mode 100644 index ecc56bc..0000000 --- a/internal/client/runner/docker/handle.go +++ /dev/null @@ -1,120 +0,0 @@ -package docker - -import ( - "bytes" - "context" - "io/ioutil" - "sync" - "time" - - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/client" - "github.com/docker/docker/pkg/stdcopy" - "github.com/hashicorp/go-hclog" - "github.com/umbracle/vesta/internal/client/runner/driver" - proto "github.com/umbracle/vesta/internal/client/runner/structs" -) - -type taskHandle struct { - client *client.Client - logger hclog.Logger - containerID string - - waitCh chan struct{} - - exitResult *proto.ExitResult - exitResultLock sync.Mutex -} - -func (t *taskHandle) run() { - t.logger.Debug("handle running", "id", t.containerID) - - statusCh, errCh := t.client.ContainerWait(context.Background(), t.containerID, container.WaitConditionNotRunning) - - var status container.ContainerWaitOKBody - select { - case err := <-errCh: - if err != nil { - // TODO: unit test - t.logger.Error("failed to wait container", "id", t.containerID, "err", err) - } - case status = <-statusCh: - } - - t.exitResultLock.Lock() - t.exitResult = &proto.ExitResult{ - ExitCode: status.StatusCode, - Signal: 0, - } - t.exitResultLock.Unlock() - close(t.waitCh) -} - -func (t *taskHandle) Kill(killTimeout time.Duration) error { - if err := t.client.ContainerStop(context.Background(), t.containerID, &killTimeout); err != nil { - return err - } - return nil -} - -func (h *taskHandle) Exec(ctx context.Context, args []string) (*driver.ExecTaskResult, error) { - config := types.ExecConfig{ - AttachStderr: true, - AttachStdout: true, - Cmd: args, - } - - exec, err := h.client.ContainerExecCreate(ctx, h.containerID, config) - if err != nil { - return nil, err - } - - resp, err := h.client.ContainerExecAttach(ctx, exec.ID, types.ExecStartCheck{}) - if err != nil { - return nil, err - } - defer resp.Close() - - // read the output - var outBuf, errBuf bytes.Buffer - outputDone := make(chan error) - - go func() { - // StdCopy demultiplexes the stream into two buffers - _, err = stdcopy.StdCopy(&outBuf, &errBuf, resp.Reader) - outputDone <- err - }() - - select { - case err := <-outputDone: - if err != nil { - return nil, err - } - break - - case <-ctx.Done(): - return nil, ctx.Err() - } - - stdout, err := ioutil.ReadAll(&outBuf) - if err != nil { - return nil, err - } - stderr, err := ioutil.ReadAll(&errBuf) - if err != nil { - return nil, err - } - - res, err := h.client.ContainerExecInspect(ctx, exec.ID) - if err != nil { - return nil, err - } - - execResult := &driver.ExecTaskResult{ - ExitCode: uint64(res.ExitCode), - Stdout: stdout, - Stderr: stderr, - } - return execResult, nil -} diff --git a/internal/client/runner/docker/network.go b/internal/client/runner/docker/network.go deleted file mode 100644 index 693de6a..0000000 --- a/internal/client/runner/docker/network.go +++ /dev/null @@ -1,95 +0,0 @@ -package docker - -import ( - "context" - - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/network" - "github.com/umbracle/vesta/internal/client/runner/structs" -) - -var ( - networkInfraImage = "gcr.io/google_containers/pause-amd64:3.1" -) - -func (d *Docker) CreateNetwork(allocID string, dnsAlias []string, hostname string) (*structs.NetworkSpec, bool, error) { - if err := d.createImage(networkInfraImage); err != nil { - return nil, false, err - } - - // if the dns alias does not include the allocID, add it - found := false - for _, a := range dnsAlias { - if a == allocID { - found = true - break - } - } - if !found { - dnsAlias = append(dnsAlias, allocID) - } - - opts := &createContainerOptions{ - name: "init-" + allocID, - config: &container.Config{ - Image: networkInfraImage, - Hostname: hostname, - }, - host: &container.HostConfig{ - NetworkMode: container.NetworkMode(d.networkName), - }, - network: &network.NetworkingConfig{ - EndpointsConfig: map[string]*network.EndpointSettings{ - d.networkName: { - Aliases: dnsAlias, - }, - }, - }, - } - - specFromContainer := func(container *types.ContainerJSON) *structs.NetworkSpec { - // resolve the ip - var ip string - for _, net := range container.NetworkSettings.Networks { - if net.IPAddress == "" { - // Ignore networks without an IP address - continue - } - - ip = net.IPAddress - break - } - return &structs.NetworkSpec{Id: container.ID, Ip: ip} - } - - container, err := d.containerByName(opts.name) - if err != nil { - return nil, false, err - } - if container != nil { - // the network for this allocation is already available - return specFromContainer(container), false, nil - } - - body, err := d.client.ContainerCreate(context.Background(), opts.config, opts.host, opts.network, nil, opts.name) - if err != nil { - return nil, false, err - } - if err := d.client.ContainerStart(context.Background(), body.ID, types.ContainerStartOptions{}); err != nil { - return nil, false, err - } - - res, err := d.client.ContainerInspect(context.Background(), body.ID) - if err != nil { - return nil, false, err - } - return specFromContainer(&res), true, nil -} - -func (d *Docker) DestroyNetwork(spec *structs.NetworkSpec) error { - if err := d.client.ContainerRemove(context.Background(), spec.Id, types.ContainerRemoveOptions{Force: true}); err != nil { - return err - } - return nil -} diff --git a/internal/client/runner/docker/network_test.go b/internal/client/runner/docker/network_test.go deleted file mode 100644 index 6f3a031..0000000 --- a/internal/client/runner/docker/network_test.go +++ /dev/null @@ -1,138 +0,0 @@ -package docker - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/umbracle/vesta/internal/client/runner/driver" - proto "github.com/umbracle/vesta/internal/client/runner/structs" - "github.com/umbracle/vesta/internal/uuid" -) - -func TestNetwork_CreateSameNetwork(t *testing.T) { - allocName := "test-same-network" - - d := NewTestDockerDriver(t) - - spec, created, err := d.CreateNetwork(allocName, []string{}, "b") - require.NoError(t, err) - require.True(t, created) - - spec2, created, err := d.CreateNetwork(allocName, []string{}, "b") - require.NoError(t, err) - require.False(t, created) - - require.Equal(t, spec.Id, spec2.Id) - - d.DestroyNetwork(spec) -} - -func TestNetwork_Destroy(t *testing.T) { - allocName := "test-destroy" - - d := NewTestDockerDriver(t) - - spec, created, err := d.CreateNetwork(allocName, []string{}, "b") - require.NoError(t, err) - require.True(t, created) - - err = d.DestroyNetwork(spec) - require.NoError(t, err) - - spec2, created, err := d.CreateNetwork(allocName, []string{}, "b") - require.NoError(t, err) - require.True(t, created) - - require.NotEqual(t, spec.Id, spec2.Id) - - d.DestroyNetwork(spec2) -} - -func TestNetwork_MultipleContainers(t *testing.T) { - // test that we can deploy a container in the network and has - // the same network ip. - allocName := "test-multiple" - - d := NewTestDockerDriver(t) - - spec, _, err := d.CreateNetwork(allocName, []string{}, "b") - require.NoError(t, err) - - t0 := &driver.Task{ - AllocID: allocName, - Network: spec, - Task: &proto.Task{ - Image: "busybox", - Tag: "1.29.3", - Args: []string{"nc", "-l", "-p", "3000", "0.0.0.0"}, - }, - } - - handle, err := d.StartTask(t0) - assert.NoError(t, err) - - d.DestroyTask(handle.Id, true) - d.DestroyNetwork(spec) - - // ip of the handle and the network - require.Equal(t, spec.Ip, handle.Network.Ip) -} - -func TestNetwork_ResolveDNS(t *testing.T) { - // test that we can deploy two networks and connect them with dns - - // deploy two allocations of nginx, one will work as the target for the dns - // queries while the other one will generate the dns requests. - // We will deploy nginx twice since it has both an http server and curl installed - - tasks := []struct { - allocName string - extraDNS []string - }{ - { - "target-alloc", - []string{"extra"}, - }, - { - "source-alloc", - []string{}, - }, - } - - d := NewTestDockerDriver(t) - - var sourceID string - for _, tt := range tasks { - // create target nginx allocation - spec, _, err := d.CreateNetwork(tt.allocName, tt.extraDNS, "b") - require.NoError(t, err) - - t0 := &driver.Task{ - Id: uuid.Generate(), - AllocID: tt.allocName, - Network: spec, - Task: &proto.Task{Image: "nginx", Tag: "1.24.0"}, - } - - handle, err := d.StartTask(t0) - require.NoError(t, err) - - defer d.DestroyTask(handle.Id, true) - defer d.DestroyNetwork(spec) - - if tt.allocName == "source-alloc" { - sourceID = handle.Id - } - } - - paths := []string{ - "http://extra", - "http://target-alloc", - } - for _, path := range paths { - res, err := d.ExecTask(sourceID, []string{"curl", path}) - require.NoError(t, err) - require.NotEmpty(t, res.Stdout) - } -} diff --git a/internal/client/runner/docker/state.go b/internal/client/runner/docker/state.go deleted file mode 100644 index 309eba9..0000000 --- a/internal/client/runner/docker/state.go +++ /dev/null @@ -1,33 +0,0 @@ -package docker - -import ( - "sync" -) - -type taskStore struct { - store map[string]*taskHandle - lock sync.RWMutex -} - -func newTaskStore() *taskStore { - return &taskStore{store: map[string]*taskHandle{}} -} - -func (ts *taskStore) Set(id string, handle *taskHandle) { - ts.lock.Lock() - defer ts.lock.Unlock() - ts.store[id] = handle -} - -func (ts *taskStore) Get(id string) (*taskHandle, bool) { - ts.lock.RLock() - defer ts.lock.RUnlock() - t, ok := ts.store[id] - return t, ok -} - -func (ts *taskStore) Delete(id string) { - ts.lock.Lock() - defer ts.lock.Unlock() - delete(ts.store, id) -} diff --git a/internal/client/runner/docker/testing.go b/internal/client/runner/docker/testing.go deleted file mode 100644 index c8e4a23..0000000 --- a/internal/client/runner/docker/testing.go +++ /dev/null @@ -1,30 +0,0 @@ -package docker - -import ( - "context" - "testing" - - "github.com/hashicorp/go-hclog" - "github.com/stretchr/testify/require" - "github.com/umbracle/vesta/internal/uuid" -) - -func NewTestDockerDriver(t *testing.T) *Docker { - t.Helper() - - // create a custom name for the network - testingNetworkName := uuid.Generate() - - logger := hclog.New(&hclog.LoggerOptions{Level: hclog.Debug}) - d, err := NewDockerDriver(logger, testingNetworkName) - require.NoError(t, err) - - // destroy the network afterwards - t.Cleanup(func() { - if err := d.client.NetworkRemove(context.Background(), testingNetworkName); err != nil { - t.Logf("[ERROR]: failed to remove network: %s: %v", testingNetworkName, err) - } - }) - - return d -} diff --git a/internal/client/runner/driver/driver.go b/internal/client/runner/driver/driver.go deleted file mode 100644 index 66483da..0000000 --- a/internal/client/runner/driver/driver.go +++ /dev/null @@ -1,42 +0,0 @@ -package driver - -import ( - "context" - "time" - - proto "github.com/umbracle/vesta/internal/client/runner/structs" -) - -type Driver interface { - StartTask(task *Task) (*proto.TaskHandle, error) - RecoverTask(taskID string, task *proto.TaskHandle) error - WaitTask(ctx context.Context, taskID string) (<-chan *proto.ExitResult, error) - StopTask(taskID string, timeout time.Duration) error - DestroyTask(taskID string, force bool) error - CreateNetwork(allocID string, dnsAlias []string, hostname string) (*proto.NetworkSpec, bool, error) - DestroyNetwork(spec *proto.NetworkSpec) error - ExecTask(taskID string, cmd []string) (*ExecTaskResult, error) -} - -type Task struct { - Id string - - AllocID string - - Network *proto.NetworkSpec - - Mounts []*MountConfig - - *proto.Task -} - -type MountConfig struct { - TaskPath string - HostPath string -} - -type ExecTaskResult struct { - Stdout []byte - Stderr []byte - ExitCode uint64 -} diff --git a/internal/client/runner/hooks/runner_hooks.go b/internal/client/runner/hooks/runner_hooks.go deleted file mode 100644 index 4d5e069..0000000 --- a/internal/client/runner/hooks/runner_hooks.go +++ /dev/null @@ -1,15 +0,0 @@ -package hooks - -type RunnerHook interface { - Name() string -} - -type RunnerPrerunHook interface { - RunnerHook - Prerun() error -} - -type RunnerPostrunHook interface { - RunnerHook - Postrun() error -} diff --git a/internal/client/runner/hooks/task_hooks.go b/internal/client/runner/hooks/task_hooks.go deleted file mode 100644 index cadcbc5..0000000 --- a/internal/client/runner/hooks/task_hooks.go +++ /dev/null @@ -1,42 +0,0 @@ -package hooks - -import ( - "context" - - "github.com/hashicorp/go-hclog" - proto "github.com/umbracle/vesta/internal/client/runner/structs" -) - -type TaskHook interface { - Name() string -} - -type TaskHookFactory func(logger hclog.Logger, alloc *proto.Allocation, task *proto.Task) TaskHook - -type TaskPoststartHookRequest struct { - Spec *proto.TaskHandle_Network -} - -type TaskPoststartHook interface { - TaskHook - - Poststart(context.Context, *TaskPoststartHookRequest) error -} - -type TaskPrestartHookRequest struct { -} - -type TaskPrestartHook interface { - TaskHook - - Prestart(context.Context, *TaskPrestartHookRequest) error -} - -type TaskStopRequest struct { -} - -type TaskStopHook interface { - TaskHook - - Stop(context.Context, *TaskStopRequest) error -} diff --git a/internal/client/runner/mock/mock.go b/internal/client/runner/mock/mock.go deleted file mode 100644 index 8ef7d9b..0000000 --- a/internal/client/runner/mock/mock.go +++ /dev/null @@ -1,37 +0,0 @@ -package mock - -import proto "github.com/umbracle/vesta/internal/client/runner/structs" - -func Task1() *proto.Task { - return &proto.Task{ - Image: "vesta", - Tag: "latest", - Args: []string{ - "a", - }, - Env: map[string]string{ - "b": "c", - }, - } -} - -func ServiceAlloc() *proto.Allocation { - return &proto.Allocation{ - Deployment: &proto.Deployment{ - Tasks: []*proto.Task{ - { - Name: "a", - Image: "busybox", - Tag: "1.29.3", - Args: []string{"sleep", "30"}, - }, - { - Name: "b", - Image: "busybox", - Tag: "1.29.3", - Args: []string{"sleep", "30"}, - }, - }, - }, - } -} diff --git a/internal/client/runner/runner.go b/internal/client/runner/runner.go deleted file mode 100644 index 627938c..0000000 --- a/internal/client/runner/runner.go +++ /dev/null @@ -1,285 +0,0 @@ -package runner - -import ( - "io/ioutil" - "reflect" - "sync" - - "github.com/hashicorp/go-hclog" - "github.com/umbracle/vesta/internal/client/runner/allocrunner" - "github.com/umbracle/vesta/internal/client/runner/docker" - "github.com/umbracle/vesta/internal/client/runner/hooks" - "github.com/umbracle/vesta/internal/client/runner/state" - "github.com/umbracle/vesta/internal/client/runner/structs" - proto "github.com/umbracle/vesta/internal/client/runner/structs" -) - -type Config struct { - Logger hclog.Logger - Volume *HostVolume - AllocStateUpdated allocrunner.StateUpdater - State state.State - Hooks []hooks.TaskHookFactory -} - -type HostVolume struct { - Path string -} - -type Runner struct { - config *Config - logger hclog.Logger - state state.State - driver *docker.Docker - allocs map[string]*allocrunner.AllocRunner - deployments map[string]*structs.Deployment - hooks []hooks.TaskHookFactory - closeCh chan struct{} - reconcileCh chan struct{} -} - -func NewRunner(config *Config) (*Runner, error) { - logger := config.Logger - if logger == nil { - logger = hclog.NewNullLogger() - } - - if config.Volume == nil { - tmpDir, err := ioutil.TempDir("/tmp", "vesta-") - if err != nil { - return nil, err - } - config.Volume = &HostVolume{ - Path: tmpDir, - } - logger.Info("volume not set, using temporal location", "path", tmpDir) - } else { - logger.Info("volume path set", "path", config.Volume.Path) - } - - driver, err := docker.NewDockerDriver(logger, "vesta") - if err != nil { - return nil, err - } - - r := &Runner{ - logger: logger, - config: config, - driver: driver, - allocs: map[string]*allocrunner.AllocRunner{}, - hooks: config.Hooks, - closeCh: make(chan struct{}), - deployments: map[string]*proto.Deployment{}, - reconcileCh: make(chan struct{}), - } - - if err := r.initState(); err != nil { - return nil, err - } - - go r.reconcile() - - return r, nil -} - -func (r *Runner) AllocStateUpdated(alloc *proto.Allocation) { - select { - case r.reconcileCh <- struct{}{}: - default: - } - - r.config.AllocStateUpdated.AllocStateUpdated(alloc) -} - -func (r *Runner) initState() error { - if r.config.State != nil { - r.state = r.config.State - } else { - state, err := state.NewBoltdbStore("client.db") - if err != nil { - return err - } - r.state = state - } - - allocs, err := r.state.GetAllocations() - if err != nil { - return err - } - for _, alloc := range allocs { - config := &allocrunner.Config{ - Alloc: alloc, - Logger: r.logger, - State: r.state, - StateUpdater: r, - Driver: r.driver, - Hooks: r.hooks, - ClientVolumeDir: r.config.Volume.Path, - } - - handle := allocrunner.NewAllocRunner(config) - r.allocs[alloc.Deployment.Name] = handle - - if err := handle.Restore(); err != nil { - return err - } - } - - for _, a := range r.allocs { - go a.Run() - } - - return nil -} - -func (r *Runner) reconcile() { - for { - select { - case <-r.reconcileCh: - case <-r.closeCh: - return - } - - r.handleReconcile() - } -} - -func (r *Runner) handleReconcile() { - allocsByDep := map[string]*allocrunner.AllocRunner{} - for _, alloc := range r.allocs { - state := alloc.Status() - - if state.Status != proto.Allocation_Complete { - // TODO: we should fail if there are two for the same deployment - allocsByDep[alloc.Deployment().Name] = alloc - } - } - - create := []*proto.Deployment{} - remove := []*allocrunner.AllocRunner{} - - // reconcile state - for _, dep := range r.deployments { - alloc, ok := allocsByDep[dep.Name] - if !ok { - // allocation not found, create it - if dep.DesiredStatus == proto.Deployment_Run { - create = append(create, dep) - } - } else { - allocDep := alloc.Deployment() - - if dep.DesiredStatus == proto.Deployment_Stop { - if allocDep.DesiredStatus == proto.Deployment_Run { - remove = append(remove, alloc) - } - } else { - // alloc found, figure out if we need to update - if deploymentUpdated(dep, allocDep) { - // it requires an update, schedule for removal if its - // desired status is still running. Otherwise, it has been - // already scheduled for removal in a previous iteration. - if allocDep.DesiredStatus != proto.Deployment_Stop { - remove = append(remove, alloc) - } - } - } - } - } - - for _, dep := range create { - alloc := &proto.Allocation{ - Deployment: dep, - } - - if err := r.state.PutAllocation(alloc); err != nil { - panic(err) - } - - config := &allocrunner.Config{ - Alloc: alloc, - Logger: r.logger, - State: r.state, - StateUpdater: r, - Driver: r.driver, - Hooks: r.hooks, - ClientVolumeDir: r.config.Volume.Path, - } - - handle := allocrunner.NewAllocRunner(config) - - r.allocs[alloc.Deployment.Name] = handle - go handle.Run() - } - - for _, del := range remove { - deployment := del.Alloc().Copy().Deployment - deployment.DesiredStatus = proto.Deployment_Stop - - del.Update(deployment) - } -} - -func (r *Runner) UpsertDeployment(newDeployment *proto.Deployment) { - dep, ok := r.deployments[newDeployment.Name] - if ok { - if newDeployment.Sequence <= dep.Sequence { - return - } - } - - r.deployments[newDeployment.Name] = newDeployment - - select { - case r.reconcileCh <- struct{}{}: - default: - } -} - -func (r *Runner) Shutdown() error { - close(r.closeCh) - - wg := sync.WaitGroup{} - for _, tr := range r.allocs { - wg.Add(1) - go func(tr *allocrunner.AllocRunner) { - tr.Shutdown() - <-tr.ShutdownCh() - wg.Done() - }(tr) - } - wg.Wait() - - if err := r.state.Close(); err != nil { - return err - } - return nil -} - -func deploymentUpdated(newDep, oldDep *proto.Deployment) bool { - if len(newDep.Tasks) != len(oldDep.Tasks) { - return true - } - - for indx, task0 := range newDep.Tasks { - task1 := oldDep.Tasks[indx] - if tasksUpdated(task0, task1) { - return true - } - } - - return false -} - -func tasksUpdated(a, b *proto.Task) bool { - if !reflect.DeepEqual(a.Image, b.Image) { - return true - } - if !reflect.DeepEqual(a.Tag, b.Tag) { - return true - } - if !reflect.DeepEqual(a.Args, b.Args) { - return true - } - return false -} diff --git a/internal/client/runner/runner_test.go b/internal/client/runner/runner_test.go deleted file mode 100644 index 024de2c..0000000 --- a/internal/client/runner/runner_test.go +++ /dev/null @@ -1,103 +0,0 @@ -package runner - -import ( - "fmt" - "testing" - "time" - - "github.com/hashicorp/go-hclog" - "github.com/stretchr/testify/require" - "github.com/umbracle/vesta/internal/client/runner/mock" - "github.com/umbracle/vesta/internal/client/runner/state" - proto "github.com/umbracle/vesta/internal/client/runner/structs" - "github.com/umbracle/vesta/internal/testutil" -) - -func newTestRunner(t *testing.T) *Runner { - config := &Config{ - Logger: hclog.New(&hclog.LoggerOptions{Level: hclog.Info}), - State: state.NewInmemStore(t), - AllocStateUpdated: &updater{}, - } - - r, err := NewRunner(config) - require.NoError(t, err) - - time.Sleep(1 * time.Second) - return r -} - -type updater struct { - alloc *proto.Allocation -} - -func (u *updater) AllocStateUpdated(alloc *proto.Allocation) { - u.alloc = alloc -} - -func TestRunner_SimpleRun(t *testing.T) { - r := newTestRunner(t) - updater := r.config.AllocStateUpdated.(*updater) - - dep := mock.ServiceAlloc().Deployment - dep.Name = "a" - - r.UpsertDeployment(dep) - - testutil.WaitForResult(func() (bool, error) { - last := updater.alloc - if last == nil { - return false, fmt.Errorf("no updates") - } - if last.Status != proto.Allocation_Running { - return false, fmt.Errorf("alloc not running") - } - - return true, nil - }, func(err error) { - t.Fatalf("err: %v", err) - }) - - dep1 := dep.Copy() - dep1.Sequence = dep.Sequence + 1 - dep1.Tasks = []*proto.Task{dep.Tasks[0]} - - r.UpsertDeployment(dep1) - - testutil.WaitForResult(func() (bool, error) { - last := updater.alloc - if last == nil { - return false, fmt.Errorf("no updates") - } - if last.Status != proto.Allocation_Running { - return false, fmt.Errorf("alloc not running") - } - if len(last.TaskStates) != 1 { - return false, fmt.Errorf("only one task expected") - } - - return true, nil - }, func(err error) { - t.Fatalf("err: %v", err) - }) - - dep2 := dep1.Copy() - dep2.Sequence = dep1.Sequence + 1 - dep2.DesiredStatus = proto.Deployment_Stop - - r.UpsertDeployment(dep2) - - testutil.WaitForResult(func() (bool, error) { - last := updater.alloc - if last == nil { - return false, fmt.Errorf("no updates") - } - if last.Status != proto.Allocation_Complete { - return false, fmt.Errorf("alloc not complete") - } - - return true, nil - }, func(err error) { - t.Fatalf("err: %v", err) - }) -} diff --git a/internal/client/runner/state/boltdb.go b/internal/client/runner/state/boltdb.go deleted file mode 100644 index ad955a6..0000000 --- a/internal/client/runner/state/boltdb.go +++ /dev/null @@ -1,218 +0,0 @@ -package state - -import ( - "fmt" - - "github.com/boltdb/bolt" - gproto "github.com/golang/protobuf/proto" - proto "github.com/umbracle/vesta/internal/client/runner/structs" -) - -var _ State = &BoltdbStore{} - -var ( - allocsBucket = []byte("allocs") - - allocKey = []byte("alloc") - - taskSpecKey = []byte("task-spec") - - taskStateKey = []byte("task-state") - - taskHandleKey = []byte("task-handle") -) - -func taskKey(name string) []byte { - return []byte("task-" + name) -} - -type BoltdbStore struct { - db *bolt.DB -} - -func NewBoltdbStore(path string) (*BoltdbStore, error) { - db, err := bolt.Open(path, 0755, &bolt.Options{}) - if err != nil { - return nil, err - } - - return NewBoltdbStoreWithDB(db) -} - -func NewBoltdbStoreWithDB(db *bolt.DB) (*BoltdbStore, error) { - err := db.Update(func(tx *bolt.Tx) error { - buckets := [][]byte{ - allocsBucket, - } - for _, bkt := range buckets { - if _, err := tx.CreateBucketIfNotExists(bkt); err != nil { - return err - } - } - return nil - }) - if err != nil { - return nil, err - } - - s := &BoltdbStore{ - db: db, - } - return s, nil -} - -func (s *BoltdbStore) DeleteAllocationBucket(allocID string) error { - err := s.db.Update(func(tx *bolt.Tx) error { - allocsBkt := tx.Bucket(allocsBucket) - - return allocsBkt.DeleteBucket([]byte(allocID)) - }) - if err != nil { - return err - } - return nil -} - -func (s *BoltdbStore) PutAllocation(a *proto.Allocation) error { - err := s.db.Update(func(tx *bolt.Tx) error { - allocsBkt := tx.Bucket(allocsBucket) - - bkt, err := allocsBkt.CreateBucketIfNotExists([]byte(a.Deployment.Name)) - if err != nil { - return err - } - if err := dbPut(bkt, allocKey, a); err != nil { - return err - } - return nil - }) - if err != nil { - return err - } - return nil -} - -func (s *BoltdbStore) GetAllocations() ([]*proto.Allocation, error) { - allocs := []*proto.Allocation{} - s.db.View(func(tx *bolt.Tx) error { - allocsBkt := tx.Bucket(allocsBucket) - - c := allocsBkt.Cursor() - for k, _ := c.First(); k != nil; k, _ = c.Next() { - allocBkt := allocsBkt.Bucket(k) - - alloc := proto.Allocation{} - if err := dbGet(allocBkt, allocKey, &alloc); err != nil { - return err - } - allocs = append(allocs, &alloc) - } - return nil - }) - return allocs, nil -} - -func (s *BoltdbStore) GetTaskState(allocID, taskName string) (*proto.TaskState, *proto.TaskHandle, error) { - state := proto.TaskState{} - handle := proto.TaskHandle{} - - err := s.db.View(func(tx *bolt.Tx) error { - allocsBkt := tx.Bucket(allocsBucket) - - allocBkt := allocsBkt.Bucket([]byte(allocID)) - if allocBkt == nil { - return fmt.Errorf("alloc '%s' not found", allocID) - } - - taskBkt := allocBkt.Bucket(taskKey(taskName)) - if taskBkt == nil { - return fmt.Errorf("task '%s' not found", taskName) - } - if err := dbGet(taskBkt, taskStateKey, &state); err != nil { - return fmt.Errorf("failed to get task state '%s' '%s'", allocID, taskName) - } - if err := dbGet(taskBkt, taskHandleKey, &handle); err != nil { - return fmt.Errorf("failed to get handle '%s' '%s'", allocID, taskName) - } - return nil - }) - if err != nil { - return nil, nil, fmt.Errorf("failed to get task state %v", err) - } - - return &state, &handle, nil -} - -func (s *BoltdbStore) PutTaskLocalState(allocID string, taskName string, handle *proto.TaskHandle) error { - err := s.db.Update(func(tx *bolt.Tx) error { - allocsBkt := tx.Bucket(allocsBucket) - - allocBkt := allocsBkt.Bucket([]byte(allocID)) - if allocBkt == nil { - return fmt.Errorf("alloc '%s' not found", allocID) - } - - taskBkt, err := allocBkt.CreateBucketIfNotExists(taskKey(taskName)) - if err != nil { - return err - } - if err := dbPut(taskBkt, taskHandleKey, handle); err != nil { - return fmt.Errorf("failed to get handle %s %s", allocID, taskName) - } - return nil - }) - if err != nil { - return err - } - return nil -} - -func (s *BoltdbStore) PutTaskState(allocID string, taskName string, state *proto.TaskState) error { - err := s.db.Update(func(tx *bolt.Tx) error { - allocsBkt := tx.Bucket(allocsBucket) - - allocBkt := allocsBkt.Bucket([]byte(allocID)) - if allocBkt == nil { - return fmt.Errorf("alloc '%s' not found", allocID) - } - - taskBkt, err := allocBkt.CreateBucketIfNotExists(taskKey(taskName)) - if err != nil { - return err - } - if err := dbPut(taskBkt, taskStateKey, state); err != nil { - return fmt.Errorf("failed to get task state '%s' '%s'", allocID, taskName) - } - return nil - }) - if err != nil { - return fmt.Errorf("failed to put task state: %v", err) - } - return nil -} - -func (s *BoltdbStore) Close() error { - return s.db.Close() -} - -func dbPut(bkt *bolt.Bucket, key []byte, obj gproto.Message) error { - raw, err := gproto.Marshal(obj) - if err != nil { - return err - } - if err := bkt.Put(key, raw); err != nil { - return err - } - return nil -} - -func dbGet(bkt *bolt.Bucket, key []byte, obj gproto.Message) error { - raw := bkt.Get(key) - if raw == nil { - return fmt.Errorf("not exists") - } - if err := gproto.Unmarshal(raw, obj); err != nil { - return err - } - return nil -} diff --git a/internal/client/runner/state/state.go b/internal/client/runner/state/state.go deleted file mode 100644 index e706d08..0000000 --- a/internal/client/runner/state/state.go +++ /dev/null @@ -1,13 +0,0 @@ -package state - -import proto "github.com/umbracle/vesta/internal/client/runner/structs" - -type State interface { - PutTaskLocalState(allocID string, taskName string, handle *proto.TaskHandle) error - GetTaskState(allocID, taskName string) (*proto.TaskState, *proto.TaskHandle, error) - PutTaskState(allocID string, taskName string, state *proto.TaskState) error - GetAllocations() ([]*proto.Allocation, error) - PutAllocation(a *proto.Allocation) error - DeleteAllocationBucket(allocId string) error - Close() error -} diff --git a/internal/client/runner/state/testing.go b/internal/client/runner/state/testing.go deleted file mode 100644 index 668ffdd..0000000 --- a/internal/client/runner/state/testing.go +++ /dev/null @@ -1,24 +0,0 @@ -package state - -import ( - "io/ioutil" - "os" - "path/filepath" - "testing" - - "github.com/stretchr/testify/assert" -) - -func NewInmemStore(t *testing.T) *BoltdbStore { - tmpDir, err := ioutil.TempDir("/tmp", "task-runner-") - assert.NoError(t, err) - - state, err := NewBoltdbStore(filepath.Join(tmpDir, "my.db")) - assert.NoError(t, err) - - t.Cleanup(func() { - os.RemoveAll(tmpDir) - }) - - return state -} diff --git a/internal/client/runner/structs/runner.pb.go b/internal/client/runner/structs/runner.pb.go deleted file mode 100644 index af7d9ea..0000000 --- a/internal/client/runner/structs/runner.pb.go +++ /dev/null @@ -1,1330 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0 -// protoc v3.12.0 -// source: internal/client/runner/structs/runner.proto - -package structs - -import ( - proto "github.com/golang/protobuf/proto" - timestamp "github.com/golang/protobuf/ptypes/timestamp" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -type Deployment_DesiredStatus int32 - -const ( - Deployment_Run Deployment_DesiredStatus = 0 - Deployment_Stop Deployment_DesiredStatus = 1 -) - -// Enum value maps for Deployment_DesiredStatus. -var ( - Deployment_DesiredStatus_name = map[int32]string{ - 0: "Run", - 1: "Stop", - } - Deployment_DesiredStatus_value = map[string]int32{ - "Run": 0, - "Stop": 1, - } -) - -func (x Deployment_DesiredStatus) Enum() *Deployment_DesiredStatus { - p := new(Deployment_DesiredStatus) - *p = x - return p -} - -func (x Deployment_DesiredStatus) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Deployment_DesiredStatus) Descriptor() protoreflect.EnumDescriptor { - return file_internal_client_runner_structs_runner_proto_enumTypes[0].Descriptor() -} - -func (Deployment_DesiredStatus) Type() protoreflect.EnumType { - return &file_internal_client_runner_structs_runner_proto_enumTypes[0] -} - -func (x Deployment_DesiredStatus) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Deployment_DesiredStatus.Descriptor instead. -func (Deployment_DesiredStatus) EnumDescriptor() ([]byte, []int) { - return file_internal_client_runner_structs_runner_proto_rawDescGZIP(), []int{1, 0} -} - -type Allocation_Status int32 - -const ( - Allocation_Unknown Allocation_Status = 0 - Allocation_Pending Allocation_Status = 1 - Allocation_Running Allocation_Status = 2 - Allocation_Complete Allocation_Status = 3 - Allocation_Failed Allocation_Status = 4 -) - -// Enum value maps for Allocation_Status. -var ( - Allocation_Status_name = map[int32]string{ - 0: "Unknown", - 1: "Pending", - 2: "Running", - 3: "Complete", - 4: "Failed", - } - Allocation_Status_value = map[string]int32{ - "Unknown": 0, - "Pending": 1, - "Running": 2, - "Complete": 3, - "Failed": 4, - } -) - -func (x Allocation_Status) Enum() *Allocation_Status { - p := new(Allocation_Status) - *p = x - return p -} - -func (x Allocation_Status) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Allocation_Status) Descriptor() protoreflect.EnumDescriptor { - return file_internal_client_runner_structs_runner_proto_enumTypes[1].Descriptor() -} - -func (Allocation_Status) Type() protoreflect.EnumType { - return &file_internal_client_runner_structs_runner_proto_enumTypes[1] -} - -func (x Allocation_Status) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Allocation_Status.Descriptor instead. -func (Allocation_Status) EnumDescriptor() ([]byte, []int) { - return file_internal_client_runner_structs_runner_proto_rawDescGZIP(), []int{3, 0} -} - -type TaskState_State int32 - -const ( - TaskState_Pending TaskState_State = 0 - TaskState_Running TaskState_State = 1 - TaskState_Dead TaskState_State = 2 -) - -// Enum value maps for TaskState_State. -var ( - TaskState_State_name = map[int32]string{ - 0: "Pending", - 1: "Running", - 2: "Dead", - } - TaskState_State_value = map[string]int32{ - "Pending": 0, - "Running": 1, - "Dead": 2, - } -) - -func (x TaskState_State) Enum() *TaskState_State { - p := new(TaskState_State) - *p = x - return p -} - -func (x TaskState_State) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (TaskState_State) Descriptor() protoreflect.EnumDescriptor { - return file_internal_client_runner_structs_runner_proto_enumTypes[2].Descriptor() -} - -func (TaskState_State) Type() protoreflect.EnumType { - return &file_internal_client_runner_structs_runner_proto_enumTypes[2] -} - -func (x TaskState_State) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use TaskState_State.Descriptor instead. -func (TaskState_State) EnumDescriptor() ([]byte, []int) { - return file_internal_client_runner_structs_runner_proto_rawDescGZIP(), []int{4, 0} -} - -type ExitResult struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ExitCode int64 `protobuf:"varint,1,opt,name=exitCode,proto3" json:"exitCode,omitempty"` - Signal int64 `protobuf:"varint,2,opt,name=signal,proto3" json:"signal,omitempty"` - OomKiller bool `protobuf:"varint,3,opt,name=oomKiller,proto3" json:"oomKiller,omitempty"` - Err string `protobuf:"bytes,4,opt,name=err,proto3" json:"err,omitempty"` -} - -func (x *ExitResult) Reset() { - *x = ExitResult{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ExitResult) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ExitResult) ProtoMessage() {} - -func (x *ExitResult) ProtoReflect() protoreflect.Message { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ExitResult.ProtoReflect.Descriptor instead. -func (*ExitResult) Descriptor() ([]byte, []int) { - return file_internal_client_runner_structs_runner_proto_rawDescGZIP(), []int{0} -} - -func (x *ExitResult) GetExitCode() int64 { - if x != nil { - return x.ExitCode - } - return 0 -} - -func (x *ExitResult) GetSignal() int64 { - if x != nil { - return x.Signal - } - return 0 -} - -func (x *ExitResult) GetOomKiller() bool { - if x != nil { - return x.OomKiller - } - return false -} - -func (x *ExitResult) GetErr() string { - if x != nil { - return x.Err - } - return "" -} - -type Deployment struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Tasks []*Task `protobuf:"bytes,2,rep,name=tasks,proto3" json:"tasks,omitempty"` - Sequence int64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"` - DesiredStatus Deployment_DesiredStatus `protobuf:"varint,7,opt,name=desiredStatus,proto3,enum=structs.Deployment_DesiredStatus" json:"desiredStatus,omitempty"` - Alias string `protobuf:"bytes,4,opt,name=alias,proto3" json:"alias,omitempty"` -} - -func (x *Deployment) Reset() { - *x = Deployment{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Deployment) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Deployment) ProtoMessage() {} - -func (x *Deployment) ProtoReflect() protoreflect.Message { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Deployment.ProtoReflect.Descriptor instead. -func (*Deployment) Descriptor() ([]byte, []int) { - return file_internal_client_runner_structs_runner_proto_rawDescGZIP(), []int{1} -} - -func (x *Deployment) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Deployment) GetTasks() []*Task { - if x != nil { - return x.Tasks - } - return nil -} - -func (x *Deployment) GetSequence() int64 { - if x != nil { - return x.Sequence - } - return 0 -} - -func (x *Deployment) GetDesiredStatus() Deployment_DesiredStatus { - if x != nil { - return x.DesiredStatus - } - return Deployment_Run -} - -func (x *Deployment) GetAlias() string { - if x != nil { - return x.Alias - } - return "" -} - -type Task struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Image string `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"` - Tag string `protobuf:"bytes,2,opt,name=tag,proto3" json:"tag,omitempty"` - Args []string `protobuf:"bytes,3,rep,name=args,proto3" json:"args,omitempty"` - Env map[string]string `protobuf:"bytes,4,rep,name=env,proto3" json:"env,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Labels map[string]string `protobuf:"bytes,5,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - SecurityOpt []string `protobuf:"bytes,7,rep,name=securityOpt,proto3" json:"securityOpt,omitempty"` - Name string `protobuf:"bytes,8,opt,name=name,proto3" json:"name,omitempty"` - Data map[string]string `protobuf:"bytes,9,rep,name=data,proto3" json:"data,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Volumes map[string]*Task_Volume `protobuf:"bytes,11,rep,name=volumes,proto3" json:"volumes,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Artifacts []*Task_Artifact `protobuf:"bytes,12,rep,name=artifacts,proto3" json:"artifacts,omitempty"` - Batch bool `protobuf:"varint,15,opt,name=batch,proto3" json:"batch,omitempty"` - Metadata map[string]string `protobuf:"bytes,16,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (x *Task) Reset() { - *x = Task{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Task) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Task) ProtoMessage() {} - -func (x *Task) ProtoReflect() protoreflect.Message { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Task.ProtoReflect.Descriptor instead. -func (*Task) Descriptor() ([]byte, []int) { - return file_internal_client_runner_structs_runner_proto_rawDescGZIP(), []int{2} -} - -func (x *Task) GetImage() string { - if x != nil { - return x.Image - } - return "" -} - -func (x *Task) GetTag() string { - if x != nil { - return x.Tag - } - return "" -} - -func (x *Task) GetArgs() []string { - if x != nil { - return x.Args - } - return nil -} - -func (x *Task) GetEnv() map[string]string { - if x != nil { - return x.Env - } - return nil -} - -func (x *Task) GetLabels() map[string]string { - if x != nil { - return x.Labels - } - return nil -} - -func (x *Task) GetSecurityOpt() []string { - if x != nil { - return x.SecurityOpt - } - return nil -} - -func (x *Task) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Task) GetData() map[string]string { - if x != nil { - return x.Data - } - return nil -} - -func (x *Task) GetVolumes() map[string]*Task_Volume { - if x != nil { - return x.Volumes - } - return nil -} - -func (x *Task) GetArtifacts() []*Task_Artifact { - if x != nil { - return x.Artifacts - } - return nil -} - -func (x *Task) GetBatch() bool { - if x != nil { - return x.Batch - } - return false -} - -func (x *Task) GetMetadata() map[string]string { - if x != nil { - return x.Metadata - } - return nil -} - -type Allocation struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Deployment *Deployment `protobuf:"bytes,2,opt,name=deployment,proto3" json:"deployment,omitempty"` - TaskStates map[string]*TaskState `protobuf:"bytes,3,rep,name=taskStates,proto3" json:"taskStates,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Status Allocation_Status `protobuf:"varint,6,opt,name=status,proto3,enum=structs.Allocation_Status" json:"status,omitempty"` - NetworkSpec *NetworkSpec `protobuf:"bytes,8,opt,name=networkSpec,proto3" json:"networkSpec,omitempty"` -} - -func (x *Allocation) Reset() { - *x = Allocation{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Allocation) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Allocation) ProtoMessage() {} - -func (x *Allocation) ProtoReflect() protoreflect.Message { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Allocation.ProtoReflect.Descriptor instead. -func (*Allocation) Descriptor() ([]byte, []int) { - return file_internal_client_runner_structs_runner_proto_rawDescGZIP(), []int{3} -} - -func (x *Allocation) GetDeployment() *Deployment { - if x != nil { - return x.Deployment - } - return nil -} - -func (x *Allocation) GetTaskStates() map[string]*TaskState { - if x != nil { - return x.TaskStates - } - return nil -} - -func (x *Allocation) GetStatus() Allocation_Status { - if x != nil { - return x.Status - } - return Allocation_Unknown -} - -func (x *Allocation) GetNetworkSpec() *NetworkSpec { - if x != nil { - return x.NetworkSpec - } - return nil -} - -type TaskState struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - State TaskState_State `protobuf:"varint,1,opt,name=state,proto3,enum=structs.TaskState_State" json:"state,omitempty"` - Failed bool `protobuf:"varint,2,opt,name=failed,proto3" json:"failed,omitempty"` - Restarts uint64 `protobuf:"varint,3,opt,name=restarts,proto3" json:"restarts,omitempty"` - Events []*TaskState_Event `protobuf:"bytes,5,rep,name=events,proto3" json:"events,omitempty"` - Id string `protobuf:"bytes,6,opt,name=id,proto3" json:"id,omitempty"` - Killing bool `protobuf:"varint,7,opt,name=killing,proto3" json:"killing,omitempty"` -} - -func (x *TaskState) Reset() { - *x = TaskState{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *TaskState) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TaskState) ProtoMessage() {} - -func (x *TaskState) ProtoReflect() protoreflect.Message { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use TaskState.ProtoReflect.Descriptor instead. -func (*TaskState) Descriptor() ([]byte, []int) { - return file_internal_client_runner_structs_runner_proto_rawDescGZIP(), []int{4} -} - -func (x *TaskState) GetState() TaskState_State { - if x != nil { - return x.State - } - return TaskState_Pending -} - -func (x *TaskState) GetFailed() bool { - if x != nil { - return x.Failed - } - return false -} - -func (x *TaskState) GetRestarts() uint64 { - if x != nil { - return x.Restarts - } - return 0 -} - -func (x *TaskState) GetEvents() []*TaskState_Event { - if x != nil { - return x.Events - } - return nil -} - -func (x *TaskState) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *TaskState) GetKilling() bool { - if x != nil { - return x.Killing - } - return false -} - -type TaskHandle struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ContainerID string `protobuf:"bytes,1,opt,name=containerID,proto3" json:"containerID,omitempty"` - Network *TaskHandle_Network `protobuf:"bytes,2,opt,name=network,proto3" json:"network,omitempty"` - Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"` -} - -func (x *TaskHandle) Reset() { - *x = TaskHandle{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *TaskHandle) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TaskHandle) ProtoMessage() {} - -func (x *TaskHandle) ProtoReflect() protoreflect.Message { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use TaskHandle.ProtoReflect.Descriptor instead. -func (*TaskHandle) Descriptor() ([]byte, []int) { - return file_internal_client_runner_structs_runner_proto_rawDescGZIP(), []int{5} -} - -func (x *TaskHandle) GetContainerID() string { - if x != nil { - return x.ContainerID - } - return "" -} - -func (x *TaskHandle) GetNetwork() *TaskHandle_Network { - if x != nil { - return x.Network - } - return nil -} - -func (x *TaskHandle) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -type NetworkSpec struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Ip string `protobuf:"bytes,2,opt,name=ip,proto3" json:"ip,omitempty"` -} - -func (x *NetworkSpec) Reset() { - *x = NetworkSpec{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *NetworkSpec) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*NetworkSpec) ProtoMessage() {} - -func (x *NetworkSpec) ProtoReflect() protoreflect.Message { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use NetworkSpec.ProtoReflect.Descriptor instead. -func (*NetworkSpec) Descriptor() ([]byte, []int) { - return file_internal_client_runner_structs_runner_proto_rawDescGZIP(), []int{6} -} - -func (x *NetworkSpec) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *NetworkSpec) GetIp() string { - if x != nil { - return x.Ip - } - return "" -} - -type Task_Volume struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` -} - -func (x *Task_Volume) Reset() { - *x = Task_Volume{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Task_Volume) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Task_Volume) ProtoMessage() {} - -func (x *Task_Volume) ProtoReflect() protoreflect.Message { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[12] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Task_Volume.ProtoReflect.Descriptor instead. -func (*Task_Volume) Descriptor() ([]byte, []int) { - return file_internal_client_runner_structs_runner_proto_rawDescGZIP(), []int{2, 5} -} - -func (x *Task_Volume) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -type Task_Artifact struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Source string `protobuf:"bytes,1,opt,name=source,proto3" json:"source,omitempty"` - Destination string `protobuf:"bytes,2,opt,name=destination,proto3" json:"destination,omitempty"` -} - -func (x *Task_Artifact) Reset() { - *x = Task_Artifact{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Task_Artifact) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Task_Artifact) ProtoMessage() {} - -func (x *Task_Artifact) ProtoReflect() protoreflect.Message { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[13] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Task_Artifact.ProtoReflect.Descriptor instead. -func (*Task_Artifact) Descriptor() ([]byte, []int) { - return file_internal_client_runner_structs_runner_proto_rawDescGZIP(), []int{2, 6} -} - -func (x *Task_Artifact) GetSource() string { - if x != nil { - return x.Source - } - return "" -} - -func (x *Task_Artifact) GetDestination() string { - if x != nil { - return x.Destination - } - return "" -} - -type TaskState_Event struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - Details map[string]string `protobuf:"bytes,2,rep,name=details,proto3" json:"details,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Time *timestamp.Timestamp `protobuf:"bytes,3,opt,name=time,proto3" json:"time,omitempty"` -} - -func (x *TaskState_Event) Reset() { - *x = TaskState_Event{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *TaskState_Event) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TaskState_Event) ProtoMessage() {} - -func (x *TaskState_Event) ProtoReflect() protoreflect.Message { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[15] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use TaskState_Event.ProtoReflect.Descriptor instead. -func (*TaskState_Event) Descriptor() ([]byte, []int) { - return file_internal_client_runner_structs_runner_proto_rawDescGZIP(), []int{4, 0} -} - -func (x *TaskState_Event) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *TaskState_Event) GetDetails() map[string]string { - if x != nil { - return x.Details - } - return nil -} - -func (x *TaskState_Event) GetTime() *timestamp.Timestamp { - if x != nil { - return x.Time - } - return nil -} - -type TaskHandle_Network struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Ip string `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"` -} - -func (x *TaskHandle_Network) Reset() { - *x = TaskHandle_Network{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *TaskHandle_Network) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TaskHandle_Network) ProtoMessage() {} - -func (x *TaskHandle_Network) ProtoReflect() protoreflect.Message { - mi := &file_internal_client_runner_structs_runner_proto_msgTypes[17] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use TaskHandle_Network.ProtoReflect.Descriptor instead. -func (*TaskHandle_Network) Descriptor() ([]byte, []int) { - return file_internal_client_runner_structs_runner_proto_rawDescGZIP(), []int{5, 0} -} - -func (x *TaskHandle_Network) GetIp() string { - if x != nil { - return x.Ip - } - return "" -} - -var File_internal_client_runner_structs_runner_proto protoreflect.FileDescriptor - -var file_internal_client_runner_structs_runner_proto_rawDesc = []byte{ - 0x0a, 0x2b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x2f, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x73, - 0x2f, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x73, - 0x74, 0x72, 0x75, 0x63, 0x74, 0x73, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x70, 0x0a, 0x0a, 0x45, 0x78, 0x69, 0x74, 0x52, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x78, 0x69, 0x74, 0x43, 0x6f, 0x64, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x65, 0x78, 0x69, 0x74, 0x43, 0x6f, 0x64, - 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x6f, 0x6f, 0x6d, - 0x4b, 0x69, 0x6c, 0x6c, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x6f, 0x6f, - 0x6d, 0x4b, 0x69, 0x6c, 0x6c, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0xe4, 0x01, 0x0a, 0x0a, 0x44, 0x65, - 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x05, - 0x74, 0x61, 0x73, 0x6b, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x73, 0x74, - 0x72, 0x75, 0x63, 0x74, 0x73, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x05, 0x74, 0x61, 0x73, 0x6b, - 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x47, 0x0a, - 0x0d, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x21, 0x2e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x73, 0x2e, 0x44, - 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x44, 0x65, 0x73, 0x69, 0x72, 0x65, - 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0d, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x22, 0x22, 0x0a, 0x0d, - 0x44, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x07, 0x0a, - 0x03, 0x52, 0x75, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x74, 0x6f, 0x70, 0x10, 0x01, - 0x22, 0xdc, 0x06, 0x0a, 0x04, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6d, 0x61, - 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x12, - 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, - 0x67, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x72, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x04, 0x61, 0x72, 0x67, 0x73, 0x12, 0x28, 0x0a, 0x03, 0x65, 0x6e, 0x76, 0x18, 0x04, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x73, 0x2e, 0x54, 0x61, 0x73, - 0x6b, 0x2e, 0x45, 0x6e, 0x76, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x03, 0x65, 0x6e, 0x76, 0x12, - 0x31, 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x19, 0x2e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x73, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x2e, 0x4c, - 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, - 0x6c, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x4f, 0x70, - 0x74, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, - 0x79, 0x4f, 0x70, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, - 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x73, - 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x34, 0x0a, 0x07, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, - 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x73, - 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x52, 0x07, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x12, 0x34, 0x0a, 0x09, 0x61, - 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, - 0x2e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x73, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x2e, 0x41, 0x72, - 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x09, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, - 0x73, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x61, 0x74, 0x63, 0x68, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x05, 0x62, 0x61, 0x74, 0x63, 0x68, 0x12, 0x37, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0x18, 0x10, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x74, 0x72, 0x75, - 0x63, 0x74, 0x73, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x1a, 0x36, 0x0a, 0x08, 0x45, 0x6e, 0x76, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, - 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, - 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x39, 0x0a, 0x0b, 0x4c, 0x61, 0x62, 0x65, - 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, - 0x02, 0x38, 0x01, 0x1a, 0x37, 0x0a, 0x09, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x50, 0x0a, 0x0c, - 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, - 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2a, - 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, - 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x73, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x2e, 0x56, 0x6f, 0x6c, - 0x75, 0x6d, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3b, - 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, - 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, - 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x1c, 0x0a, 0x06, 0x56, - 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x1a, 0x44, 0x0a, 0x08, 0x41, 0x72, 0x74, - 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x20, 0x0a, - 0x0b, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, - 0x90, 0x03, 0x0a, 0x0a, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x33, - 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x73, 0x2e, 0x44, 0x65, 0x70, - 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, - 0x65, 0x6e, 0x74, 0x12, 0x43, 0x0a, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, - 0x73, 0x2e, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x54, 0x61, 0x73, - 0x6b, 0x53, 0x74, 0x61, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x74, 0x61, - 0x73, 0x6b, 0x53, 0x74, 0x61, 0x74, 0x65, 0x73, 0x12, 0x32, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x73, 0x74, 0x72, 0x75, 0x63, - 0x74, 0x73, 0x2e, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x36, 0x0a, 0x0b, - 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x53, 0x70, 0x65, 0x63, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x14, 0x2e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x73, 0x2e, 0x4e, 0x65, 0x74, 0x77, - 0x6f, 0x72, 0x6b, 0x53, 0x70, 0x65, 0x63, 0x52, 0x0b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x53, 0x70, 0x65, 0x63, 0x1a, 0x51, 0x0a, 0x0f, 0x54, 0x61, 0x73, 0x6b, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x28, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x74, 0x72, 0x75, 0x63, - 0x74, 0x73, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x49, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0b, - 0x0a, 0x07, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x52, - 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x6f, 0x6d, 0x70, - 0x6c, 0x65, 0x74, 0x65, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, - 0x10, 0x04, 0x22, 0xc3, 0x03, 0x0a, 0x09, 0x54, 0x61, 0x73, 0x6b, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x12, 0x2e, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x18, 0x2e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x73, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, - 0x12, 0x16, 0x0a, 0x06, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x06, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x74, - 0x61, 0x72, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x72, 0x65, 0x73, 0x74, - 0x61, 0x72, 0x74, 0x73, 0x12, 0x30, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x05, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x73, 0x2e, 0x54, - 0x61, 0x73, 0x6b, 0x53, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, - 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6b, 0x69, 0x6c, 0x6c, 0x69, 0x6e, - 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6b, 0x69, 0x6c, 0x6c, 0x69, 0x6e, 0x67, - 0x1a, 0xc8, 0x01, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x3f, - 0x0a, 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x25, 0x2e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x73, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, - 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x1a, - 0x3a, 0x0a, 0x0c, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, - 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, - 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x2b, 0x0a, 0x05, 0x53, - 0x74, 0x61, 0x74, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x10, - 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x10, 0x01, 0x12, 0x08, - 0x0a, 0x04, 0x44, 0x65, 0x61, 0x64, 0x10, 0x02, 0x22, 0x90, 0x01, 0x0a, 0x0a, 0x54, 0x61, 0x73, - 0x6b, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x61, - 0x69, 0x6e, 0x65, 0x72, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, - 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x49, 0x44, 0x12, 0x35, 0x0a, 0x07, 0x6e, 0x65, 0x74, - 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x74, 0x72, - 0x75, 0x63, 0x74, 0x73, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x2e, - 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, - 0x1a, 0x19, 0x0a, 0x07, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x22, 0x2d, 0x0a, 0x0b, 0x4e, - 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x53, 0x70, 0x65, 0x63, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x42, 0x21, 0x5a, 0x1f, 0x2f, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x72, - 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x73, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_internal_client_runner_structs_runner_proto_rawDescOnce sync.Once - file_internal_client_runner_structs_runner_proto_rawDescData = file_internal_client_runner_structs_runner_proto_rawDesc -) - -func file_internal_client_runner_structs_runner_proto_rawDescGZIP() []byte { - file_internal_client_runner_structs_runner_proto_rawDescOnce.Do(func() { - file_internal_client_runner_structs_runner_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_client_runner_structs_runner_proto_rawDescData) - }) - return file_internal_client_runner_structs_runner_proto_rawDescData -} - -var file_internal_client_runner_structs_runner_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_internal_client_runner_structs_runner_proto_msgTypes = make([]protoimpl.MessageInfo, 18) -var file_internal_client_runner_structs_runner_proto_goTypes = []interface{}{ - (Deployment_DesiredStatus)(0), // 0: structs.Deployment.DesiredStatus - (Allocation_Status)(0), // 1: structs.Allocation.Status - (TaskState_State)(0), // 2: structs.TaskState.State - (*ExitResult)(nil), // 3: structs.ExitResult - (*Deployment)(nil), // 4: structs.Deployment - (*Task)(nil), // 5: structs.Task - (*Allocation)(nil), // 6: structs.Allocation - (*TaskState)(nil), // 7: structs.TaskState - (*TaskHandle)(nil), // 8: structs.TaskHandle - (*NetworkSpec)(nil), // 9: structs.NetworkSpec - nil, // 10: structs.Task.EnvEntry - nil, // 11: structs.Task.LabelsEntry - nil, // 12: structs.Task.DataEntry - nil, // 13: structs.Task.VolumesEntry - nil, // 14: structs.Task.MetadataEntry - (*Task_Volume)(nil), // 15: structs.Task.Volume - (*Task_Artifact)(nil), // 16: structs.Task.Artifact - nil, // 17: structs.Allocation.TaskStatesEntry - (*TaskState_Event)(nil), // 18: structs.TaskState.Event - nil, // 19: structs.TaskState.Event.DetailsEntry - (*TaskHandle_Network)(nil), // 20: structs.TaskHandle.Network - (*timestamp.Timestamp)(nil), // 21: google.protobuf.Timestamp -} -var file_internal_client_runner_structs_runner_proto_depIdxs = []int32{ - 5, // 0: structs.Deployment.tasks:type_name -> structs.Task - 0, // 1: structs.Deployment.desiredStatus:type_name -> structs.Deployment.DesiredStatus - 10, // 2: structs.Task.env:type_name -> structs.Task.EnvEntry - 11, // 3: structs.Task.labels:type_name -> structs.Task.LabelsEntry - 12, // 4: structs.Task.data:type_name -> structs.Task.DataEntry - 13, // 5: structs.Task.volumes:type_name -> structs.Task.VolumesEntry - 16, // 6: structs.Task.artifacts:type_name -> structs.Task.Artifact - 14, // 7: structs.Task.metadata:type_name -> structs.Task.MetadataEntry - 4, // 8: structs.Allocation.deployment:type_name -> structs.Deployment - 17, // 9: structs.Allocation.taskStates:type_name -> structs.Allocation.TaskStatesEntry - 1, // 10: structs.Allocation.status:type_name -> structs.Allocation.Status - 9, // 11: structs.Allocation.networkSpec:type_name -> structs.NetworkSpec - 2, // 12: structs.TaskState.state:type_name -> structs.TaskState.State - 18, // 13: structs.TaskState.events:type_name -> structs.TaskState.Event - 20, // 14: structs.TaskHandle.network:type_name -> structs.TaskHandle.Network - 15, // 15: structs.Task.VolumesEntry.value:type_name -> structs.Task.Volume - 7, // 16: structs.Allocation.TaskStatesEntry.value:type_name -> structs.TaskState - 19, // 17: structs.TaskState.Event.details:type_name -> structs.TaskState.Event.DetailsEntry - 21, // 18: structs.TaskState.Event.time:type_name -> google.protobuf.Timestamp - 19, // [19:19] is the sub-list for method output_type - 19, // [19:19] is the sub-list for method input_type - 19, // [19:19] is the sub-list for extension type_name - 19, // [19:19] is the sub-list for extension extendee - 0, // [0:19] is the sub-list for field type_name -} - -func init() { file_internal_client_runner_structs_runner_proto_init() } -func file_internal_client_runner_structs_runner_proto_init() { - if File_internal_client_runner_structs_runner_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_internal_client_runner_structs_runner_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExitResult); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_client_runner_structs_runner_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Deployment); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_client_runner_structs_runner_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Task); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_client_runner_structs_runner_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Allocation); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_client_runner_structs_runner_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TaskState); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_client_runner_structs_runner_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TaskHandle); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_client_runner_structs_runner_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*NetworkSpec); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_client_runner_structs_runner_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Task_Volume); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_client_runner_structs_runner_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Task_Artifact); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_client_runner_structs_runner_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TaskState_Event); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_client_runner_structs_runner_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TaskHandle_Network); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_internal_client_runner_structs_runner_proto_rawDesc, - NumEnums: 3, - NumMessages: 18, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_internal_client_runner_structs_runner_proto_goTypes, - DependencyIndexes: file_internal_client_runner_structs_runner_proto_depIdxs, - EnumInfos: file_internal_client_runner_structs_runner_proto_enumTypes, - MessageInfos: file_internal_client_runner_structs_runner_proto_msgTypes, - }.Build() - File_internal_client_runner_structs_runner_proto = out.File - file_internal_client_runner_structs_runner_proto_rawDesc = nil - file_internal_client_runner_structs_runner_proto_goTypes = nil - file_internal_client_runner_structs_runner_proto_depIdxs = nil -} diff --git a/internal/client/runner/structs/runner.proto b/internal/client/runner/structs/runner.proto deleted file mode 100644 index feee64a..0000000 --- a/internal/client/runner/structs/runner.proto +++ /dev/null @@ -1,116 +0,0 @@ -syntax = "proto3"; - -package structs; - -import "google/protobuf/timestamp.proto"; - -option go_package = "/internal/client/runner/structs"; - -message ExitResult { - int64 exitCode = 1; - int64 signal = 2; - bool oomKiller = 3; - string err = 4; -} - -message Deployment { - string name = 1; - repeated Task tasks = 2; - int64 sequence = 3; - - DesiredStatus desiredStatus = 7; - - string alias = 4; - - enum DesiredStatus { - Run = 0; - Stop = 1; - } -} - -message Task { - string image = 1; - string tag = 2; - repeated string args = 3; - map env = 4; - map labels = 5; - repeated string securityOpt = 7; - string name = 8; - map data = 9; - map volumes = 11; - - repeated Artifact artifacts = 12; - - bool batch = 15; - - map metadata = 16; - - message Volume { - string path = 1; - } - - message Artifact { - string source = 1; - string destination = 2; - } -} - -message Allocation { - Deployment deployment = 2; - - map taskStates = 3; - - Status status = 6; - - NetworkSpec networkSpec = 8; - - enum Status { - Unknown = 0; - Pending = 1; - Running = 2; - Complete = 3; - Failed = 4; - } -} - -message TaskState { - State state = 1; - - bool failed = 2; - - uint64 restarts = 3; - - repeated Event events = 5; - - string id = 6; - - bool killing = 7; - - enum State { - Pending = 0; - Running = 1; - Dead = 2; - } - - message Event { - string type = 1; - map details = 2; - google.protobuf.Timestamp time = 3; - } -} - -message TaskHandle { - string containerID = 1; - Network network = 2; - - string id = 3; - - message Network { - string ip = 1; - } -} - -message NetworkSpec { - string id = 1; - string ip = 2; -} diff --git a/internal/client/runner/structs/utils.go b/internal/client/runner/structs/utils.go deleted file mode 100644 index 23df6c9..0000000 --- a/internal/client/runner/structs/utils.go +++ /dev/null @@ -1,72 +0,0 @@ -package structs - -import ( - "fmt" - - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/types/known/timestamppb" -) - -func NewTaskState() *TaskState { - return &TaskState{ - State: TaskState_Pending, - } -} - -func (r *ExitResult) Successful() bool { - return r.ExitCode == 0 && r.Signal == 0 && r.Err == "" -} - -func NewTaskEvent(typ string) *TaskState_Event { - return &TaskState_Event{ - Type: typ, - Time: timestamppb.Now(), - Details: map[string]string{}, - } -} - -func (t *TaskState_Event) SetExitCode(c int64) *TaskState_Event { - t.Details["exit_code"] = fmt.Sprintf("%d", c) - return t -} - -func (t *TaskState_Event) SetSignal(s int64) *TaskState_Event { - t.Details["signal"] = fmt.Sprintf("%d", s) - return t -} - -func (t *TaskState_Event) FailsTask() bool { - _, ok := t.Details["fails_task"] - return ok -} - -func (t *TaskState_Event) SetFailsTask() *TaskState_Event { - t.Details["fails_task"] = "true" - return t -} - -func (t *TaskState_Event) SetTaskFailed(name string) *TaskState_Event { - t.Details["failed_task"] = name - return t -} - -const ( - TaskStarted = "Started" - TaskTerminated = "Terminated" - TaskRestarting = "Restarting" - TaskNotRestarting = "Not-restarting" - TaskSiblingFailed = "Sibling-failed" - TaskKilling = "Task-Killing" -) - -func (a *Allocation) Copy() *Allocation { - return proto.Clone(a).(*Allocation) -} - -func (d *Deployment) Copy() *Deployment { - return proto.Clone(d).(*Deployment) -} - -func (d *Task) Copy() *Task { - return proto.Clone(d).(*Task) -} diff --git a/internal/client/sync_hook.go b/internal/client/sync_hook.go deleted file mode 100644 index 337c2e2..0000000 --- a/internal/client/sync_hook.go +++ /dev/null @@ -1,90 +0,0 @@ -package client - -import ( - "context" - "fmt" - "time" - - "github.com/golang/protobuf/ptypes/empty" - "github.com/hashicorp/go-hclog" - babel "github.com/umbracle/babel/sdk" - "github.com/umbracle/vesta/internal/client/runner/hooks" - proto "github.com/umbracle/vesta/internal/client/runner/structs" - "google.golang.org/grpc" -) - -type syncStateUpdater interface { - UpdateSyncState(alloc, task string, status *babel.SyncStatus) -} - -var _ hooks.TaskHook = &syncHook{} -var _ hooks.TaskPoststartHook = &syncHook{} -var _ hooks.TaskStopHook = &metricsHook{} - -type syncHook struct { - logger hclog.Logger - task *proto.Task - alloc string - closeCh chan struct{} - ip string - syncStateUpdater syncStateUpdater -} - -func newSyncHook(logger hclog.Logger, alloc string, task *proto.Task, syncStateUpdater syncStateUpdater) *syncHook { - h := &syncHook{ - closeCh: make(chan struct{}), - task: task, - alloc: alloc, - syncStateUpdater: syncStateUpdater, - } - h.logger = logger.Named(h.Name()) - return h -} - -func (m *syncHook) Name() string { - return "sync-hook" -} - -func (m *syncHook) Poststart(ctx context.Context, req *hooks.TaskPoststartHookRequest) error { - if req.Spec.Ip == "" { - return nil - } - - // only track if the name of the task is babel - if m.task.Name != "babel" { - return nil - } - - m.ip = req.Spec.Ip - go m.collectMetrics() - - return nil -} - -func (m *syncHook) collectMetrics() { - conn, err := grpc.Dial(fmt.Sprintf("%s:2020", m.ip), grpc.WithInsecure()) - if err != nil { - panic(err) - } - clt := babel.NewBabelServiceClient(conn) - - for { - resp, err := clt.GetSyncStatus(context.Background(), &empty.Empty{}) - if err != nil { - m.logger.Error("failed to get sync status", "err", err) - } else { - m.syncStateUpdater.UpdateSyncState(m.alloc, m.task.Name, resp) - } - - select { - case <-m.closeCh: - return - case <-time.After(5 * time.Second): - } - } -} - -func (m *syncHook) Stop(ctx context.Context, req *hooks.TaskStopRequest) error { - close(m.closeCh) - return nil -} diff --git a/internal/cmd/server.go b/internal/cmd/server.go index 50bdf5b..cdc2c6e 100644 --- a/internal/cmd/server.go +++ b/internal/cmd/server.go @@ -8,10 +8,10 @@ import ( "time" "github.com/boltdb/bolt" + "github.com/ferranbt/composer" "github.com/hashicorp/go-hclog" "github.com/mitchellh/cli" flag "github.com/spf13/pflag" - "github.com/umbracle/vesta/internal/client" "github.com/umbracle/vesta/internal/server" ) @@ -19,7 +19,7 @@ import ( type ServerCommand struct { UI cli.Ui server *server.Server - client *client.Client + client *composer.Server logLevel string volume string @@ -72,25 +72,34 @@ func (c *ServerCommand) Run(args []string) int { } c.server = srv - cfg := &client.Config{ - ControlPlane: srv, - NodeID: "local", - PersistentDB: db, - } - if c.volume == "" { - logger.Warn("no volume is set") - } else { - cfg.Volume = &client.HostVolume{ - Path: c.volume, - } - } - - client, err := client.NewClient(logger, cfg) + clt, err := composer.NewServer() if err != nil { - c.UI.Output(fmt.Sprintf("failed to start agent: %v", err)) + c.UI.Output(fmt.Sprintf("failed to start local scheduler: %v", err)) return 1 } - c.client = client + c.client = clt + + /* + cfg := &client.Config{ + ControlPlane: srv, + NodeID: "local", + PersistentDB: db, + } + if c.volume == "" { + logger.Warn("no volume is set") + } else { + cfg.Volume = &client.HostVolume{ + Path: c.volume, + } + } + + client, err := client.NewClient(logger, cfg) + if err != nil { + c.UI.Output(fmt.Sprintf("failed to start agent: %v", err)) + return 1 + } + c.client = client + */ return c.handleSignals() } @@ -107,7 +116,6 @@ func (c *ServerCommand) handleSignals() int { gracefulCh := make(chan struct{}) go func() { c.server.Stop() - c.client.Stop() close(gracefulCh) }()