Commit Graph
69 Commits
Author SHA1 Message Date
Christophe Simonis a719cf2563 [MERGE] forward port branch saas-11.3 up to b4555df336 2018-07-30 17:02:28 +02:00
Christophe Simonis a6e401a2ee [MERGE] forward port branch 11.0 up to 44ea58234e 2018-07-30 14:08:56 +02:00
Christophe Simonis 248a59553d [MERGE] forward port branch saas-15 up to 535d50afbd 2018-07-30 12:53:34 +02:00
Christophe Simonis fbd52d57d8 [MERGE] forward port branch saas-14 up to b8f866c57b 2018-07-30 11:44:31 +02:00
Denis Ledoux 3096d94d9b [FIX] service: --dev=reload, exclude temporary python files
Do not reload when a temporary Python file is
added/updated/reloaded.

This is to be able to use editors using isolation when saving file.
On save, they create a temporary file which is then moved on the target file.
The temporary file exists for milliseconds only,
and when the change was detected by watchdog and the server was reloaded,
the file already no longer existed on load.
It leaded to `No such file or directory` after the reload.
2018-07-27 11:40:01 +02:00
Christophe Simonis 73652a0b19 [MERGE] forward port branch saas-11.3 up to 50860317cc
Note: 1aacc96262 has been ignored and will
be forward-ported later
2018-06-15 13:27:27 +02:00
Christophe Simonis b170a753e1 [MERGE] forward port branch 11.0 up to b05e4d5f95 2018-06-15 10:15:27 +02:00
Christophe Simonis b05e4d5f95 [MERGE] forward port branch saas-15 up to a53bea49fe 2018-06-14 21:28:39 +02:00
Christophe Simonis 803df909b1 [MERGE] forward port branch saas-14 up to 804d68efe5 2018-06-14 18:05:38 +02:00
Christophe Simonis 23a1bce2a9 [MERGE] forward port branch 9.0 up to 90165e2d96 2018-06-14 17:29:56 +02:00
Christophe Simonis af1853775f [MERGE] forward port branch 11.0 up to e3658d6f56 2018-06-12 16:49:11 +02:00
Christophe Simonis e3658d6f56 [MERGE] forward port branch saas-15 up to d44cd77884 2018-06-12 16:31:54 +02:00
Christophe Simonis d44cd77884 [MERGE] forward port branch saas-14 up to 284ed9216c 2018-06-12 12:19:14 +02:00
Rod Schouteden 5c03430d9f [FIX] service: do not break on gevent 1.3
gevent 1.3.0 removed backward compatibility on gevent.wsgi.
make the new path the default

While the recommanded version on requirements.txt is 1.1, a server can not
launched with the 1.3

Closes #24780
Fixes #24779
2018-06-11 10:42:09 +02:00
Christophe Simonis 279d928693 [FIX] core: always load base and web as server wide modules
Since 285ead28e3, `base` should be loaded
as a server wide module to enable rpc routes.
2018-06-05 14:46:24 +02:00
Christophe Simonis 2bc6ea1b37 [MERGE] forward port branch 11.0 up to 02ee3fd88e 2018-05-23 19:33:40 +02:00
Christophe Simonis 8383181b8f [MERGE] forward port branch saas-15 up to 021d0e6a98 2018-05-18 18:59:06 +02:00
Christophe Simonis 021d0e6a98 [MERGE] forward port branch saas-14 up to cabe0951af 2018-05-18 18:54:26 +02:00
Christophe Simonis bfda65d894 [MERGE] forward port branch 9.0 up to 612fd33fb1 2018-05-18 16:19:21 +02:00
Christophe Monniez c28a998d3d [IMP] server: intercept SIGXCPU and shutdown gracefully
When the runbot spawns an Odoo instance, a CPU TIME limit is set.
When this limit is reached, the kernel kills the Odoo instance and no
message appears in the logs leaving the dev in a deep smoke cloud.

With this commit, the signal sent by the kernel when the soft
limit is reached (SIGXCPU), is intercepeted and Odoo shutdown gracefully with a
nice message for the dev.
2018-05-18 11:26:46 +02:00
Christophe Monniez b356b19033 [IMP] tests: Add the possibility to tag tests
Purpose: When running tests, all the tests for the installed/updated
files are done. This commit adds a 'tagged' decorator that can be used to
tag tests. Combined with a new 'test-tags' CLI option, it adds the ability
to filter which tests are executed. For example, @tagged('slow') will
add a tag 'slow' to the test. The CLI option 'test-tags="slow"' will
only run tests tagged 'slow'.

One can use prefixes to select cases with tags.
'+' or no prefix means that the tests tagged with this tag are selected
for execution. '-' prefix will exclude the tests tagged with this tag.
Exclusion takes precedence over inclusion.

Also, by default, all Odoo tests cases are tagged 'standard' and with
the technical name of the module.
This means that when selecting tests with the 'test-tags'
parameter, if '-standard' is not specified, all tests tags are
going to be executed.
When tagging tests, one can remove such automatic tag by prefixing the
tag name with '-'. E.g. @tagged('-standard') will remove the standard
tag from the test.

Another example, if one wants to test the 'sale' module alone,
even without adding any 'tagged' decorator thos tests can be selected
like that: --test-tags="sale"

Tests are selected or deselected using a TagsSelector. When instanciated,
 a string is passed with comma separated tests selectors like
'+slow,-standard'. When the 'check' method is called  with a test as argument,
it returns True or False if the test has to be executed or not.
2018-01-18 13:20:37 +01:00
Christophe Simonis 29590a61cd [MERGE] forward port branch 11.0 up to 8fb25e185b 2017-11-28 16:57:58 +01:00
Thibault Delavallée 1fbc29a641 [MOV] base: move ir_* models into models/ 2017-11-27 11:15:03 +01:00
Adrian Torres ac5ba4a2b0 [FIX] server: do not restart if phoenix is True (#21209)
Before this commit, saving a file being watched by watchdog
(--dev=reload) with vim (and possibly other text editors) would
crash the server via a KeyboardInterrupt error.

This happens because vim, emacs cause multiple filesystem events to
happen when saving a single file, the FSWatcher registers these events
as multiple SIGHUPs which in turn calls restart() multiple times in a
very small amount of time which makes the KeyboardInterrupts completely
shut down the server

This is fixed by only calling restart() if odoo.phoenix is False, since
catching a SIGHUP sets it to true.

Fixes #21178

Special thanks to @odony for the help :)
2017-11-27 11:12:27 +01:00
Christophe Simonis c703a2a0c3 [MERGE] forward port branch 11.0 up to d279a3e6d5 2017-11-16 17:55:37 +01:00
Yannick Tivisse 77eb1f82d9 [REM] tools: Remove the yml import engine 2017-11-16 14:49:06 +01:00
Christophe Simonis a094f6318b [MERGE] forward port branch saas-16 up to 745d00362a 2017-11-16 12:40:36 +01:00
Christophe Simonis 5877b7b38c [MERGE] forward port branch saas-15 up to 73e4dacf78 2017-11-15 15:50:36 +01:00
Christophe Simonis 0e1ac93e2d [MERGE] forward port branch saas-14 up to abfd662109 2017-11-13 15:03:56 +01:00
Silvio Fernandez c68b41bff2 [FIX] server: avoid crash with gevent worker on windows
Some people may want to use the gevent worker on Windows, even if
multi-process mode is generally not supported on Windows.

Fixes #17726
Closes #20409
2017-11-11 00:51:36 +01:00
Christophe Simonis de93645fe3 [MERGE] forward port branch saas-16 up to 82add438f2 2017-11-09 19:16:05 +01:00
Christophe Simonis 82add438f2 [MERGE] forward port branch saas-15 up to 90ca872071 2017-11-09 18:05:49 +01:00
Christophe Simonis 90ca872071 [MERGE] forward port branch saas-14 up to d171f282c3 2017-11-09 16:49:41 +01:00
Raphael Collet b206d83c03 [FIX] ir_cron: refactor _acquire_job to retrieve useful information
The method `_process_jobs` provides an alternative API to process the cron
jobs, that does not catch exceptions and log them.  This makes the processing
of cron jobs easier for scripting.
2017-11-08 16:03:16 +01:00
Olivier Dony d9b721c805 [FIX] server: avoid partial HTTP responses in worker mode
Python 3 (before 3.6) is affected by outstanding issue 24291:
 https://bugs.python.org/issue24291

In Python 3.6 the issue is gone thanks to this patch:
 https://bugs.python.org/issue26721

The base StreamRequestHandler class does not properly deal with raw IO
output streams. This affects most HTTP servers that use it, including
werkzeug. It causes large HTTP responses to be truncated when the
output socket is unbuffered and in non-blocking mode.
This is the case in multi-process mode (workers > 0) due to the socket
timeout configured to avoid worker deadlocks.

Typically, large file downloads (2MB+) and large JSON responses will be
truncated and cause corrupted files or errors on the client side.

As a workaround, we turn on the buffering on the output stream by
default in multi-process mode (it is already turned on for the input
stream) when running on Python 3.5.

See also the socket.makefile() method and the docstring of
`socketserver.StreamRequestHandler` at
https://github.com/python/cpython/blob/dcb101e7f078f12fc3d2bf1730410798a880bfe3/Lib/socketserver.py#L707

Fixes #20158
opw-777120
2017-10-26 12:58:22 +02:00
Christophe Simonis 1475a1c2c3 [FIX][P3] core: correctly handle binary files (base64 encoded) at rpc level 2017-10-03 12:30:11 +02:00
Olivier Dony e58e0c268c [IMP] server: rename xmlrpc* related parameters
The 'xmlrpc'-based configuration parameters have been a misnomer since
the introduction of the generic HTTP service, years ago.

Hide these options from the server parameters, and replace them with
more appropriate 'http' ones:

 --xmlrpc-interface -> --http-interface
 --xmlrpc-port      -> --http-port
 --no-xmlrpc        -> --no-http

The config entries for these have been adapted as well.

The old parameter names are still silently supported in both
command-line arguments and config files. However they are
stored with the new names in the `tools.config` dict,
and when saving config files (with the -s option).

Also clarified and cleaned up the descriptions of the HTTP/WEB server
parameters.

And finally, added a short version `-p`, for the `--http-port` option.
Credits to @dreispt for this (via #19518)

Closes #19518
Closes #19778
2017-09-29 18:18:03 +02:00
Fabien Meghazi 9f9a7fdd0d [FIX] server: python3 compatibility for --dev=reload 2017-09-28 14:58:38 +02:00
Olivier Dony e98e8e9b1b [FIX] P3: fix server shutdown on Ctrl+C
This is an attempt at fixing the long timeout occurring on P3 when
trying to stop the server with Ctrl-C, both in multithreaded and
multi-process mode.

The root cause is the implementation of PEP-0475[1] as of Python 3.5,
which make system calls silently resume after an interrupt.
With this PEP, interrupting a syscall now requires the signal handler to
raise an exception, which get propagated in places where they did not
use to occur (e.g. time.sleep() used to return early when interrupted)

The solution handles 2 separate cases:

1. Multithreaded

In multithreaded mode, stopping the server requires interrupting
the main thread, while ensuring that all other threads are daemon ones.
The previous commit fixed the latter.
Interrupting the main thread is easy, because it simply sleeps until
it gets interrupted. And it already catches KeyboardInterrupt for
win32 quirks. All we need to do is thus to raise a KeyboardInterrupt
in the signal handler, as proposed in PEP 475 (Use Case 2)

2. Multi-process

In multi-process mode, stopping the server requires interrupting the
main thread of each process. The signal is already propagated to all
processes, so it should be as simple as for multithreaded mode.
Unfortunately, the main threads are far from idle in this case,
and raising a KeyboardInterrupt from the signal handler causes a
series of ugly tracebacks before stopping the server.
Effective, but frightening for the admin.

Instead of doing that, we can watch the wakeup file descriptor
(also suggested in PEP 475, Use Case 2) during the sleep() part of the
main loop of each worker. An interrupt signal won't therefore stop
the server immediately, but will wait until each worker is done with
their current request.. even better.
For select() syscalls, this is done with an extra pipe fd that is passed in
the "read fds", and used as wakeup fd.
And for sleep() syscalls, that don't support a wakeup fd, we can
replace them with an equivalent select() call on the wakeup fd, and
a timeout.

The combination of the above seems to restore a relatively fast
interrupt shutdown on both Python 2.7 and Python 3.5, in both
multithreaded and multi-process mode, with no surprising traceback.

[1] https://www.python.org/dev/peps/pep-0475/
2017-09-25 11:22:09 +02:00
Xavier Morel 1222422333 [FIX] p3: race condition when *reloading* an existing db
When re-launching Odoo on an existing database in Python 3.6[0] it's
possible that the scheduler will preempt the main thread
mid-module-import and run the cron thread which causes registry (and
module) initialisation with only a subset of the Python files loaded
and thus e.g. tries loading auth_crypt with a registry in which none
of res has been loaded makes for interesting situations.

Delay spawning the cron thread until *after* the registry preload at
least, though I don't think that actually entirely fixes the issue.

[0] and probably in any Python >= 3.3, I'm guessing it's related to
    the per-module import locks which replaced the old global lock:
    https://docs.python.org/3.3/whatsnew/3.3.html#a-finer-grained-import-lock

    though since ir.cron has little reason to import anything it could
    also just be Python 3 scheduler changes which allow/cause a
    context-switch during imports while the Python 2 scheduler would
    not allow that. IDK.
2017-08-29 16:54:32 +02:00
Olivier Dony 2cc77a1990 [FIX] P3: os.write(bytes) 2017-08-20 23:25:54 +02:00
Olivier Dony 9197676e88 [FIX] P3: socket.error.errno instead of [0]
As of P3 socket.error is replaced by IOError and the underlying error
code must be accessed with `.errno `. This also worked in P2, so simply
use that all the time.
2017-08-20 23:25:54 +02:00
Olivier Dony 695716efb0 [FIX] P3: remove pycompat.{keys,items,values} helpers
Now that we're closer to switching to P3 for good, these helpers have
outlived their usefulness, and mostly add noise.

All remaining dict.iter*() or dict.view*() must be converted to the
normal keys(), values() or items() calls.

Whenever the result is likely to be used for more than the scope of a
loop, or when the dict needs to be modified during iteration, the calls
must be wrapped in a ``list()``, to protect the new P3 semantics.
Those cases are very exceptional.

Also removed some dead code or improved the API to remove unnecessary
conversions.
2017-08-20 23:25:54 +02:00
Christophe Simonis 4d5ff6401c [MERGE] forward port branch saas-16 up to b76109173a 2017-07-28 18:37:10 +02:00
Christophe Simonis b76109173a [MERGE] forward port branch saas-15 up to c0ec09e9d5 2017-07-28 18:11:07 +02:00
Christophe Simonis c0ec09e9d5 [MERGE] forward port branch saas-14 up to be77cf7f5f 2017-07-28 17:25:45 +02:00
Christophe Simonis e686385138 [MERGE] forward port branch saas-11 up to 5e6637a240 2017-07-28 16:26:57 +02:00
Christophe Simonis bf51fe55a1 [MERGE] forward port branch saas-16 up to 0f2b2c4e2b 2017-07-07 14:30:30 +02:00
Christophe Simonis 7dc731db83 [MERGE] forward port branch saas-15 up to 1f16d34aaa 2017-07-06 13:54:22 +02:00
Christophe Simonis 1f16d34aaa [MERGE] forward port branch saas-14 up to 5009752dcf 2017-07-06 13:53:17 +02:00