Commit Graph

502 Commits

Author SHA1 Message Date
Simone Gotti
abf908bcad runservice executor: rename makeEnv to makeEnvSlice 2019-04-22 18:19:13 +02:00
Simone Gotti
7e9abbf529 runservice executor: add driver Setup method
Remote custom `copytoolbox` hack and use a generic `Setup` function in the
driver interface
2019-04-22 18:17:55 +02:00
Simone Gotti
7ebc436854 runservice executor: generate pod id outside driver 2019-04-22 17:53:34 +02:00
Simone Gotti
17f3dc89f2 runservice executor: remove unused CopyTo method from driver 2019-04-22 18:27:48 +02:00
Simone Gotti
f85ffb594f runservice toolbox: add exec command 2019-04-22 17:49:18 +02:00
Simone Gotti
dfeba334f6 runservice: update docker registry auth 2019-04-22 14:38:25 +02:00
Simone Gotti
d91bb36ccb cmd serve: update parse config error 2019-04-21 15:27:35 +02:00
Simone Gotti
9c74b4ddc1 runservice scheduler: choose scheduler only if it has capacity 2019-04-17 20:59:28 +02:00
Simone Gotti
1ac139434e runservice scheduler: cancel unscheduled root tasks when run has result
When run has a result set, root tasks not yet scheduled must be cancelled.
2019-04-17 18:00:34 +02:00
Simone Gotti
9f89a923c0 runservice scheduler: take a copy of run in advanceRunTasks
take and change a copy of the current run so we'll change newRun and use curRun
status for logic decision. In this way result are reproducible or they will be
affected by the random run.Tasks map iteration order.
2019-04-17 18:06:31 +02:00
Simone Gotti
4dd89646af runservice executor: report ActiveTasksLimit
Add a config option to set the active tasks limit and report it.
2019-04-17 15:51:20 +02:00
Simone Gotti
455623e58a runservice executor: report running tasks 2019-04-17 15:47:58 +02:00
Simone Gotti
adf9c73518 runservice scheduler: choose executor with right arch
Choose an executor matching the required arch or any if no arch is required
2019-04-17 15:26:09 +02:00
Simone Gotti
f3e583bb40 config: check Runtime.Arch 2019-04-17 15:24:37 +02:00
Simone Gotti
22f0865aa3 runconfig: add and populate Runtime.Arch 2019-04-17 15:23:50 +02:00
Simone Gotti
a511fbf10c runservice: executor: provide architecture information 2019-04-17 15:22:26 +02:00
Simone Gotti
d3e95ba665 runservice config: set executor labels 2019-04-17 15:25:11 +02:00
Simone Gotti
d3f658c5ad runservice: add run cache cleaner
Removes old cache entries (defaults to 7 days)
2019-04-17 13:58:41 +02:00
Simone Gotti
4c19ea3e91 remove .agola/config.yml
since we use the jsonnet format
2019-04-16 17:51:39 +02:00
Simone Gotti
fcba3ccfad tests: add config.jsonnet
Use a jsonnet config that make creating matrix build and tests a breeze
2019-04-16 15:37:23 +02:00
Simone Gotti
ebe34ba1fa runservice: set default config task working_dir
Set default task working_dir to ~/project
2019-04-16 15:20:45 +02:00
Simone Gotti
4c30a5af1c runservice: handle jsonnet and json config files
Handle config files with name `config.jsonnet`, `config.json` and
`config.yml` and take the first from the repository in this order

For a jsonnet file execute it and use the generated output as the config
2019-04-16 15:00:37 +02:00
Simone Gotti
03451535c8 runservice: rework config format
The current config format was thought for future extensions for reusing runtimes
and job definitions adding some parameters.

After a lot of thoughts this looks like a complex approach: the final result
will be a sort of templating without a lot of powers.

Other approach like external templating should be an alternative but I really
don't think templating yaml is the way to go.

A much better approach will to just use jsonnet when we need to create matrix
runs and a lot of other use cases.

So just make the config a simple yaml/json. User can generate their config using
any preferred tool and in future we'll leverage jsonnet automated parsing and
provide a lot of jsonnet based examples for most use cases.

Main changes:

* Runs are now an array and not a map. The run name is in the Name field
* Tasks are now an array and not a map. The task name is in the Name field
* Use https://github.com/ghodss/yaml so we'll use json struct tags and unmarshall functions
2019-04-16 11:01:02 +02:00
Simone Gotti
6066221136 runservice: rename config pipeline(s) to run(s)
No need for different names. We are always talking about a run. In the config
it's the run definition, in the service is the run execution.
2019-04-15 23:42:10 +02:00
Simone Gotti
06374e14fd runservice: resolve ~ in working_dir 2019-04-15 11:12:07 +02:00
Simone Gotti
351f7518de toolbox: add toolbox mkdir 2019-04-15 14:33:55 +02:00
Simone Gotti
ac7447a5c9 toolbox: add expanddir command 2019-04-15 14:33:26 +02:00
Simone Gotti
8bde2f2bc0 runservice: implement caching
Add `save_cache` and `restore_cache steps`
2019-04-13 14:58:56 +02:00
Simone Gotti
57161477ca objectstorage: return object last modified time 2019-04-15 09:37:34 +02:00
Simone Gotti
9c2ac68a75 toolbox: add template command 2019-04-14 15:10:54 +02:00
Simone Gotti
4c12b03544 toolbox: expand archive/unarchive starting tilde
Expand archive sourceDir(s) and unarchive DestDir
2019-04-13 14:56:35 +02:00
Simone Gotti
3928851c10 runservice: rename Run.RunTasks to Run.Tasks 2019-04-12 17:45:38 +02:00
Simone Gotti
68e95ad3be runservice: implement task dependencies conditions
Handle the task dependencies conditions:
* on_success (default if no conditions are specified)
* on_failure
* on_skipped

Not the runservice won't stop run but continue executing tasks that depends on a
parent also if this is failed
2019-04-12 16:46:04 +02:00
Simone Gotti
5165984030 runservice: convert RunConfigTask.Depends to a map 2019-04-12 17:04:07 +02:00
Simone Gotti
991fcc59de runservice: stop all running executor tasks when run is marked to stop 2019-04-11 23:44:55 +02:00
Simone Gotti
c300a37d09 runservice: add some initial scheduler tests 2019-04-11 17:23:59 +02:00
Simone Gotti
ca1d837ecd webhook: use hook provided ssh url for cloning
Additionally don't save a CloneURL field inside the project type.

If in future some git source doesn't provide a clone url we could just calculate
it from project.RepoPath or call the remote api to retrieve it.
2019-04-11 16:49:07 +02:00
Simone Gotti
782750e51e project: save remote repository id 2019-04-11 17:11:17 +02:00
Simone Gotti
4e07550f30 toolbox: create tmp dir if missing
Create the tmp dir if the image doesn't have one.
2019-04-11 16:46:24 +02:00
Simone Gotti
634a8a543c runservice: implement docker registry auth
By now just support default username/password login

In future also support additional container registries with their own credential
helpers
2019-04-10 17:13:51 +02:00
Simone Gotti
298ffc3529 config: generalize and simplify value string/from_variable parsing 2019-04-10 17:12:39 +02:00
Simone Gotti
751361daea runservice: refactor scheduling logic
* split functions in sub parts to ease future testing
* save run fewer times
* rework events logic to considere both run phase and result changes (emit an
event on every phase or result change)
2019-04-10 14:48:47 +02:00
Simone Gotti
da27348a1d runservice: implement run setup errors
Add the ability to define a run with a setuperror phase.

When the run setup has errors client could submit a run with a list of setup
errors. In such case the run will be created in the setuperror phase.

Setup errors are currently generated by the webhook receiver and the run service
when it checks the run config for possible issues.
2019-04-09 16:51:37 +02:00
Simone Gotti
671b89d391 runservice: merge RunConfig and RunData
* Use just RunConfig
* Use StaticEnvironment vs Environment in RunConfig to distinguish between env
that won't change at run recreation from env that could change at every
recreation
* The RunCreate api will just receive the runtasks instead of a runconfig (more
right)
2019-04-09 18:11:00 +02:00
Simone Gotti
3642be6f21 */api: Use helpers for error handling
* client: always parse the json error message field and return its contents
* Use ErrBadRequest and ErrNotFound in every handler and command
* Gateway: by default pass underlying service error (configstore, runservice) to
client keeping the status code and message. In future, if some errors must be
masked, we should change the specific parts that need special handling.
2019-04-09 14:53:00 +02:00
Simone Gotti
643dfe4072 runservice api: improve response handling
* Command: use ErrBadRequest
* Always return a json message also on error. For internal errors return a
generic "internal server error" message to not leak the real internal error to
clients
* Return 201 Created on resource creation
* Return 204 No Content on resource deletion and other action with no json
output
2019-04-08 18:04:42 +02:00
Simone Gotti
7d787c5f77 *: implement task approval 2019-04-08 17:29:57 +02:00
Simone Gotti
81537f882f gateway: fix runs url to plural 2019-04-08 16:11:19 +02:00
Simone Gotti
14bc618a91 types: add MatchWhen tests 2019-04-08 16:05:53 +02:00
Simone Gotti
4fb250a668 configstore api: improve response handling
* Always return a json message also on error. For internal errors return a
generic "internal server error" message to not leak the real internal error to
clients
* Return 201 Created on resource creation
* Return 204 No Content on resource deletion and other action with no json
output
2019-04-08 12:29:25 +02:00