Commit Graph

546 Commits

Author SHA1 Message Date
Xavier-Do
1e102b7d76 [FIX] runbot: check support before adding auto-tags 2019-11-08 15:40:36 +01:00
Xavier-Do
0c4d78f497 [FIX] runbot: various small fixes 2019-11-08 15:33:30 +01:00
Xavier-Do
a7992e9f50 [IMP] runbot: add no_build on repo
When runbot is installed to test customs addons, we don't
want to build all odoo commit, but we need to update branches
in order to make _get_closest_branch work.

This commit will allow a user to set odoo in poll mode
with no_build set to True, to create branches only.

(And a small fix for additionnal_env)
2019-11-08 12:08:02 +01:00
Christophe Monniez
631b29fcf8 [FIX] runbot: fix container cli tests
Since 81fefee, the container.py CLI does not work as expected.

With this commit, the CLI is working, a new arg was added to test
flamegraphs and the dump is adapted to mimic the runbot.

Also, a small issue is fixed in the zip file creation. Before the zip
creation, the directory is changed, if the directory change fails, the
zip is created from the current directory which is removed by zip at the
end of the process. That could lead to the deletion of the build dir.
2019-11-08 10:29:51 +01:00
Xavier-Do
685cc282ba [IMP] runbot: add env parameter support for docker in config steps 2019-11-08 10:29:51 +01:00
Xavier-Do
58c683030d [IMP] runbot: add auto test-tags management.
A typical use case when an error is detected is to disable
this test by adding a negated test-tags on config
step 'all' and 'split_all'. This commit will help
to do that by adding a test_tags management on build error.

The user define a test_tag that will only execute failling test.
if a config step has the flag enable_auto_tags, the test tag will
be negated and added to config test-tags.

This commit also add some information for monitoring.
2019-11-07 09:51:05 +01:00
Xavier-Do
40bc185d28 [FIX] runbot: quite zip 2019-11-06 14:11:15 +01:00
Xavier-Do
d7f6075c8b [FIX] runbot: avoid build failure when test_tags not supported 2019-11-06 12:55:58 +01:00
Christophe Monniez
daea9018d3 [FIX] runbot: fix database dump
* Add zip utility in Dockerfile
* fix zip command to avoid useless prefix
* write json info file at the right place
* fix zip file link
2019-11-04 17:28:37 +01:00
Xavier-Do
b9550dccca [IMP] runbot: improve db dump
Current dump version doesn't include filestore. This new
version adds the filestore trying to match odoo backup format
in order to ease restore.
manifest.json file is not create since it isn't usefull,
but an info.json is added, with build info.
2019-11-04 14:03:41 +01:00
Christophe Monniez
6e7d8d57f8 [IMP] runbot: add a multibuild wizard
Creating multi builds configs can be tedious. One must create 2 build
configs and 2 build config steps in the right order.

With this commit, a simple wizard is added that creates those 4
configurations by simply filling 4 fields.

Also, a new field, group, is added in order to be able to gather
config's and config steps into  groups. The group is a Many2one on a
config.

While at it, the runbot menu has been a bit rearranged with everything
about config's in a parent menu named Configs.

Config's and config's steps tree views have been enhanced to show the
config group and add some filters in the search views.
2019-10-28 15:26:15 +01:00
Xavier-Do
ddb7bec0c2 [FIX] runbot: remove useless divide by 2 2019-10-28 10:54:08 +01:00
Xavier-Do
3bf0550b3a [FIX] runbot: rename duplicate field description 2019-10-25 19:19:27 +02:00
Xavier-Do
a3d908ac03 [FIX] runbot: fix forgotten cleanup 2019-10-22 17:18:30 +02:00
Xavier-Do
18b37d9002 [IMP] runbot: gc database faster if corresponding build has parent_id 2019-10-22 16:55:12 +02:00
Xavier-Do
c874f4a046 [IMP] runbot: execute flamegraph in case of failure and log dl link 2019-10-22 14:33:10 +02:00
Xavier-Do
8284c7270d [IMP] runbot: add message if docker does not match dest format 2019-10-22 11:40:46 +02:00
Xavier-Do
7f4f82a881 [FIX] runbot: docker cleanup should be run on workers only 2019-10-21 17:41:59 +02:00
Xavier-Do
ecd718ca2a [FIX] runbot: fix default modules and flamegraph 2019-10-21 17:03:43 +02:00
Xavier-Do
ec8a70a410 [IMP] runbot: allow to generate a flamegraph during a build
With this commit, a new boolean field "flamegraph" is added on the
build_config to allow a flamegraph generation.

In order to be able to generate a flamegraph during a runbot build, the
flamegraph package is added to the Docker image as well as the
flamegraph.pl tool.
2019-10-21 16:30:22 +02:00
Christophe Monniez
d9b20d6961 [IMP] runbot: dump database at the end of step
Dump a db at the end of a build, using a new 'finals' cmd part
added in order to execute dump even if build fails.

Add a link in last step log to download dump.
2019-10-21 16:23:05 +02:00
Christophe Monniez
d869d22f7b [FIX] runbot: add forgotten imports
Oversight of previous commit.
2019-10-21 15:17:58 +02:00
Christophe Monniez
5ff9cc2382 [FIX] runbot: clean running dockers with done builds
In different situations, a docker container may stay alive even if the
build global_state is done. This can lead to a build failure when a
build wants to go in running state and tries to expose the same ports as
the left over build.
2019-10-21 10:52:45 +02:00
Xavier-Do
5b12f37c74 [REV] runbot: Avoid infinite loop fetching"
This reverts commit 1207daded1.

A too quick review, setting a default value is a good idea but since field is a float now,
default value should be time.time
2019-10-18 20:20:10 +02:00
Christophe Monniez
3308829e80 [IMP] runbot: uses fnmatch patterns to select modules
Actually some Odoo modules are black_listed from a set hardcoded in the
runbot code. In some cases, one needs to blacklist custom modules,
preferably in a config_step.

With this commit, the repo.modules, branch.modules,
config_step.install_modules fields are concatained in a comma separated
list of fnmatch patterns. The patterns can be prefixed with a dash to
exclude the matching module(s).

Co-authored by @Xavier-Do
2019-10-18 16:30:06 +02:00
Moises Lopez - https://www.vauxoo.com/
1207daded1 [FIX] runbot: Avoid infinite loop fetching
Using `repo.hook_time = None` and `repo.mode = hook` the cron run fetch command in an infinite-loop.
2019-10-18 11:18:46 +02:00
Christophe Monniez
27b1c2b5f4 [IMP] runbot: add the active_step_id on the ir_logging log
In order to have a more efficient ir_logging filtering, this commit adds
the currrent build step id on the ir_logging line.
2019-10-18 11:03:22 +02:00
Christophe Monniez
db52bff323 [IMP] runbot: number of log lines per build
When a build is running, a cron, an evil query or something else can
start to fill and bloat the runbot ir_logging table.

With this commit, a log_counter field is added on the build, starting at
100. The SQL trigger decrement this counter after a line is inserted.

When the counter drops to 0, a the last log line contains a message
stating that the limit has been reached. Further log lines are dropped
for this build step.

The counter is reset to a default of 100 before each step.
This value is configurable through an optional ir.config_parameter
runbot_maxlogs.

The runbot itself is still able to add logs lines through the build _log
method.

Thanks @Xavier-Do for the smart idea.
2019-10-18 11:03:22 +02:00
Xavier-Do
ac578d430d [IMP] runbot: propagate end_time to parent_build
When a build only create sub-builds, the build_time is verry small (a few seconds),
and this information is not relevant. This commit propagates end_time to parent_build
if parent_build is done or running.
2019-10-16 14:25:43 +02:00
Christophe Monniez
4b2a93af9e [FIX] runbot: fix build_error active field changes
When a build_error active field is changed, the onchange leads to a
traceback. Anyway, the onchange was not a good idea as it only reflects
UI changes.

With this commit, the write method is overwritten to change the
child_ids active fields too. Also, the active_test context is used to
correctly compute the childs_ids and children_build_ids.

A test is also added for all that.
2019-09-20 14:58:16 +02:00
Christophe Monniez
56999ecfb4 [IMP] runbot: various improvements
- Add a keep running flag on the build to allow a build to stay in
  running state until the flag is switched off ( or the build killed)
- Do not update configs and config_steps data
- Add a first/last_seen_build and first/last_seen_date on build.error
- Children error builds now include the parent builds too
- Use a notebook on build.error form view to display builds and linked
  errors
- Update result when a build triggers a change from 'warn' to 'ko' too
- Add the sticky flag on the error logs stored sql view
2019-09-18 15:27:19 +02:00
Christophe Monniez
b7df8566e4 [IMP] runbot: create a new build error when a fixed one reappear
When a build error appears with the same fingerprint as already known
one which was supposedly fixed, the build is simply added to the known
build error.

In order to keep an eye on such reappearing bugs and keep the fixing
history separated, this commit simply creates a new build_error.
Old build errors with the same hash (or child_ids 's hashes) appears in
a computed field error_history_ids.
2019-09-18 13:16:20 +02:00
Xavier ALT
f25ab94517 [FIX] runbot: correctly order repo by sequence
Even if present and editable the user, changing the sequence
of a repository has no effect

Fix by adding missing _order on runbot.repo model
2019-09-06 11:01:15 +02:00
Christophe Monniez
c5582ce154 [FIX] runbot: remove skip old builds logic
When finding new commits, if there is more pending builds on a repo than
the running_max parameter, the exceeding builds are skipped.

As a result, when nightly builds are created on the runbot, it happens
that some of them are skipped.

Also, since e51412d , only refs newer than max_age are builded; thus the
logic is not needed to prevent rebuild of olds refs in case of a fresh
runbot install.
2019-09-04 11:05:43 +02:00
Christophe Monniez
cc388715bc [FIX] runbot: properly compute children_build_ids
The Many2many related on a Many2many does not map the ids as expected.
With this commit, the records are mapped in a compute.

It also fixes an uppercase letter was used in the children_build_ids field name.
2019-09-03 15:33:39 +02:00
Xavier-Do
9a9de6ad85 [FIX] runbot: fix build_end and port
When killed a build could have his build end changed (problematic when
killing a running since build_time must represent the testing time)
-> if a build already has a build end, don't overwrite it.

Port also needs to be reset on wake_up since another build would have
recycle the current one since port unicity is limited to build not in
done state. This was working most of the time before since port unicity
was determined cross runbots, thus we only had one chance over 17
to have a conflict on wake up. (this changed with prevous commit)
2019-09-03 11:10:38 +02:00
Xavier-Do
2e44c51678 [FIX] runbot: limit port search to local host.
With the increasing number of runbot servers (17), the total number of docker
instances can reach more than 3570 only for running build. Starting at 2000,
this covers the posrt 5432 used by postgress and make the build run step fail.

This commit simply limit the port unicity constraint by host.
2019-09-03 11:10:38 +02:00
Christophe Monniez
4c75a8e107 [IMP] runbot: add an action to parse logs from build error views 2019-09-03 11:10:38 +02:00
Christophe Monniez
c49e422a25 [IMP] runbot: add an error log model based on a SQL view
With this commit, a new model is introduced to facilitate the tracking
of the build errors.

Its based on an SQL view (Thanks @Xavier-Do), that way, there is no new
table in DB and this view is also useful from the PSQL CLI.

In the UI, the search for errors easier than manipulate the ir_logging
view because the builds informations can be used in search and filters.
2019-09-03 11:10:38 +02:00
Xavier-Do
7382aa6b79 [FIX] runbot: various small fixes and imps 2019-09-03 11:10:38 +02:00
Xavier-Do
a91b08897f [IMP] runbot: improve archive failure logging 2019-09-03 11:10:38 +02:00
Christophe Monniez
57a32ee937 [IMP] runbot: log error instead of info when wake up fails 2019-09-03 11:10:38 +02:00
Christophe Monniez
8d199b4c16 [FIX] runbot: catch exceptions on wake-up
When a build is wake-up and something goes wrong during the
_run_odoo_run method, the "fetch and build" cron is broken and the
concerned runbot host stops working.

With this commit, the exception is catched and the build goes back to
the "done" state whith a log.
2019-09-03 11:10:38 +02:00
Christophe Monniez
0da30a9f60 [IMP] runbot: add build_error model
With this commit, a new RunbotBuilError model is added in order to
classify and manage errors that appears during runbot builds.  This is
an helper to find undeterministic bugs in Odoo builds.  Build logs can
be parsed on demand, during the parsing, the logs are cleaned with some
regexes stored on the RunbotErrorRegex model.  A hash is computed on the
cleaned log, if a build error already exists with the same fingerprint,
the build is appended on the build error.

Errors can also be manually linked together with a parent/children
relation in case of a related error log. e.g. the error message is
different in two different branches but the bug is the same.

Also, a new build_url field is added to the runbot_build in order to
access the build web page from the backend.
2019-09-03 11:10:38 +02:00
Xavier-Do
02d2cc4528 [WIP] runbot: monitoring tools
Add a new model runbot.host to keep info and configuration about
hosts (worker servers), like number of worker, reserved or not,
ping times (last start loop, successful iteration, end loop, ...)
and also last errors, number of testing per host, psql connection
count, ...

A new monitoring frontend page is created, similar to glances
but with additionnal information like hosts states and
last_monitored builds (for nightly)

Later this model will be used for runbot_build host instead of char.

Host are automaticaly created when running _scheduler.
2019-09-03 11:10:38 +02:00
Xavier-Do
2a18ef4195 [FIX] runbot: missing indirect
In some case _force can return an empty recordset,
if the corresponding branch is in no_build mode in other
repo may be an explanation here.

This commit avoid to stuck the fetch and build loop in this case.
2019-08-19 12:13:55 +02:00
mreficent
9b174ab706 [FIX] runbot: typo (closet -> closest) 2019-08-14 11:43:03 +02:00
Christophe Monniez
857821e41a [IMP] runbot: use the odoo screenshots args
Since odoo/0dc4a63e2 the screenshots arguments can be used to specify
where to save sceenshots.
With this commit, the argument is used if available.
2019-08-13 14:46:07 +02:00
Xavier-Do
d68d0ffa81 [FIX] runbot: fix tracking visibility
Tracking was inspired from master state of the art. This commit addapt
everything to 11.0 tracking in ordr to make it work.
2019-08-13 14:32:18 +02:00
Xavier-Do
a374c2cba3 [FIX] runbot: fix indirect mechanism
indirect state was writen on parent leading to unconsistent info.
indirect was using last build regardless of build_type. Now, indirect
will only use normal build to avoid red-chain after a sticky rebuild.
2019-08-13 14:30:41 +02:00
Xavier-Do
626f454d8b [IMP] runbot: commit message dep param.
A prototype of feature was added some times a go.
No really tested, this commit improves parmater format
and makes dependency closest_branch_id not required
since a repo/sha is all we need.
2019-08-13 14:30:30 +02:00
Xavier-Do
46a7362d18 [FIX] runbot: tempfix wait for docker mechanism
Docker can take some time to be considered as running after docker_run. This
issue can appear when we speedup sheduling loop. To avoid that when can add an
time condition to consider if a docker is running, but we want to avoid to wait
to much since some jobs are fast.

This solution check if a job is a docker run before waiting, and will also
update job_start after a checkout since this can take some time if
a git fetch is performed.
2019-08-13 14:19:51 +02:00
Xavier-Do
5bbfb06ce1 [IMP] runbot: keep result on kill if result is failure
When a build is killed, result will be set to manually killed,
removing the 'error' or 'warn' result.

This commit removes this behaviour in order to keep error result
in this case.
2019-08-13 14:15:26 +02:00
Xavier-Do
694f9e6e05 [IMP] runbot: only gc db after job end
If a user really wants to keep a database up for a long time, he has the possibility
to wake it up multiple times.

Using last job end as reference will allow to keep a database alive longer.
2019-08-13 14:10:21 +02:00
Xavier-Do
fb637194f5 [FIX] runbot: use parent global_state for gitthub status
The main motivation of this commit is to be able to notify github status only
when all children are done.

Until today, children where only used for dev branches and nightly. The needs to
use this system for staging need to enforce github_status behaviour.
Before this commit, a parent won't send github status since he will only
create childrens. And childrens are not awared of other children state,
so sending a succes may be wrong if another one failed.

Asking the parent to make the github_status looks the easiest solution:
-If top parent config will have update_github_state False, we also want to take that into account.
-If a child wants to contact github for failfast, parent will be in global_state error too and will send
message immediatly.
-If a child want to contact github for succsess, we actually want to wait for last child, parent will
be in waiting global_state and notify nothing (or pending).
Only last child will be able to notiffy success since global_state will be running or done at this step.
Orphan builds wont have any impact on result in with this scenario.
2019-08-13 14:03:14 +02:00
Xavier-Do
2e5b1cb240 [FIX] runbot: fix typo
kill -> _kill
2019-08-13 11:10:21 +02:00
Xavier-Do
0efd3fde1d [FIX] runbot: less noisy log
Some data are logged at each loop turn even if nothing interresting was done:
- ... builds [] where allocated to runbot
- reload nginx

That kind of info was interresting for debug but now this noise makes
logs heavier and more difficult to read.
Reload ngnix will be done only if file changed and this this will avoid
a log at each loop turn.

We also display difference between existing sources and source that should
be there instead of complete lists.
2019-08-13 10:58:00 +02:00
Xavier-Do
75dc7bd605 [IMP] runbot: clean sources once they are not used
Sources can be easily exported if needed since they are in the bare repository
most of the time. To avoid using to much space, this commit will garbage collect
all sources at the beginning of a long_running cron.

Only real side effect of this is that it will be impossible to wake up
a build that was force pushed since source cannot be fetched anymore.
We may imagine that we could keep sources of recent build, maybe for
48 hours, but keeping build specific data (logs, database)
is more interresting.
2019-08-13 10:35:19 +02:00
Christophe Monniez
dcf3297bff [FIX] runbot: forbid wake-up on dead builds
When a build is completely dead, with directory and db deleted, the
wake-up system fails.

With this commit, a wake-up is not allowed on such dead builds.
2019-07-19 13:56:19 +02:00
Christophe Monniez
c3e23532be [IMP] runbot: allow nginx access to tests dir
In order to stores other things than logs, that could be accessible by
end users, for example screenshots and screencasts, a "tests" directory
is allowed thruough the nginx template in the builds directories.

Also, the "with" context manager is used to open the nginx configuration
to ensure that the file descriptor is released during long running crons.
2019-07-18 14:39:38 +02:00
Xavier-Do
287efc7989 [FIX] runbot: make result for python code too 2019-07-17 15:51:20 +02:00
Xavier-Do
090b84c86c [FIX] runbot: partial fix for build time with children 2019-07-17 15:51:20 +02:00
Xavier-Do
99fcd9638a [IMP] runbot: take care or extras
If a param is in extra, dont add it automaticaly.
This will allow to remove custom 'test from extras' step.
2019-07-17 15:51:18 +02:00
Xavier-Do
87c794a9aa [IMP] runbot: add wake up option on builds 2019-07-17 11:34:45 +02:00
Christophe Monniez
dbe44e2a76 [FIX] runbot: prevent inter Docker communication
When an Odoo instance is run in a Docker container, it listen on all
interfaces by default and a bridge interface is used to communicate with
the outside world.

This bridge interface is necessary to allow the instance to send logging
messages into the runbot postgresql database.

Even though Docker isolate the container from the oustide world, it's
still possible to reach the Odoo instace from the runbot host and worse,
from other Docker containers using the same bridge interface.

To confirm the  Murphy's law, it finally happened with this commit
odoo/enterprise@0ba0ef99de that scanned the ip range of the interface,
disturbing other builds.

One solution would be to create a bridge interface for each instance to
isolate each Docker but that would imply a big change to garbage collect
forgotten bridges ...

An 'icc' (Inter Container Communication) option exists for the Docker
daemon which defaults to True. Setting it to False was tested and works
but it appears that this option can be messed-up by the firewall on the
runbot host.

Finally, if applied, this commit will prevent the Odoo instance to
listen on the bridge interface by only listening to 127.0.0.1 during
tests. A local_only parameter is a added on the _cmd method which is
true by default and means that the Odoo instance will only listen on
127.0.0.1. This parameter is set to False for the running step to allow
the running to be contacted through the Docker exposed ports.
2019-07-17 10:52:14 +02:00
Xavier-Do
81fefee137 [FIX] runbot: fix coverage since shared sources
The requirements path and python version where defined from
server in cmd. Since in coverage we add a 'python' before server,
it is difficult to define which element of the cmd is the server.

A solution here is simply to define requirements install and
python version when building cmd since we have access to all
build/source informations. We also add python part in every
cases, and coverage params are now a _cmd python_params.

The _cmd method now returns a Command object instead of a
list, which behave has a list for the cmd part but also contains
a pres and posts list.

pres are requirement install, preparation, ...
cmd is the original cmd list, element can be append or added, this
will allow to keep existing python job without to much changes.
posts are post cmd commands, like coverage result making.

This commit also fix issue with create_job dependencies.
2019-07-16 12:06:09 +02:00
Xavier-Do
785001acac [FIX] runbot: fix _coverage_params 2019-07-12 16:37:39 +02:00
Xavier-Do
c31c9642be [IMP] runbot: add read_source on commit 2019-07-12 16:31:17 +02:00
Xavier-Do
21c3686543 [FIX] runbot: _log not log 2019-07-12 15:18:40 +02:00
Xavier-Do
f7a4fb7ac3 [IMP] runbot: share sources between builds
Multibuild can create generate a lots of checkout, especially for small
and fast jobs, which can overload runbot discs since we are trying not
to clean build immediatly. (To ease bug fix and allow wake up)

This commit proposes to store source on a single place, so that
docker can add them as ro volume in the build directory.
The checkout is also moved to the installs jobs, so that
builds containing only create builds steps won't checkout
the sources.

This change implies to use --addons-path correctly, since odoo
and enterprise addons wont be merged in the same repo anymore.
This will allow to test addons a dev will do, with a closer
command line.

This implies to change the code structure a litle, some changes
where made to remove no-so-usefull fields on build, and some
hard-coded logic (manifest_names and server_names) are now
stored on repo instead.

This changes implies that a build CANNOT write in his sources.
It shouldn't be the case, but it means that runbot cannot be
tested on runbot untill datas are written elsewhere than in static.

Other possibilities are possible, like bind mounting the sources
in the build directory instead of adding ro volumes in docker.
Unfortunately, this needs to give access to mount as sudo for
runbot user and changes docjker config to allow mounts
in volumes which is not the case by default. A plus of this
solution would be to be able to make an overlay mount.
2019-07-12 14:50:59 +02:00
Christophe Monniez
0830557cd6 [FIX] runbot: avoid "Modules loaded not found in logs"
In some conditions, Docker can take a little time to start a container.
In that case, if the runbot checks that the container is running before
it starts, runbot consider the job as finished. It the tries to grep the
logs and, as expected, it does not find the "Modules loaded".

With this commit, we consider young builds (less than 15 sec) as
running, giving more time to Docker for starting it.
2019-07-09 13:15:14 +02:00
Christophe Monniez
19b36e4ee6 [FIX] runbot: set force_rebuild when creating multi builds
When creating multi builds config steps, the force_build option is often
forgotten. In that case, the multi builds are detected as duplicate of
the first one.

With this commit, when asking for more that one multi build, the
force_build is chnaged to to True.
2019-07-05 18:03:24 +02:00
Xavier-Do
1b2940705d [FIX] runbot: fix ask_kill for children_ids 2019-07-04 12:17:22 +02:00
Xavier-Do
c4837641cc [FIX] runbot: fix result when make_result crash 2019-07-04 11:48:33 +02:00
Xavier-Do
2de144d299 [IMP] runbot: select all db strating by dest when cleaning 2019-07-04 10:25:25 +02:00
Xavier-Do
fe6788e349 [IMP] runbot: lock an host
In order to be able to test some custom code on one specific worker,
this commit will allow to lock a runbot so that he will only run
assigned build.
2019-07-03 16:23:48 +02:00
Xavier-Do
6bc666b5c3 [IMP] runbot: avoid loosing hooks
In the same spirit of getting garanties that community is updated when enterprise is,
force the hook time of dependencies in case it was lost.
2019-07-03 16:23:48 +02:00
Xavier-Do
f51a021dfe [IMP] runbot: update repo in reversed order
When updating repo, order is  odoo/odoo, odoo-dev/odoo, odoo/enterprise, odoo-dev/enterprise
The problem with this is that if a community hash and an enterprise hash arrives exactly
between odoo/odoo and odoo/enterprise update, enterprise could have a newest version
than community when creating builds.

By inversing this order, we have less chances to have this cornercase (as unlikelly as
it could be)
2019-07-03 16:23:48 +02:00
Xavier-Do
83a0568403 [FIX] runbot: write duplicate_id instead of duplicate when killing build 2019-07-03 16:22:08 +02:00
Xavier-Do
1ffa0468c1 [IMP] runbot: keep cron on transaction rollback 2019-07-03 12:58:58 +02:00
Xavier-Do
c5e0da174a [FIX] runbot: fix exact rebuild 2019-07-03 10:56:57 +02:00
Xavier-Do
53267d64bb [IMP] runbot: improve error logs 2019-07-03 10:50:47 +02:00
Xavier-Do
47396ddb46 [IMP] runbot: only drop database and clean localfiles after 30 days. 2019-06-25 16:43:47 +02:00
Xavier-Do
5c72655e18 [FIX] runbot: invalidate cache at each commit.
In some rare case db could become inconsistent if some data
in cache were used between two _schedule loop turn.
2019-06-25 16:15:24 +02:00
Xavier-Do
94a680f0c8 [FIX] runbot: get_ref_time as float
get_ref_time was cast from float to datetime and thus,
milliseconds where lost. Storing it as float make code
easier to read and avoid this rounding that was breaking
 this feature.
2019-06-24 15:59:21 +02:00
Xavier-Do
b64c7adce2 [FIX] runbot: make nb_testing count correct when children are duplicates 2019-06-24 15:59:21 +02:00
Christophe Monniez
e51412d558 [IMP] runbot: only consider refs newer than max_age
When getting new refs, a lot of them are really old and the
find_new_commits is called for each one and thus browsing branches.

With this commit, refs older than configured max_age are ignored.

Co-authored-by: Xavier Dollé (xdo@odoo.com)
2019-06-24 14:33:17 +02:00
Xavier-Do
54f9b9b546 [IMP] runbot: use counts for global states 2019-06-24 14:29:52 +02:00
Xavier-Do
03da48a07a [IMP] runbot: compute nb states without accessing childrens
Accessing childrens can create rollback, especially for builds with
a lot of them, since other runbot will concurently access and update
states. This commit tries to improve this by incrementing and
decrementing counters instead of counting all of them each time.
2019-06-24 14:29:52 +02:00
Christophe Monniez
7adfa6c7eb [FIX] runbot: add an index on local state
A slow query was detected on the runbot, causing a latency when loading
any page. After some investigations (thnks jle), we found that an index
on local_state could improve speed.
2019-06-19 15:37:31 +02:00
Christophe Monniez
c13128a229 [FIX] runbot: try to update github status multiple times
When updating github statuses, it happens that we face a "Bad gateway"
from github. In that case, the error is logged in the runbot logs and
that's it. As a consequence, when the runbot_merge is waiting status for
the staging branch and this kind of error occurs, the runbot_merge
timeouts and the users vainly search the reason.

With this commit, the runbot tries to update the status at least twice.
If it fails, an INFO message is logged on the build itself.
2019-06-19 10:20:38 +02:00
Xavier-Do
2fb0f2c79a [FIX] runbot: kill children even if state is done 2019-06-18 13:33:45 +02:00
Christophe Monniez
ae1eed46f5 [IMP] runbot: add optional warning message on frontend 2019-06-18 12:43:25 +02:00
Xavier-Do
6d36455ef1 [FIX] runbot: ensure that job and build end are always set. 2019-06-18 12:42:07 +02:00
Xavier-Do
af7a8b7d8b [IMP] runbot: kill subbuild when killing build 2019-06-18 12:42:07 +02:00
Xavier-Do
a246d60c71 [IMP] runbot: always create new build at rebuild 2019-06-18 12:42:07 +02:00
Xavier-Do
17c57d499e [IMP] runbot: exact rebuild
allow to rebuild using exact config, dependencies, ...
2019-06-18 12:42:07 +02:00
Xavier-Do
7e9826ba4c [IMP] runbot: add build creation log 2019-06-18 12:42:07 +02:00
Xavier-Do
bdc6506ede [IMP] runbot: always keep one empty slot when assigning sheduled
Nightly build have a low priority but once they have a slot, they keep it.
When pushing a branch or asking robodoo to nicelly merge a branch for the
third time at 22:00, there may be no slot left since all the nightly build are created.

This commit will only assign scheduled build if there is no other build to create and
will always keep a free slot for other builds.
2019-06-18 12:42:07 +02:00
Xavier-Do
86ffeac589 [FIX] runbot: test_enable should be True by default 2019-06-18 12:42:07 +02:00
Christophe Monniez
b98ff23cd9 [IMP] runbot: add write_file and make_dirs methods
When using a "python job", it's sometimes useful to write a file or
create a directory.
Instead of giving a wide open access to the os module in the
"_run_python" context, this commit adds a write_file and make_dirs
methods on the build which is usable in the _run_python eval context.
2019-06-18 11:50:48 +02:00
Christophe Monniez
800691a14c [IMP] runbot: add a mode parameter to readfile
When using the read_method in a "python job", it's sometimes needed to
read a file in binary mode.

With this commit, the mode can be specified when calling the method.
2019-06-18 11:50:48 +02:00
Christophe Monniez
799f3aed22 [IMP] runbot: add more objects in run python
Since the use of the "python jobs", we spotted various needs that were
not fulfilled. In order to add flexibility to "python jobs", this commit
adds some useful objetcs in the _run_python eval context.

Also, the glob.glob function is given instead of the whole glob module
to avoid giving access to the os module via glob.os.
2019-06-18 11:50:48 +02:00
Christophe Monniez
a9cd5d7a60 [IMP] runbot: allow to configure workers per host
When a runbot instance is scheduling builds, the numbers of builds
depends of a global ir.config_parameter. Even if one of the runbot
instance is running on a more powerful systsem, its number of workers is
limited by this global parameter.

With this commit, this parameter still exists but can be overriden by
specific ir.config_parameter.

For example, if the host 'runbot24.odoo.com' has more cpu power, the
number of workers for this host can be specified in the
ir.config_parameter named 'runbot24.odoo.com.workers'.
2019-06-17 12:44:14 +02:00
Christophe Monniez
c49e4d21ad [IMP] runbot: allow a parent to ignore some child builds
In a create config, a parent result is computed based on children
results

In some situations, it could be handy to ignore the result of some
sub-builds.

Example: the nightly tests are just the children of one nightly build
with a create config. The external tests are failing randomly and as a
consequence, the nightly result is always red. On the other hand,
keeping the test running, just to have logs is a good idea.

With this commit, a config_step of type create can be marked as
orphan_result, that way, the result is not taken into account in the
parent build result.
2019-05-23 12:32:35 +02:00
Christophe Monniez
c24df5fac2 [FIX] runbot: choose quickconnect build with same config
When the quickconnect button is used, the last running build is
searched in the last 10 builds. If no running build is found, the last
one is rebuilt, even if it's a nightly build.

With this commit, the quickconnect build is choosen only among the ones
with the same config.
2019-05-23 10:52:13 +02:00
Xavier-Do
0384f2c98b [FIX] runbot: correct indentation 2019-05-22 14:08:45 +02:00
Christophe Monniez
b31735406d [FIX] runbot: adapt build write method to api multi
And add tests to avoid regression.
2019-05-22 10:58:30 +02:00
Xavier-Do
534368b675 [FIX] runbot: minimize transactionnal errors
With recursive states computation, schedule is
most likely to have transactionnal errors.
This is particularly a problem when external
operations are done during the transaction,
like running a docker.

Adding some commits will help to reduce
transactionnal errors, and ensure that the db
is consistent with docker states.
2019-05-22 10:15:53 +02:00
Christophe Monniez
45516f9d33 [FIX] runbot: properly call _log when time exceeds 2019-05-22 09:25:56 +02:00
Christophe Monniez
5761fd1694 [FIX] runbot: properly omit manifest files in coverage 2019-05-21 23:21:45 +02:00
Xavier-Do
519f50790d [FIX] runbot: make python jobs usable and improve logs 2019-05-21 16:03:47 +02:00
Christophe Monniez
d55a71d675 [FIX] runbot: oversight of a repo arg not needed anymore 2019-05-20 11:23:27 +02:00
Xavier-Do
427639b77a [FIX] runbot: various fixes (data improvement, python step, logs, ...) 2019-05-20 10:52:13 +02:00
Xavier-Do
8a7e0b20aa [FIX] runbot: fix config access rights 2019-05-18 15:13:21 +02:00
Xavier-Do
98913f6d39 [FIX] runbot: fix cla step 2019-05-18 14:20:05 +02:00
Xavier-Do
fce51d6dbe [FIX] runbot: correctly store get_ref_time 2019-05-18 11:16:08 +02:00
Christophe Monniez
16e1eaa30b [IMP] runbot: decrease for-each-ref calls
When searchings for new refs to create builds, the for-each-ref git
commit is run and each ref is searched in the database which is a
somewhat heavy operation.

With this commit, the timestamp of the last database update with the
refs is stored in a field on the repo. This timestamp is checked each
time a for-each-ref is needed, running the operation only when
necessary.
2019-05-18 10:42:31 +02:00
Xavier-Do
8ef6bcfde7 [IMP] runbot: replace jobs by build configs
This commit aims to replace static jobs by fully configurable build config.

Each build has a config (custom or inherited from repo or branch).
Each config has a list of steps.
For now, a step can test/run odoo or create a new child build. A python job is
also available.

The mimic the previous behaviour of runbot, a default config is available with
three steps, an install of base, an install+test of all modules, and a last step
for run.

Multibuilds are replace by a config containing cretaion steps.
The created builds are not displayed in main views, but are available
on parent build log page. The result of a parent takes the result of
all children into account.

This new mechanics will help to create some custom behaviours for specifics
use cases, and latter help to parallelise work.
2019-05-18 10:42:31 +02:00
Christophe Monniez
bb35b1cc9d [FIX] runbot: remove typo that prevent kill when timeout 2019-05-14 11:54:59 +02:00
Christophe Monniez
cff0133e1a [FIX] runbot: convert runbot_timeout to int
The cpu limit used in job_20 uses the runbot_timeout config_parameter
since b539112a7e. When measuring coverage, this parameter is multiplied
and leads to an error because the type of ir.config_parameter.get_param
method is str.

With this commit, the this value is converted into integer before usage
in job_20.
2019-05-12 19:29:07 +02:00
Christophe Monniez
12acfda83a [FIX] runbot: add dbuser parameter to the odoo cmd
When running Odoo in the Docker container, the username used to connect
to the database is the username defined in the docker container
(actually odoo).

A problem may arise if the user of the runbot process is not the same.
An authentication error is then raised by postgres because of the
username mismatch.

With this commit, the '-r' parameter of Odoo is added to the command
with the username used by the runbot process.

While at it, unused imports are removed.
2019-05-10 11:42:18 +02:00
Christophe Monniez
b539112a7e [FIX] runbot: make the cpu limit the same as the runbot timeout
When a build exceeds the cpu limit, it is simply killed by the kernel.
As a safeguard the "Initiating shutdown." sentence should be searched
in the log file, and the build marked as "ko" if not found.

Unfortunateley, there is no period (.) at the end of the sentence in the
Odoo logs (see: https://github.com/odoo/odoo/blob/12.0/odoo/service/server.py#L444)
Thus, this condition is never fulfilled.
On top of that, this was masked by the first part of the condition,
checking that the 'test/common.py' has no "post_install" string.
The "test" directory does not exists in Odoo ( but "tests" exists) , so
the condition was always falsy.

Finally, a build can be marked as "ok" when he is killed and no errors
are found until the kill.

With this commit:
    * The legacy grep for post_install is removed as it now exists in
      all Odoo supported versions.
    * The period typo is fixed.
    * A log is inserted when the final sentence is not found.
    * The cpu_limit is set as the same as the runbot_timeout parameter
      for better consitency.
    * The time exceeded log message is now logged in the build instead
      of the runbot log.

Co-authored-by: @Xavier-Do
2019-05-10 10:56:55 +02:00
Christophe Monniez
75e56d944a [IMP] runbot: use a separate method for git fetch command
At the end of the _update_git method, the "git fetch" command is run.
That makes it diffcult to override to change its behavior (for example
to avoid fetching pull requests).

With this commit, the command is separated in a new small method that
can be easily overriden.
2019-05-03 16:52:54 +02:00
Christophe Monniez
5dd889de3c [IMP] runbot: split branch creation and pending builds creation
When searching for new builds by parsing git refs, the new branches are
created as well as the pending builds in the same _find_new_commits
method.

With this commit, this behavior is splitted into two methods, that way,
it's now possible to create missing branches without creating new
builds. The closest_branch detection is enhanced because all the new
branches are created before the builds (separated loops).

The find_new_commits method uses an optimized way to search for
existsing builds. Before this commit, a build search was performed for
each git reference, potentially a huge number.

With this commit, a raw sql query is performed to create a set of tuples
(branch_id, sha) which is enough to decide if a build already exists.

A test was added to verify that new refs leads to pending builds.

Also, a performance test was added but is skipped by default because it
needs an existing repo with 20000 branches in the database so it will
not work with an empty database. This test showed a gain of performance
from 8sec to 2sec when creating builds from new commits.

co-authored by @Xavier-Do
2019-05-03 10:34:49 +02:00
Christophe Monniez
e5420f7a3a [FIX] runbot: add missing repo parameter 2019-04-25 21:51:01 +02:00
XavierDo
e323aa888d [IMP] runbot: add dependencies to build
Before this commit, dependencies (i.e. community commit to use when testing enterprise)
were computed at checkout, when the build was going from pending to testing state and
were not stored.

Since the duplicate detection was done at create, the get_closest_branch_name was called
in a loop for each posible duplicate candidate, then a last time at checkout. The main idea of this
pr is to store the build dependecies on build at create, making the duplicate detection
faster (especially when the build name is matching many indirect builds).

The side effect of this change is that the build dependencies won't be affected if a new
commit is pushed between the build creation and the checkout. The build is fully
determined at creation. get_closest_branch is only called once per build

The duplicate detection will also be more precise since we are matching on the commits groups
that were used to run the build, and not only the branch name.

Some work has also been done to rework the closest branch detection in order to manage new corner
cases. Hopefully, everything should work as before (or in a better way).

In a soon future, it will also be possible to use this information to make an "exact rebuild"
or to find corresponding community build.

Pr: #117
2019-04-25 17:58:51 +02:00
XavierDo
5b22d57566 [IMP] runbot: move build closest_branch_name to branch
Closest_branch is more branch scope related, puting it in branch instead of build
will ease testing and refactoring.

PR: #117
2019-04-25 17:58:51 +02:00
Christophe Monniez
8aeabb01e3 [IMP] runbot: give priority to normal builds
When some special builds are scheduled during the night, free slots on
runbot instances are used. Depending on the number of scheduled builds,
all the slots can be used. That prevents people to use the runbot for
normal builds during this time.
To mitigate the problem, the scheduled builds were postponed to the
middle of the night ... the CET night. It means that it could be morning
in India.

With this commit, a build priority is given to normal builds. On the
other hand, scheduled builds are pushed at the end of the queue.

So even if there are plenty of builds during the Belgian night, if
someone pushes a commit in between, it will be built in priority before
the scheduled pending builds.
2019-04-23 13:24:32 +02:00
Christophe Monniez
84ea0e7ef2 [FIX] runbot: use a repo short name to avoid bugs in qweb template
When using a local git repo, the git name does not have colon, making
the frontend crash.

With this commit, a non-stored computed field 'short_name' is added to
compute a shortest version of the name.
2019-04-19 15:52:28 +02:00
Christophe Monniez
82f881d9e6 [IMP] runbot: detach odoo command from docker_run
When the docker_run function is called, the odoo command is decorated
with a pip command to install required packages.
This pollute the docker_run function if a runbot job_ method wants to
use docker for something else that starting an odoo instance (like
pg_dump) for example.

With this commit, command modification is made in an optional helper
function named build_odoo_cmd.

the docker_run function now needs the command to run as a string instead
of a list of odoo cmd and its parameters.
2019-04-16 16:41:50 +02:00
Christophe Monniez
574105b66c [FIX] runbot: allow to kill a duplicate
Asking for the kill of a build which is the duplicate of another fails
because the state of this build is "duplicate", so the _ask_kill method
has no effect on it.

With this commit, the effect of _ask_kill is applied on the duplicate in
the above mentioned case.
2019-03-28 13:46:20 +01:00
Christophe Monniez
eb68de40f3 [FIX] runbot: speedup and limit search in frontend
When searching the builds for the frontend the resulting query can last
a very long time (up to 7sec).

With this commit, the search result is strictly limited to 100 builds,
the limit query parameter is removed and the search string length is limited to
60 chars.

The guess_result method is now optimized to guess results for testing
builds only. The others have the same value as the final result.
A few tests were added for this method.
Thanks @KangOl for the optimization code.
2019-03-19 16:55:36 +01:00
Christophe Monniez
f50b13172d [FIX] runbot: ivalidate cache to get valid hook_time
When github reaches the hook controller, the repo hook_time field is
updated. That way, a git fetch is done only when the hook_time is newer
that the last fetch. If the hook_time is updated during the long running
cron that runs the _cron_fetch_and_schedule method, the hook_time is cached
and only the old hook time is seen until the cron's end. The cursor
commit is not enough. As a result, the new builds are scheduled in the
next cron run.

With this commit, the cache is invalidated after the commit, that way,
the hook_time field contains the correct value.
2019-03-15 08:08:22 +01:00
Christophe Monniez
64694a6b0b [FIX] runbot: find duplicate when no PR in community
When a PR is created in odoo/enterprise but without a corresponding
PR in odoo/community BUT a corresponding branch in odoo-dev/community,
the closest_branch detection fails. Moreover, the duplicate detection
fails too.

As a consequence, the PR build will probably fail because it will be
built with the default target branch that could not be suited for it.
If the branch built succeeds, it leads to inconsistent results.

With this commit, a new case is added on the _get_closests_branch_name
to handle this case.
The serever_match field also reflects the difference as this case will
be marked as 'no PR'.
When a PR also exists in odoo/community, the server_match field will be
'exact PR'. This change should not imply migration.

This commit also adds a bunch of tests to test the closests branch name
detection and the duplicates.

Co-authored by @Xavier-Do
2019-03-14 08:59:13 +01:00
Christophe Monniez
da6551c28c [FIX] runbot: properly convert update frequency into integer 2019-03-11 22:01:17 +01:00
Christophe Simonis
10b456deda [FIX] runbot: update git before logging last commit 2019-03-07 10:40:54 +01:00
Christophe Monniez
51938247d8 [FIX] runbot: send failure status to github when result is warn
When a runbot build ends without error but with one or more warning,
status are not sent to github. As a result, the PR stays in pending
state.

With this commit, the github status is set to failure when a build ends
in a "warn" result.
2019-03-01 17:33:03 +01:00
Christophe Monniez
286b1a3d30 [FIX] runbot: update dependency repo before checkout
At checkout time when a build has no server (e.g. enterprise),
the dependency repo that contains the server needs to be extracted too.
It happens that this dependency repo is not up to date.

With this commit, the dependency repo is updated before its extracttion.
2019-02-26 17:34:34 +01:00
Christophe Monniez
6e57b0954d [FIX] runbot: limit duplicate builds search to one
When searching for duplicate builds, a git ls-remote is used to verify
that the branch still exists. This command is time consuming (up to 2
seconds).

If the number of build is significant, it can last a very long time.

When a user push one ore more new branches without new commits, the
number of duplicate builds found may be very large (more than 92).
This loop blocks the cron wroker in charge of creating new builds.

This quick fix will limit the number of duplicate to 1 but if the
closest name is not the same, it will not be considered as a duplicate.
2019-02-26 15:44:58 +01:00
Christophe Monniez
41ce858c93 [FIX] runbot: fix oversight of logging reason in _skip
When giving a reason of a build skip, the reason paramater was missing
in the logging string.

Test is also added to verify the build skip.
2019-02-26 10:19:54 +01:00
Christophe Monniez
1617a2e339 [FIX] runbot: force repo update on runbot builders
When a runbot execute the cron_fetch_and_build method, the repo is
updated only if the webhook time is newer than the last fetch
time.

As the cron is now split into long running crons, the hook_time field is
cached. The runbot instance that sees a new build pending use this
cached value to estimate if the repo update is needed.

With this commit, the repo update is done right before exporting the
repo and only if the commit hash is not found.

As a bonus, the environment is reset in the long running cron of the
runbot builders to update the cached values.
2019-02-25 17:35:22 +01:00
Christophe Monniez
fe018aeefa [REF] runbot: split cron to speed up builds
The Runbot Cron is executed on each runbot instance. When the number of
instances scales, the time needed for an instance to obtain the cron
increases.

With this commit, the original runbot_cron is removed. Instead, a cron
have to be created to run the _cron_fetch_and_schedule method.
This method will fetch the repo and create pending builds. This cron is
intended to run only on one runbot instance. This method needs a host
parameter to specify which runbot instance will be in charge of this
task.

On the other hand, a dedicated cron have to be manually created for each
runbot instance that will have the build task.
Those cron's only have to call the _cron_fetch_and_build method with the
runbot hostname as a parameter. This method will then self
assign pending builds if there are slots available.
All available build slots are reserved in a single LOCKED SQL query.

Both methods are intended to last a large amount of time, just a few
minutes below the cron timeout to maximize the cron productivity.
The timeout is randomized to avoid deadlocks if the runbot instances are
started at the same time.

So the --limit-time-real parameter have to be set to a minimum of 180
sec (600 or 1200 are probably better targets).
2019-02-25 11:25:41 +01:00
Christophe Monniez
602298330a [IMP] runbot: send status earlier when the build fails
When a user checks the runbot frontend, the guess_result field is used
to change the color of the build state. But github is not notified of
this guessed result.

As a consequence, the runbot_merge is not aware the build is failed and
will continue to wait.

With this commit, as soon as the guess_result detects a failure, the
status is sent to github, that way, runbot_merge will stop waiting
sooner.
2019-02-21 13:11:46 +01:00
Christophe Monniez
2c7feffd5e [IMP] runbot: avoid running test when installing base
When running the _job_10 method, a database is created with base module
alone. Tests are enabled during this job. Those tests are run again with
the _job_20 method. Moreover, even if the tests fail during _job_10,
they are not taken into account for the final result. The _job_10 method
duration is approximately 4 min.

With this commit, the tests are not enabled during _job_10.
2019-02-21 13:11:46 +01:00
Christophe Monniez
809f5639c2 [FIX] runbot: remove common ancestor case
Useless merge-base command is causing timeouts on runbots.
2019-02-20 10:09:36 +01:00
Christophe Simonis
338166e474 [FIX] runbot: correct pg version detection
`local_cr` is directly a psycopg cursor, not an odoo one.
2019-01-31 16:29:21 +01:00
Christophe Simonis
5697f1ab9c [FIX] runbot: terminate all active queries before dropping database
The docker using this database may still be alive.
2019-01-31 15:37:04 +01:00
Christophe Monniez
3632463f80 [IMP] runbot: adapt test for github status
Adapt test for eb7f5de . The mentioned commit fixes an issue that occurs
when updating github status. A test already exists but was assuming that
the build is in 'done' state when reaching the job_29.

With this commit, the build used in test is set to 'testing' state like
in the real cases.

Also, a new test is added to test the job_00_init which also send
github status but with a minimal build.

Finally, the runtime that should appear in status description was
forgotten in the previous commit. Now the runtime is always sent with
the github status.
2019-01-24 21:31:23 +01:00
Christophe Monniez
eb7f5de218 [FIX] runbot: update github status with correct state
Since d7c7e54 the github status is send in job_29. At this moment, the
state of the build is still 'testing'. For that reason, the github
status is set to 'pending'.

With this commit, once a result is available, the github status is
updated with the right value even if the build state is 'testing'.
2019-01-24 11:16:51 +01:00
Christophe Monniez
d7c7e547d4 [FIX] runbot: write build results in a separate job
When a build reach the job30_run method, results from a previous testing
methods are computed.
With the previous commit 8c73e6a901 this
job can now be skipped. In that case, the results are not set.

With this commit, the results are computed in a separate method.
2019-01-23 16:10:59 +01:00
Christophe Monniez
2e05c56354 [FIX] runbot: prevent build creation on job_type none
Since 8c73e6a it's possible to skip jobs from a build by using the
job_type field on the branch. If a branch job_type is set to 'none', the
builds are created but they stay in 'pending' state.

With this commit, the build is not even created if the 'job_type' is
'none'.
2019-01-23 14:38:29 +01:00
Xavier Morel
8c73e6a901 [IMP] runbot: add a job_type on branch and build
Since the runbot_merge module, some branches does not need to be built.
For example the tmp.* branches.
Some other branches does need to be tested but it could be useless to
keep them running. For example the staging branches.
Finally, some builds are generated by server actions during the night.
Those builds does not need to be kept running despite the branch configuration.

For example, the master branch can be configured to create builds with
testing and running but nightly multiple builds can be generated with
testing only.

For that purpose, this commit adds a job_type selection field on the
branch. That way, a branch can be configured by selecting the type of
jobs wanted.
A same kind of job_type was also added on the build that uses the
branch's value if nothing is specified at build creation.

A decorator is used on the job_ methods to specify their job types.
For example, a job method decorated by 'testing' will run if the
branch/build job_type is 'testing' or 'all'.
2019-01-22 14:18:58 +01:00
Christophe Monniez
8ef9eafc60 [IMP] runbot: get the logdb uri from a config parameter
When a build is created, the --log-db command line argument is built
using the same db and credentials that the one used by the runbot.

With this commit, this argument is built based on a postgress connect
URI given as ir.config_parameter in the settings.

A dedicated role must be created beforehand on the runbot postgresql
server, accordingly to the given URI.

Also, care should be taken to give minimal privileges to this user only
granting "update" on the table ir_logging_id_seq and
"insert,select,udpate" on the table ir_logging.
2019-01-18 09:43:56 +01:00
Christophe Monniez
989513801a [FIX] runbot: find docker gateway for build smtp host
When a build is running, the stmp is the localhost.
Since Docker builds, the localhost is the container which does not catch
port 25 smtp. Mails are lost in the limbo.

With this commit, the default gateway of the Docker network is used as
smtp host for the builds. It's the responsability of the runbot host to
catch smtp traffic from the container.

This bridge interface exists by default on a system where Docker is
running. However, Docker is affected by this issue:
https://github.com/moby/moby/issues/26799

The first time the Docker daemon is installed, the Gateway is not
defined on the bridge interface. When the Docker daemon is restarted,
the gateway is correctly defined. Pay attention that restarting the
Docker daemon will kill all the running/testing builds.
2019-01-11 10:23:27 +01:00
Christophe Monniez
4c0cd91914 [REF] runbot: use Docker containers for builds
When building Odoo, the instance is started on the same host as the
runbot. It means that all the required python packages have to be
installed on each runbot hosts with the same versions. Also there is no
real separation between builds. Finally, from a security point of view,
arbitrary code could be executed on the runbot host.

With this commit, the runbot uses Docker containers to build Odoo.
During the tests, Odoo http ports are not exposed to the outside,
meaning that nobody could interact with that instance.

The Docker image used for containers is valid for Odoo branches 10.0,
11.0, 12.0 and master.

When building, right before starting the Odoo tests, the tested branch's
requirements.txt is now taken into account to adapt the container.

On a runbot host, the "docker ps -a" command can be used to have the
list of the current builds. The containers are named using the build
dest field and the current running job. For example:
  123456-12-0-123456_job_30_run

Prerequisites:

Docker have to be installed on the runbot hosts and the user that runs
the runbot should be able to use Docker. Typically, the runbot user have
to be added to the docker unix group.

On the first build, the Docker image will be built from scratch. It
can last several minutes locking the runbot cron during this time.
It means that on a multi-runbot configuration, this process will be
repeated for each runbot and during this time there will be no builds.

To avoid such a situation, the Docker image can be built from the
command line. The container.py file can be started like this:

  python3 container.py build /tmp/build_dir

The /tmp/build_dir directory will be created to store the Dockerfile.

When the process is done, the "docker images" command should show an
image tagged runbot_tests in the odoo repository. At that time, the
runbot instance can be started, it will use this image for the builds.

Api change:

The 'job_*' methods signature has changed, the lock_path is not needed anymore.

Docker image informations:

Currently, the Docker image is built based on Ubuntu bionic to
benefit of the python 3.6 version.

Chrome and phantomjs are both installed.

The latest wkhtmltopdf (0.12.5) is installed as recommended on our wiki:
https://github.com/odoo/odoo/wiki/Wkhtmltopdf
2019-01-02 11:32:04 +01:00
Christophe Monniez
a0dd87e45b [FIX] runbot, runbot_cla: notify each repo of cla status
When a PR is a duplicate of a branch, only the branch CLA status are
update. The same issue for build status was fixed in commit 4f1a55da9.

With this commit, there is new method than can be used in runbot_cla.
This method updates commit given status in each repo.
2018-12-07 09:43:16 +01:00
Christophe Monniez
4f1a55da9b [FIX] runbot: reduce the amount of github status
When commit is built serveral times, each time the status is updated, a
request is sent to github for each build.
As a side effect, if the first build is a failure and the last one a
success, github is wrongly updated to failure.
This bug is particulary annoying on PR in conjunction with the
runbot_merge, preventing a the PR to be merged even after several
rebuild.

With this commit, only the latest build per repository is used to update
the github status. The amount of github status updates is also reduced.
2018-12-06 10:53:45 +01:00
Christophe Monniez
248d23c2d0 [FIX] runbot: remove typo 2018-11-29 16:53:10 +01:00
Christophe Monniez
922be0a594 [FIX] runbot: split _get_branch_url again to avoid mass recompute 2018-11-29 16:48:34 +01:00
Christophe Monniez
c14b864b06 [FIX] runbot: fix branch infos singleton 2018-11-29 16:31:38 +01:00
Christophe Monniez
1330d52098 [REF] runbot: store the target branch name
In the case of PR, the name contains 'refs/pull/3175', the branch_name
contains '3175' and because of the previous fix e095170f8c, the
pull_head_name sontains something like 'blah:12.0-something'.

In that case, the _get_closest_branch_name reaches the fallback.

With this commit, the target_branch_name is stored in a new field and is
used as the fallback.
2018-11-29 16:18:33 +01:00
Christophe Monniez
e095170f8c [FIX] runbot: build PR with corresponding community PR
When searching for a matching PR in a target repo, the match was made on
the 'base ref' which is the base branch that the PR targets.
This means that the second case of the _get_closest_branch method was
never reached.

Example:
    An enterprise PR is created that targets Odoo branch 12.0 but with a
    matching community PR with a branch with the same name.
    The corresponding PR is never found by the runbot because the first
    rule match: '12.0' is the base ref of the PR.

This could have been fixed by using the branch pull_head_name field to
build the domain but that leads to a problem with the second rule:

If a PR branch is named 'patch-1', the domain will match each PR with
the same pull_head_name.

With this commit, the pull_head_name field will store the pull head
label. It's not a problem with older PR as a newly created PR in
enterprise will not accidentally match with older ones.

Another issue appeared with github branch naming like 'patch-'.
If someone creates a PR with a branch auto-named 'patch-1',
targeting the community repo and later creates an unrelated PR,
targetting another repo depending of the community, they will be
matched.

To avoid that, the pull head names that ends with 'patch-n' are not
stored. Those pull requests will be built against the target branch
head.

The actual behavior, before this commit, is a blocking point for the
runbot_merge which is based on PR's only. It means that when a community
PR is wrongly matched with with an enterprise PR runbot_merge will not
merge the PR's.
2018-11-28 15:28:38 +01:00
Christophe Monniez
439e336a2f
[FIX] runbot: store pull_head_name on branch
This one flew under the radar because it only affects a PR when its
branch name changes.

Closes #47
2018-10-19 08:50:20 +02:00
Christophe Monniez
070dbee204
[IMP] runbot: add priority field on branch
This commit permits to prioritize a branch when scheduling builds.
It's main purpose is for the runbot_merge module. It avoids to have
staging branches as sticky and pollutes the main repo view.
Also, that branch can benefit of the autokill feature when a newer build
is found, freeing ressources for other builds.

Closes #43
2018-10-09 16:42:34 +02:00
Andreas Perhab
3915f3d7ae [IMP] runbot: perform fetch with one git command
Closes: #33
2018-09-06 11:56:58 +02:00
Christophe Monniez
cfba7da06d
[IMP] runbot: skip an additional port for chrome
In a near future, Odoo will use Chrome Headless instead of phantomjs.
Chrome needs a port to listen to and it was decided that it will be
http_port + 2.
With this commit, we ensure that this port is not used by another build.

Closes #30
2018-08-14 13:57:31 +02:00
Christophe Monniez
52cdd9fd27
[FIX] runbot: add build type
The unicode icon added in the build subject is not clear for the users.
In that state, it's not easy to add a title on the icon or the subject.

With this commit, a build type field is added to differentiate the
builds and add the appropriate icon and title.

Closes: #24
2018-06-18 10:42:23 +02:00
Christophe Monniez
8471c8c35b
[FIX] runbot: improve coverage processing
When a build with coverage is killed during the tests, the coverage
result is set to 100%.

With this commit, coverage result is verbosely skipped if the coverage
file does not exists.

Also, the coverage module is no longer user to retrieve the coverage
value as it was already calculated. It's faster to grep the html file
than to recompute the value.

As the coverage builds takes a longer time than normal builds, the
timeout is increased for those kind of builds (as it was already done for the
CPU limit).

Finally, the omitted patterns were wrong and are now fixed with this
commit.

Closes #25
2018-06-15 13:30:04 +02:00
Christophe Monniez
822433a3bb
[IMP] runbot: add link to the latest coverage
On the frontend, the coverage is a static indication.
With this commit, this indication is now a link to the coverage details
page.

Closes: #26
2018-06-12 09:04:09 +02:00
Christophe Monniez
a3da5cad04
[IMP] runbot: increase cpu_limit
When the Odoo instances are spawned for tests, they have a time limit
set on their CPU usage. This limit is hard-coded in the _spawn method
calls.

As the number of tests are increasing, their duration increases too.
As this limit is inherited by subprocesses, if a phantomjs test
last too long, the test is killed alone.

Finally, when the coverage is enabled, the tests duration is
approximately increased of 1.5 times.

With this commit, the cpu_limit of the two main tests jobs are
increased. When the coverage is used, the cpu_limit is increased.

Closes: #23
2018-06-11 17:58:29 +02:00
Christophe Monniez
b1f155c1a2
[IMP] runbot: kill older builds when a new one is created
When a new commit is found and a new build is created, if a user
pushes more commits in the same branch a few minutes later, it causes
more builds in testing phase, resulting in a CPU waste.

With this commit, previous builds in testing phase in non sticky
branches are killed when a new build is created.

Closes: #20
2018-06-06 16:31:33 +02:00
Christophe Monniez
c6fe87e18b
[IMP] runbot: update nginx template
When someone tries to log in an old runbot build that is not running
anymore, he lands on the runbot instance that was running the build.
Also, all the running builds are allowed on all runbot instances,
leading to the same behavior.

With this commit, only the builds that are running on the runbot
instance can be reached, others are defaulted to a 404.

closes #21
2018-06-01 16:37:43 +02:00
Christophe Simonis
7fcbf6e653 [IMP] runbot: visually mark rebuilds 2018-06-01 16:31:57 +02:00
Christophe Monniez
223ba61828 [IMP] runbot: add coverage result on builds
When the coverage is activated on a branch, the coverage result is not
stored.

With this commit, the coverage result will be stored on a build.
The last result will be shown on the frontend for sticky branches.

Also, an extra_parameter field is added on the build model.
2018-05-28 09:40:01 +02:00
Christophe Monniez
46c4c54337 [IMP] runbot: force a rebuild when commit in reverse dependency
When a build fails in a repo that depends on another repo, it's difficult
to figure out from which commit it comes in the depending repo.

If this commit is applied, when a new commit is found in a repo's sticky
branch, the latest build from the same branch name, in the depending
repo will be forced to rebuild.
2018-05-28 09:40:01 +02:00
Christophe Monniez
5d23d0957a [FIX] runbot: remove deprecated method
The refresh method is deprecated and invalidate_cache should be used
instead. Also, since the new API, the cache is automatically
invalidated, hence this removal.
2018-05-28 09:40:01 +02:00
Christophe Monniez
9555370fa6
[FIX] runbot: update github status on duplicates too
Actually, when a build is a duplicate of another build, its github status is not updated.
e.g. a pull request may not have a github status but its corresponding
branch have a gtihub status.
With this commit, all builds will have their github status updated based
on the corresponding build status.

Thanks for your help @xmo-odoo 

closes: #3
2018-04-27 13:39:33 +02:00
Christophe Monniez
efbce41e2e
[IMP] runbot: choose the python version for coverage
When code coverage was processed the 'coverage' utility was called the
same way regardless of the Odoo version. That was the cause of two
problems:
1) In some OS packages, the 'coverage' executable was renamed to
'python-coverage' and 'python3-coverage'
2) Since version 11.0, Odoo needs python3

With this commit, the coverage module is called from python '-m'
argument and the python version is chosen from the Odoo executable
shebang.

closes: #12
2018-04-20 16:16:24 +02:00
Christophe Monniez
12542808a9 [IMP] runbot: log latest commit hash and message when server is built
When a server is built based on dependency_ids, only the branch refs was
logged. In this situation, it's difficult to reproduce a build locally
in the exact same conditions.

With this commit, the latest commit hash and message of this
branch is also logged.
2018-04-20 10:37:52 +02:00
Christophe Monniez
0cb07e73db
[FIX] runbot: return closest branch when PR head name are equals (#11)
When searching for the closest branch name in a target repo, if the PR
head names are equals, a branch method is called on a dictionary, causing
a traceback.

With this commit, the method is called on a branch object instance.

closes #11
2018-04-19 16:16:24 +02:00
Martin Trigaux
4a558741e0 [FIX] runbot: remove unused argument
Leftover from the old api conversion
Making an error when trying to kill a build
2018-04-10 09:02:36 +02:00
Moisés López
9de7c2f8cf [FIX] runbot: Use correct name of new parameters 2018-03-28 10:29:39 +02:00
Moisés López
8b4b941e06 [FIX] runbot: dictionary don't have iteritems attibute 2018-03-28 10:29:39 +02:00
Moisés López
a886dba4ab [FIX] runbot: Fix decode error 2018-03-28 10:29:39 +02:00
Moisés López
c9de61a320 [REF] runbot: Consider empty returned values
When installing a clean runbot instance a bad query is made because
there is not any build yet.

With this commmit, the query is not made when there are no builds
directories found on the filesystem.
2018-03-28 09:42:52 +02:00
Julien Legros
3cacd8db52
[FIX] runbot: build garbage collection 2018-03-23 14:20:34 +01:00
Julien Legros
f8cbae79e1
[FIX] runbot: nginx reload
Actually check the return code and do not raise any exception doing so.
2018-03-21 13:06:32 +01:00
Christophe Simonis
dc3659c6f1 [FIX] runbot: use connected user when logging kill/rebuild
As these methods are call in sudo mode, we should use request's user to
have a meaningful log entry.
2018-03-20 10:20:53 +01:00
Julien Legros
278d4ed449
[FIX] runbot: guess_result conversion to record api 2018-03-16 10:16:44 +01:00
Julien Legros
3d71619dcd
[FIX] runbot: make repo_id stored again
Oversight of the code migration.
2018-03-14 16:02:08 +01:00
Julien Legros
328a25a31f
[FIX] runbot: do not rely on copy behavior for rebuilds
Instead of marking most fields as `copy=False` to be able to use the
copy method for rebuilds, we create the build explicitly. We also
forbid to copy builds as it doesn't make much sense to begin with.

As for duplicates, it wasn't always possible to rebuild them. The
rebuild now injects a specific context key (force_rebuild). This allows
duplicates to undergo a rebuild. The side-effect of writing on previous
builds is also removed[1].

[1]: it's not obvious from the diff but the porting to the V8 API
should have yielded

duplicate.write({'duplicate_id': build_id.id})

instead of

build_id.write({'duplicate_id': build_id.id})
2018-03-14 15:05:17 +01:00
Christophe Monniez
e9a292373f [FIX] runbot: compute build time and don't copy from previous build
Before this commit, the job_end was always None because of a time2str
function with no return. So the job_time was the same as the job age.
Also, the result and times were copied from the prvious build. Displayed
time and results were wrong.
2018-03-13 16:38:20 +01:00
Christophe Monniez
5b8184890e [FIX] runbot: sync the build sequence with the build id
The branch order was wrong because of a zeroed build sequence.
2018-03-12 18:14:17 +01:00
Christophe Monniez
4b0eac3b21 [FIX] runbot: compute repository url 2018-03-12 17:43:24 +01:00
Christophe Monniez
21c31b4c3c [REF] runbot, runbot_cla: upgrade to Odoo 11.0
The previous code of runbot and runbot_cla was made for Odoo API version
8.0. This commit makes it work with Odoo API 11.0 and Python 3.

Also, the present refactoring splits the code into multiple files to
make it easier to read (I hope).

The main change due to Python 3 is the job locking mechanism:
Since PEP-446 file descriptors are non-inheritable by default.
A new method (os.set_inheritable) was introduced to explicitely make
fd inheritable. Also, the close_fds parameter of the subprocess.Popen
method is now True by default.

Finally, PEP-3151 changed the exception raised by fcntl.flock from IOError to OSError
(and IOError became an alias of OSError).

As a consequence of all that, the runbot locking mechanism to check if a
job is finished was not working in python3.
2018-03-12 14:36:33 +01:00