100 Commits
Author SHA1 Message Date
Guewen BaconnierandGitHub 0000eab313 Set test_base_fileurl_field (#190)
It seems it has been forgotten during the migration of
base_fileurl_field at 65cdd3d
2023-03-01 10:59:38 +01:00
Guewen BaconnierandGitHub 298050ba52 Merge pull request #191 from guewen/13.0-log-user-id-uuid
[13.0] Extend json logger with request uuid and user id
2020-06-22 13:36:59 +02:00
Guewen Baconnier fd335d89be Upgrade setuptools files 2020-06-22 07:23:56 +02:00
Guewen Baconnier bc7d37d465 Ignore .eggs/ in gitignore 2020-06-22 07:22:45 +02:00
Guewen BaconnierandGitHub 787a64178f Merge pull request #183 from avoinsystems/13.0-redis-by-url
[13.0][IMP] session_redis: allow configuring Redis URL instead of host & port.
2020-05-28 20:45:56 +02:00
Guewen BaconnierandGitHub dcc809d450 Merge pull request #187 from guewen/13.0-fix-force-storage-db
[13.0] Rework and fix storage forced in database
2020-05-28 11:40:14 +02:00
Guewen Baconnier e3e3899143 Rework and fix storage forced in database
The initial issue that triggered this rework is that the forced storage in
database was working only on writes, and was never applied on attachment
creations.

This feature is used to store small files that need to be read in a fast way in
database rather than in the object storage. Reading a file from the object
storage can take 150-200ms, which is fine for downloading a PDF file or a single
image, but not if you need 40 thumbnails.

Down the path to make a correction, I found that:

* the logic to force storage was called in `_inverse_datas`, which is not called
  during a create
* odoo implemented a new method `_get_datas_related_values`, which is a model
  method that receive only the data and the mimetype, and return the attachment
  values and write the file to the correct place

The `_get_datas_related_values` is where we want to plug this special storage,
as it is called for create and write, and already handle the values and
conditional write. But using this method, we have less information than before
about the attachment, so let's review the different criterias we had before:

* res_model: we were using it to always store attachments related to
  'ir.ui.view' in db, because assets are related to this model. However, we
  don't really need to check this: we should store any javascript and css
  documents in database.
* exclude res_model: we could have an exclusion list, to tell that for instance,
  for mail.message, we should never store any image in db. We don't have this
  information anymore, but I think it was never used and added "in case of".
  Because the default configuration is "mail.mail" and "mail.message" and I
  couldn't find any attachment with such res_model in any of our biggest
  databases. So this is removed.
* mimetype and data (size) are the last criteria and we still have them

The new system is only based on mimetype and data size and I think it's actually
more versatile. Previously, we could set a global size and include mimetypes,
but we couldn't say "I want to store all images below 50KB and all files of type
X below 10KB". Now, we have a single system parameter with a dict configuration
(`ir_attachment.storage.force.database`) defaulting to:

    {"image/": 51200, "application/javascript": 0, "text/css": 0}

Assets have a limit of zero, which means they will all be stored in the database
whatever their size is.

Overall, this is a great simplification of the module too, as the method
`_get_datas_related_values` integrates it better in the base calls of IrAttachment.

Note for upgrade:

I doubt we customized the previous system parameters which are now obsolete, but
if yes, the configuration may need to be moved to `ir_attachment.storage.force.database`.
For the record, the params were:

* mimetypes.list.storedb (default: image)
* file.maxsize.storedb (default: 51200)
* excluded.models.storedb (mail.message,mail.mail), no equivalent now

The method IrAttachment.force_storage_to_db_for_special_fields() should be called
through a migration script on existing databases to move the attachments back into
the database.
2020-05-28 07:26:42 +02:00
Guewen BaconnierandGitHub a2e4c8fc65 Merge pull request #178 from guewen/13.0-redis-json-encode-date
Encode/decode date and datetime in redis sessions
2020-05-26 10:43:47 +02:00
Guewen BaconnierandGitHub 0769d3b47e Merge pull request #181 from guewen/13.0-fix-server-env
[13.0] Fix build after changes in server_environment
2020-05-11 09:39:53 +02:00
Guewen Baconnier 9bdd4b6b1d Fix build after changes in server_environment
Now the default env is "test", and we don't need the directory
at all.
See https://github.com/OCA/server-env/pull/44
2020-05-11 08:27:16 +02:00
Guewen Baconnier ac89e923d7 Add (de-)serialization of set objects in sessions 2020-05-11 07:35:05 +02:00
Guewen Baconnier 35fb727d6c Encode/decode date and datetime in redis sessions
In several places, odoo sets a datetime object directly in the
session. It works with the default session handler of odoo which
uses pickle.

But datetime and date are not json serializable by default.

Add custom encoder / decoder to handle them (from
https://github.com/OCA/queue/blob/dc12a6a20ecfd15c5b90f9b089c9a64cf9d8bbe4/queue_job/fields.py#L57-L99)

See the discussion raised by @PCatinean on https://github.com/camptocamp/odoo-cloud-platform/pull/176
2020-05-04 16:09:55 +02:00
Guewen BaconnierandGitHub 20c0138588 Merge pull request #126 from sbidoul/patch-1
[FIX] logging_json: PyPI package as python external dep
2020-01-14 16:17:51 +01:00
Guewen Baconnierandvrenaville 3d25e59f0f Add method to force storage of special attachments to DB
Some attachments (e.g. image_small, image_medium) are stored in DB
instead of the object storage for faster access.

In some situations, we may have pushed all these files on the Object
Storage (migration from a filesystem to object storage) and want to
bring back these attachments from the object storage to the database.

This method is not called anywhere but can be called by RPC or scripts.
2019-12-20 13:23:48 +01:00
Guewen BaconnierandGitHub 3cb8ce8b8b Merge pull request #113 from guewen/13.0-add-support-running-env-labs
[13.0] Add support of 'labs' RUNNING_ENV in cloud_platform
2019-11-29 15:52:23 +01:00
Guewen Baconnier d9307f44cb Add an advice in error message 2019-11-18 16:25:34 +01:00
Guewen Baconnier a482f186ce Add support of 'labs' RUNNING_ENV in cloud_platform
The labs env can be anything starting by 'labs', such as
'labs-logistics', 'labs-finance', ...

* At install, s3/swift is set as default storage
* However, unlike prod/integration, the storage is not forced to be an
object storage
* Redis is required
* When the storage is set on s3/swift, then the bucket name is mandatory
(otherwise, there is no place where to create the files...)

The redis prefix regex match is relaxed: anything starting by a project
name, then '-odoo-', then any combination of letters, digits, and dashes
is accepted (so a prefix my-project9-odoo-labs-web3 is valid).
2019-11-18 16:25:34 +01:00
Guewen BaconnierandGitHub 7684760065 Merge pull request #106 from camptocamp/revert-101-13.0-monitoring_check_db_connection
Revert "[13.0] [IMP] monitoring_status: check the db is reachable"
2019-11-18 14:45:09 +01:00
Guewen Baconnier bb0d50418e Use python3.6 2019-11-18 13:59:58 +01:00
Guewen BaconnierandGitHub e5cd6a8f87 Revert "[13.0] [IMP] monitoring_status: check the db is reachable" 2019-10-29 17:32:39 +01:00
Guewen BaconnierandGitHub 84e00f5f14 Merge pull request #73 from camptocamp/simahawk-patch-1
monitoring_status filter: ignore HTTP version
2019-08-09 09:54:33 +02:00
Guewen Baconnier ad3a962931 Filter /monitoring/status werkzeug logs
With healtchecks, they constitute 95% of our logs. Let's stop wasting
resources and shut them up.
2019-07-12 10:07:20 +02:00
Guewen Baconnier 580eff0062 Override dependencies with different name and pin versions
The name of the libs and python packages are different, Odoo expects
the inner python package in the manifest, but setuptools cannot find the
libs in pypi, overrides them with the libs names.
2019-05-09 10:10:58 +02:00
Guewen Baconnier d032e518ba Pin PyYAML version because 5.x does not work with Odoo
It would raise ConstructorError: could not determine a constructor for the tag '!record'
2019-05-09 10:10:58 +02:00
Guewen Baconnier c6456a58f7 attachment_swift: share a session for all connections
OVH's Swift applies a rate limit on the authentication.

attachment_swift authenticates again each time it has to read/write an
attachment. When running upgrades on upgrades of files or installing a
new DB, at some point, we get rejected with HTTP 429.

This commit introduces a shared storage for Swift Session. All
connections will reuses the same authentication token created the first
time a connection needs a Session.

Note: needs python-swiftclient>=3.7.0 to have
https://github.com/openstack/python-swiftclient/commit/1971ef880ff225379d4a91f00f89f323a1605eeb
2019-05-09 10:10:58 +02:00
Guewen Baconnier 339876236e Add missing variable in documentation example 2019-05-07 15:51:36 +02:00
Guewen BaconnierandGitHub 8b9e7b1ffe Merge pull request #41 from jcoux/fix_check_stack_name
Fix the check stack name for project with digit at first character
2018-12-03 10:56:46 +01:00
Guewen Baconnier a9c2f64fca Add setuptools files 2018-12-03 10:09:33 +01:00
Guewen Baconnier 67bf8b8286 Edit readme 2018-12-03 10:09:23 +01:00
Guewen Baconnier 96f4e75311 base_attachment_object_storage: bump 1.1.0 2018-06-13 17:25:21 +02:00
Guewen BaconnierandGitHub 19dcbff646 Merge pull request #35 from guewen/11.0-force-storage-at-upgrade
11.0 Fix attachments stored in FS instead of object storage
2018-06-13 17:24:50 +02:00
Guewen Baconnier 371e5439e6 Document a weird domain which is there for a reason
The reason being:
https://github.com/odoo/odoo/blob/9032617120138848c63b3cfa5d1913c5e5ad76db/odoo/addons/base/ir/ir_attachment.py#L344-L347

I nearly deleted this domain but it was too weird to be there for no
reason. A comment explaining the issue was really missing.
2018-06-13 16:05:34 +02:00
Guewen Baconnier 6ab3038a90 Fix attachments stored in FS instead of object storage
Assume the following situation:

* We have installed addons base, sale and attachment_s3 (hence
base_attachment_object_storage as dependency)
* All attachments are in S3 already
* We run an upgrade of the 'base' addon, 'sale' is upgraded before
attachment_s3 in the order of loading.
* Sale updates the icon of the Sale menu
* As attachment_s3 is not loaded yet, the attachment is created in the
filestore

Now if we don't persist the filestore or use different servers, we'll
lose the images of the menus (or any attachment loaded by the
install/upgrade of an addon).

The implemented solution is to move the attachments from the filestore
to the object storage at the loading of the module. However, this
operation can take time and it shouldn't be run by 2 processes at the
same time, so we want to detect if the module is loaded during a normal odoo
startup or when some addons have been upgraded. There is nothing anymore
at this point which allow us to know that modules just have been
upgraded except... in the caller frame (load_modules). We have to rely
on the inpect module and get the caller frame, which is not recommended,
but seems the only way, besides, it's not called often and if
_register_hook was called from another place, it would have no effect
(unless the other place has a variable 'update_module' too).
2018-06-13 16:05:26 +02:00
Guewen Baconnier fb3d3134d6 Ensure that migration of files is commited before deleting files
When moving attachments from the filestore to an object storage,  the
filesystem files will be deleted only after the commit, so if the
transaction is rollbacked, we still have the local files for another
try.
2018-06-13 16:04:55 +02:00
Guewen BaconnierandGitHub 2ec125cccd Merge pull request #31 from guewen/11.0-swift-pass-region-name
Propagage region_name to swift connection
2018-03-29 16:44:39 +02:00
Guewen Baconnier 529c4066fa Propagage region_name to swift connection
Otherwise, the bucket will be in the incorrect region
2018-03-16 09:10:58 +01:00
Guewen BaconnierandGitHub c35483d948 Merge pull request #29 from guewen/11.0-fix-redis-stored-log
Fix order of args in logs
2018-03-15 12:27:47 +01:00
Guewen Baconnier 543a9eb22d Fix order of args in logs 2018-03-13 15:00:26 +01:00
Guewen BaconnierandGitHub 68c161e345 Merge pull request #28 from camptocamp/yvaucher-patch-1
Remove useless call to lower()
2018-02-08 15:32:14 +01:00
Guewen Baconnierandjcoux 39e71ff334 Expire sessions generated by health checks quickly
The default expiration of sessions is 7 days. With healthchecks run
every few seconds, we quickly have millions of anonymous sessions in
Redis. Allow to define a custom expiration for some sessions and set a
very short one for the monitoring requests.
2018-01-11 10:46:55 +01:00
Guewen Baconnier e3799cd54b Change OCA dependency to server-env
server_environment addons have been moved there
2018-01-11 10:41:26 +01:00
Guewen Baconnier 6cc18007dd Remove web_kanban, does no longer exist in 11.0 2018-01-11 10:41:26 +01:00
Guewen Baconnier bfaca4628a Tentative to fix travis build 2018-01-11 10:41:26 +01:00
Guewen Baconnier 5b37af2376 Fix flake8 warning 2018-01-11 10:41:26 +01:00
Guewen Baconnier 207cd6504c Encode/decode redis data which expects bytes 2017-11-15 16:25:02 +01:00
Guewen Baconnier ea44b4fd15 Remove call to encode, str expected, not bytes (py3) 2017-11-15 16:15:39 +01:00
Guewen Baconnier 08329c91d2 Replace value.decode('base64') by base64.b64decode (py3) 2017-11-15 15:54:59 +01:00
Guewen Baconnier 5901ca82a2 Set version in .travis.yml 2017-11-15 15:42:25 +01:00
Guewen Baconnier 4bb649f729 Add check for empty bucket on integration 2017-11-15 15:03:03 +01:00
Guewen Baconnier b084ce278a Set addons installable 2017-11-15 14:56:45 +01:00
Guewen Baconnier f9c290a45a Apply 2to3 automatic migration 2017-11-15 14:55:11 +01:00
Guewen Baconnier 96c9a38150 Set addons uninstallable 2017-11-15 14:31:23 +01:00
Guewen BaconnierandGitHub 98d7bc3096 Merge pull request #19 from yvaucher/aws-region
Add AWS_REGION to connect to bucket with specific region
2017-11-15 14:28:54 +01:00
Guewen BaconnierandGitHub aaf56d5027 Merge pull request #18 from TDu/mock-test-swift
Mock Swift client api in tests
2017-11-10 09:00:38 +01:00
Guewen Baconnier 7999386273 Fix tests
When there is no write container setup, no write/delete actions are
done.
2017-11-10 08:52:53 +01:00
Guewen BaconnierandGitHub 86e5bd3ad7 Merge pull request #16 from TDu/add-ovh-platform
[BSRTL-215] Add OVH as an option for the cloud platform
2017-09-21 09:03:46 +02:00
Guewen Baconnier ee8038b388 Update doc 2017-09-20 15:42:25 +02:00
Guewen Baconnier abe34fcaa2 Return empty result on file read error
This is how the core implementation works
2017-09-20 15:42:25 +02:00
Guewen Baconnier cbef735c76 Abstract object storage in attachment_s3
Using the base_attachment_object_storage module, the same way
attachment_swift is done. Fixed a few issues along the way in
attachment_swift.
2017-09-20 15:42:25 +02:00
Guewen Baconnier edc700c807 Configure storage by platform kind 2017-09-20 15:42:25 +02:00
Guewen Baconnier 81196a8058 Various small changes after review 2017-09-20 12:43:38 +02:00
Guewen Baconnier 5d30207963 Merge branch 'TDu-swift-integration' into 10.0 2017-09-01 11:15:33 +02:00
Guewen BaconnierandGitHub 27707f7271 Merge pull request #13 from guewen/better-s3-access-error-msg
[10.0] Make error message more precise for S3 access
2017-08-29 11:37:32 +02:00
Guewen Baconnier f1e84b5562 Make error message more precise for S3 access
The previous error message let think that you should set AWS_BUCKETNAME,
although you should set it only if you are trying to write in this
repository.
2017-08-28 14:37:45 +02:00
Guewen BaconnierandGitHub e67626945e Merge pull request #11 from guewen/10.0-session-redis-sentinel
[10.0] Allow to use a Redis Sentinel
2017-05-18 16:40:25 +02:00
Guewen Baconnier c7240e1fe1 Allow to use a Redis Sentinel 2017-05-16 09:07:59 +02:00
Guewen Baconnier 2b81b7a6fb Do not require to run statds metrics 2017-04-29 09:20:55 +02:00
Guewen Baconnier f0519cf2f6 Add more details in asserts 2017-01-17 11:11:47 +01:00
Guewen BaconnierandGitHub 540269f59e Merge pull request #5 from guewen/10.0-attachment-fast-web-access
Store files that need fast access in the database
2017-01-16 17:27:39 +01:00
Guewen Baconnier 795692ad78 Store files that need fast access in the database
An Object Storage read is slower than a disk of database access.
It might take ~200 to 300ms to retrieve a file content.

This is not an issue for attachments such as the pdf files or any
attachment that we want to read on demand. But that's too slow for
files needed to render a web page.

We'll store in the database:

* Assets (js, css, ...). As a side effect, the databases will be more
  portable, as assets are rebuilt frequently, storing them in the Object
  Storage led the integration server to try to read assets deleted since
  long ago
* Attachments linked to Binary fields named 'image_small',
  'image_medium', 'web_icon_data'. Those fields are often used on kanban
  views that display a lot a images and retrieving them all was then
  very slow (Odoo does not do async requests).

The migration to S3 is no longer called during initialization of the
registry: it would be too slow as we would have to define if the
attachments must be kept in database or sent to S3 on each new start. It
means we have to call `env['ir.attachment'].force_storage()` to run the
migration.
2017-01-16 14:04:24 +01:00
Guewen Baconnier 4eecb899f3 Fix IrHttp._dispatch is now a class method 2016-12-21 23:21:57 +01:00
Guewen Baconnier 8e4b461c75 Migrate addons to 10.0 2016-12-21 21:29:09 +01:00
Guewen Baconnier 022f9003e8 Add debug logs in session_redis 2016-12-14 11:25:12 +01:00
Guewen Baconnier 997f92aaab Rename builtin id variable 2016-12-13 12:21:37 +01:00
Guewen Baconnier d138a1fd3d Be more defensive against concurrent workers
When migrating attachments to S3, several workers may try to migrate
the same attachments. Do not fail when both update the same attachment.
2016-12-13 12:01:50 +01:00
Guewen Baconnier 5f61ed8985 registry is useless in the second branch 2016-12-13 09:06:50 +01:00
Guewen Baconnier 53d7cdf3e7 Fix attachment_s3: do not open a new cursor
Because it provokes serialization errors during the installation or
update of addons. Do not commit as we might commit unwanted things...
Later, we might want to add a specific, more elaborate, migration
process.
2016-12-13 08:58:08 +01:00
Guewen BaconnierandGitHub 8b15070c7f Merge pull request #4 from guewen/add-load-readme
Document --load option for some addons
2016-11-14 08:29:51 +01:00
Guewen Baconnier 607268bd4f Delete S3 file only when bucket is the current one 2016-11-14 08:29:13 +01:00
Guewen Baconnier 779aa03c57 Explicit attachment_s3 must be started in --load 2016-11-10 16:14:19 +01:00
Guewen Baconnier 92880deeab Explicit session_redis must be started in --load 2016-11-10 16:14:19 +01:00
Guewen Baconnier 78ac4d306e Document --load option 2016-11-10 16:14:19 +01:00
Guewen Baconnier 110ec2399d Add logging when deleting file on the object storage 2016-11-07 10:11:23 +01:00
Guewen Baconnier 7f262799cf Do not care if an attachment could not be deleted 2016-11-07 09:50:26 +01:00
Guewen Baconnier 8400c0f34e Set statsd customer 2016-11-04 13:39:50 +01:00
Guewen Baconnier f643c19fba Do not fail when an attachment cannot be read
It would be blocking and a missing attachment might be a minor issue.
Only warn when such a file is missing.
2016-11-04 13:38:31 +01:00
Guewen BaconnierandGitHub 80ac235c28 Merge pull request #3 from guewen/grafana-statsd
Add statsd addon
2016-11-04 10:35:25 +01:00
Guewen Baconnier 65e9bad4e5 Add monitoring_statsd in cloud_platform 2016-11-04 10:30:10 +01:00
Guewen Baconnier d53ef3de37 Add statsd metrics addon 2016-11-04 10:30:10 +01:00
Guewen BaconnierandGitHub 23634feb46 Merge pull request #2 from guewen/logging-json
Add logging_json
2016-11-04 10:20:20 +01:00
Guewen Baconnier bed41d6719 Add requirements.txt 2016-11-03 17:37:00 +01:00
Guewen Baconnier e5c1afb09e Fix server_environment_files error 2016-11-03 17:07:47 +01:00
Guewen Baconnier 3c8b74369b Make pylint happy 2016-11-03 16:58:36 +01:00
Guewen Baconnier 3fd26cb894 Fix travis configuration 2016-11-03 16:46:42 +01:00
Guewen Baconnier 7eafdd75f4 Add oca-dependencies 2016-11-03 16:24:47 +01:00
Guewen Baconnier b5f00c26dc Fix pep8 2016-11-02 10:29:02 +01:00
Guewen Baconnier ec1f3fc61a Add logging_json
Output odoo logs as json
2016-11-02 10:10:05 +01:00
Guewen Baconnier 46231b3365 Fix pep8 2016-11-02 09:55:36 +01:00
Guewen Baconnier 1d4f76de2b Migrate attachments s3 to new pattern
So remove the compatibility code altogether
2016-11-01 08:55:00 +01:00
Guewen Baconnier 963b65e99d Storage should be 's3' 2016-10-31 17:23:20 +01:00