-
Couldn't load subscription status.
- Fork 10
feat(test reports): test_report key functionality #634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
aad77ed
802831e
e7a30eb
309d53a
aeb5c30
e2749c2
aa3edbf
86a2d9b
f022c7a
4a522db
060aceb
e2ec2b9
a52952d
ec9dafa
6d37f5a
f42e676
76529b1
012d17e
c26d850
7886bd1
e7fa8e6
9e63c7b
b85a4c6
54eccc6
02bc917
a3300f5
9c829e5
746ba27
c0affe8
788af04
085a207
e9a7ced
fe11078
14d8645
ee65782
5e08770
319412f
2b63a1c
4bfe330
0fe9168
419a687
605d9a4
76efee5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| "sync" | ||
| "time" | ||
|
|
||
| "github.com/go-vela/server/storage" | ||
|
Check failure on line 13 in cmd/vela-worker/exec.go
|
||
| "github.com/sirupsen/logrus" | ||
|
|
||
| "github.com/go-vela/sdk-go/vela" | ||
|
|
@@ -25,9 +26,11 @@ | |
| // exec is a helper function to poll the queue | ||
| // and execute Vela pipelines for the Worker. | ||
| // | ||
| //nolint:nilerr,funlen // ignore returning nil - don't want to crash worker | ||
| //nolint:funlen // ignore returning nil - don't want to crash worker | ||
| func (w *Worker) exec(index int, config *api.Worker) error { | ||
|
Check failure on line 30 in cmd/vela-worker/exec.go
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
| var err error | ||
| var execStorage storage.Storage | ||
|
Check failure on line 32 in cmd/vela-worker/exec.go
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
| var _executor executor.Engine | ||
|
Check failure on line 33 in cmd/vela-worker/exec.go
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
|
|
||
| // setup the version | ||
| v := version.New() | ||
|
|
@@ -156,6 +159,13 @@ | |
| execOutputCtn := *w.Config.Executor.OutputCtn | ||
| execOutputCtn.ID = fmt.Sprintf("outputs_%s", p.ID) | ||
|
|
||
| if w.Storage != nil { | ||
| execStorage = w.Storage | ||
| logrus.Debugf("executor storage is available, setting up storage") | ||
|
Check failure on line 164 in cmd/vela-worker/exec.go
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
| } else { | ||
| logrus.Debugf("executor storage is nil, skipping storage setup") | ||
| } | ||
|
|
||
| // create logger with extra metadata | ||
| // | ||
| // https://pkg.go.dev/github.com/sirupsen/logrus#WithFields | ||
|
|
@@ -229,11 +239,10 @@ | |
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| // setup the executor | ||
| // | ||
| // https://pkg.go.dev/github.com/go-vela/worker/executor#New | ||
| _executor, err := executor.New(&executor.Setup{ | ||
| setup := &executor.Setup{ | ||
| Logger: logger, | ||
| Mock: w.Config.Mock, | ||
| Driver: w.Config.Executor.Driver, | ||
|
|
@@ -248,8 +257,17 @@ | |
| Pipeline: p.Sanitize(w.Config.Runtime.Driver), | ||
| Version: v.Semantic(), | ||
| OutputCtn: &execOutputCtn, | ||
| }) | ||
| } | ||
|
|
||
| if execStorage != nil { | ||
| fmt.Printf("setting up executor storage\n") | ||
| setup.Storage = execStorage | ||
|
Check failure on line 264 in cmd/vela-worker/exec.go
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
| } | ||
| _executor, err = executor.New(setup) | ||
|
Check failure on line 266 in cmd/vela-worker/exec.go
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
| if err != nil { | ||
|
Check failure on line 267 in cmd/vela-worker/exec.go
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
| logger.Errorf("unable to setup executor: %v", err) | ||
| return err | ||
| } | ||
| // add the executor to the worker | ||
| w.Executors[index] = _executor | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| "context" | ||
| "time" | ||
|
|
||
| "github.com/go-vela/server/storage" | ||
|
Check failure on line 9 in cmd/vela-worker/operate.go
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
| "github.com/sirupsen/logrus" | ||
| "golang.org/x/sync/errgroup" | ||
|
|
||
|
|
@@ -19,7 +20,7 @@ | |
| // queue and execute Vela pipelines. | ||
| // | ||
| //nolint:funlen // refactor candidate | ||
| func (w *Worker) operate(ctx context.Context) error { | ||
|
Check failure on line 23 in cmd/vela-worker/operate.go
|
||
| var err error | ||
| // create the errgroup for managing operator subprocesses | ||
| // | ||
|
|
@@ -31,7 +32,7 @@ | |
| registryWorker.SetHostname(w.Config.API.Address.Hostname()) | ||
| registryWorker.SetAddress(w.Config.API.Address.String()) | ||
| registryWorker.SetActive(true) | ||
| registryWorker.SetBuildLimit(int32(w.Config.Build.Limit)) | ||
|
Check failure on line 35 in cmd/vela-worker/operate.go
|
||
|
|
||
| // set routes from config if set or defaulted to `vela` | ||
| if (len(w.Config.Queue.Routes) > 0) && (w.Config.Queue.Routes[0] != "NONE" && w.Config.Queue.Routes[0] != "") { | ||
|
|
@@ -77,6 +78,56 @@ | |
| w.updateWorkerStatus(registryWorker, constants.WorkerStatusError) | ||
| } | ||
|
|
||
| // getting storage creds | ||
| logrus.Trace("getting storage s3 creds..") | ||
| // fetching queue credentials using registration token | ||
| stCreds, _, err := w.VelaClient.Storage.GetInfo() | ||
| if err != nil { | ||
| logrus.Tracef("error getting storage creds: %v", err) | ||
| return err | ||
| } | ||
|
|
||
| if stCreds.GetEnabled() { | ||
| logrus.Trace("storage enabled") | ||
| // if an address was given at start up, use that — else use what is returned from server | ||
| if len(w.Config.Storage.Endpoint) == 0 { | ||
| w.Config.Storage.Endpoint = stCreds.GetStorageAddress() | ||
| } | ||
|
|
||
| // set access key in storage config | ||
| w.Config.Storage.AccessKey = stCreds.GetAccessKey() | ||
|
|
||
| // set secret key in storage config | ||
| w.Config.Storage.SecretKey = stCreds.GetSecretKey() | ||
|
|
||
| // set bucket name in storage config | ||
| w.Config.Storage.Bucket = stCreds.GetStorageBucket() | ||
|
|
||
| // set storage enabled to true | ||
| w.Config.Storage.Enable = stCreds.GetEnabled() | ||
|
|
||
| s, err := storage.New(w.Config.Storage) | ||
| if err != nil { | ||
| logrus.Error("storage setup failed") | ||
| // set to error as storage setup fails | ||
| w.updateWorkerStatus(registryWorker, constants.WorkerStatusError) | ||
| return err | ||
|
Check failure on line 114 in cmd/vela-worker/operate.go
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
| } | ||
| w.Storage = s | ||
|
Check failure on line 116 in cmd/vela-worker/operate.go
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
| logrus.WithFields(logrus.Fields{ | ||
| "driver": w.Config.Storage.Driver, | ||
| "bucket": w.Config.Storage.Bucket, | ||
| "endpoint": w.Config.Storage.Endpoint, | ||
| }).Debug("storage initialized") | ||
|
|
||
| } else { | ||
|
Check failure on line 123 in cmd/vela-worker/operate.go
|
||
|
||
| logrus.Trace("storage not enabled") | ||
| // storage disabled; nothing to validate | ||
| w.Config.Storage.Enable = false | ||
| w.Storage = nil | ||
| logrus.Debug("storage disabled: worker storage unset") | ||
|
Check failure on line 128 in cmd/vela-worker/operate.go
|
||
|
||
| } | ||
|
|
||
| // spawn goroutine for phoning home | ||
| executors.Go(func() error { | ||
| // five second ticker for signal handling | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| "net/url" | ||
|
|
||
| "github.com/gin-gonic/gin" | ||
| "github.com/go-vela/server/storage" | ||
|
Check failure on line 11 in cmd/vela-worker/run.go
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
| "github.com/sirupsen/logrus" | ||
| "github.com/urfave/cli/v3" | ||
|
|
||
|
|
@@ -96,15 +97,15 @@ | |
| }, | ||
| // build configuration | ||
| Build: &Build{ | ||
| Limit: int(c.Int("build.limit")), | ||
| Limit: c.Int("build.limit"), | ||
| Timeout: c.Duration("build.timeout"), | ||
| }, | ||
| // build configuration | ||
| CheckIn: c.Duration("checkIn"), | ||
| // executor configuration | ||
| Executor: &executor.Setup{ | ||
| Driver: c.String("executor.driver"), | ||
| MaxLogSize: uint(c.Uint("executor.max_log_size")), | ||
| MaxLogSize: c.Uint("executor.max_log_size"), | ||
| LogStreamingTimeout: c.Duration("executor.log_streaming_timeout"), | ||
| EnforceTrustedRepos: c.Bool("executor.enforce-trusted-repos"), | ||
| OutputCtn: outputsCtn, | ||
|
|
@@ -138,6 +139,13 @@ | |
| Address: c.String("server.addr"), | ||
| Secret: c.String("server.secret"), | ||
| }, | ||
| Storage: &storage.Setup{ | ||
| Driver: c.String("storage.driver"), | ||
| Endpoint: c.String("storage.endpoint.name"), | ||
| AccessKey: c.String("storage.access.key"), | ||
| SecretKey: c.String("storage.secret.key"), | ||
| Bucket: c.String("storage.bucket.name"), | ||
| }, | ||
| // Certificate configuration | ||
| Certificate: &Certificate{ | ||
| Cert: c.String("server.cert"), | ||
|
|
@@ -172,5 +180,6 @@ | |
| } | ||
|
|
||
| // start the worker | ||
| //nolint: contextcheck // not using ctx yet | ||
| return w.Start() | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
| "github.com/go-vela/server/compiler/types/pipeline" | ||
| "github.com/go-vela/server/constants" | ||
| "github.com/go-vela/server/mock/server" | ||
| "github.com/go-vela/server/storage" | ||
| "github.com/go-vela/worker/executor/linux" | ||
| "github.com/go-vela/worker/executor/local" | ||
| "github.com/go-vela/worker/runtime/docker" | ||
|
|
@@ -37,6 +38,36 @@ | |
| t.Errorf("unable to create runtime engine: %v", err) | ||
| } | ||
|
|
||
| _storageT := &storage.Setup{ | ||
| Enable: true, | ||
| Driver: "minio", | ||
| Endpoint: "http://localhost:9000", | ||
| AccessKey: "ad", | ||
| SecretKey: "asd", | ||
| Bucket: "vela", | ||
| Region: "", | ||
| Secure: false, | ||
| } | ||
| _sT, err := storage.New(_storageT) | ||
| if err != nil { | ||
|
Check failure on line 52 in executor/executor_test.go
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
| t.Errorf("unable to create storage engine: %v", err) | ||
| } | ||
|
|
||
| _storageF := &storage.Setup{ | ||
| Enable: false, | ||
| Driver: "", | ||
| Endpoint: "", | ||
| AccessKey: "", | ||
| SecretKey: "", | ||
| Bucket: "", | ||
| Region: "", | ||
| Secure: false, | ||
| } | ||
| _sF, err := storage.New(_storageF) | ||
| if err != nil { | ||
|
Check failure on line 67 in executor/executor_test.go
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
| t.Errorf("unable to create storage engine: %v", err) | ||
| } | ||
|
|
||
| _linux, err := linux.New( | ||
| linux.WithBuild(_build), | ||
| linux.WithHostname("localhost"), | ||
|
|
@@ -45,6 +76,7 @@ | |
| linux.WithRuntime(_runtime), | ||
| linux.WithVelaClient(_client), | ||
| linux.WithVersion("v1.0.0"), | ||
| linux.WithStorage(_sT), | ||
| ) | ||
| if err != nil { | ||
| t.Errorf("unable to create linux engine: %v", err) | ||
|
|
@@ -57,6 +89,7 @@ | |
| local.WithRuntime(_runtime), | ||
| local.WithVelaClient(_client), | ||
| local.WithVersion("v1.0.0"), | ||
| local.WithStorage(_sT), | ||
| ) | ||
| if err != nil { | ||
| t.Errorf("unable to create local engine: %v", err) | ||
|
|
@@ -80,6 +113,7 @@ | |
| Pipeline: _pipeline, | ||
| Runtime: _runtime, | ||
| Version: "v1.0.0", | ||
| Storage: _sF, | ||
| }, | ||
| want: nil, | ||
| equal: reflect.DeepEqual, | ||
|
|
@@ -95,6 +129,7 @@ | |
| Pipeline: _pipeline, | ||
| Runtime: _runtime, | ||
| Version: "v1.0.0", | ||
| Storage: _sT, | ||
| }, | ||
| want: _linux, | ||
| equal: linux.Equal, | ||
|
|
@@ -109,6 +144,7 @@ | |
| Pipeline: _pipeline, | ||
| Runtime: _runtime, | ||
| Version: "v1.0.0", | ||
| Storage: _sT, | ||
| }, | ||
| want: _local, | ||
| equal: local.Equal, | ||
|
|
@@ -123,6 +159,7 @@ | |
| Pipeline: _pipeline, | ||
| Runtime: _runtime, | ||
| Version: "v1.0.0", | ||
| Storage: _sT, | ||
| }, | ||
| want: nil, | ||
| equal: reflect.DeepEqual, | ||
|
|
@@ -137,6 +174,7 @@ | |
| Pipeline: _pipeline, | ||
| Runtime: _runtime, | ||
| Version: "v1.0.0", | ||
| Storage: _sT, | ||
| }, | ||
| want: nil, | ||
| equal: reflect.DeepEqual, | ||
|
|
@@ -151,6 +189,7 @@ | |
| Pipeline: _pipeline, | ||
| Runtime: _runtime, | ||
| Version: "v1.0.0", | ||
| Storage: _sT, | ||
| }, | ||
| want: nil, | ||
| equal: reflect.DeepEqual, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
File is not properly formatted (gci)