Commit Graph
194 Commits
Author SHA1 Message Date
Telmo Santos 7c140a3338 Log exception 2020-09-02 11:33:21 +02:00
Iryna Vushnevska 6337607e2c [IMP] adapt features to v12 2020-08-25 15:34:53 +03:00
Guewen BaconnierandIryna Vushnevska b05c5eeb8b 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-08-25 14:26:03 +03:00
Guewen BaconnierandGitHub 234451065f Merge pull request #193 from acsone/12.0-188-port
[12.0][PORT] 188 from 10.0
2020-06-22 13:36:47 +02:00
Stéphane Bidoul 384c75061a Log uid 2020-06-22 08:42:25 +02:00
Stéphane Bidoul c3b061e980 Log request uuid 2020-06-22 08:42:25 +02:00
Guewen BaconnierandGitHub 0a592403e8 Merge pull request #174 from grindtildeath/12.0_attachment_s3_bin_size_close
[12.0] attachment_s3: Improvements
2020-06-22 07:45:26 +02:00
Guewen BaconnierandGitHub ef07381879 Merge pull request #140 from camptocamp/12-fixes
cloud_platform: fix default config
2020-06-22 07:39:28 +02:00
Guewen Baconnier 3036a8161e Update setuptools files 2020-06-22 07:21:54 +02:00
Guewen Baconnier 74c528e050 Ignore .eggs/ in gitignore 2020-06-22 07:21:43 +02:00
Guewen BaconnierandGitHub 981a99310c Merge pull request #184 from guewen/12.0-redis-json-encode-date
[12.0] Encode/decode date and datetime in redis sessions
2020-05-28 20:44:07 +02:00
Guewen BaconnierandGitHub a05bbfe517 Merge pull request #185 from PCatinean/12.0-session-preserve-forward-port-pc
12.0 session preserve forward port pc
2020-05-28 20:42:32 +02:00
Andreas PerhabandPaul c18e84a3bf [FIX] session_redis: fix flake8 errors 2020-05-26 14:46:56 +02:00
Andreas PerhabandPaul 9ac4d26470 [IMP] session_redis: add option to copy sessions from filesystem when starting 2020-05-26 14:39:27 +02:00
Andreas PerhabandPaul 18b5ceaebc [FIX] session_redis: add required option 'post_load' for server wide addon 2020-05-26 14:39:08 +02:00
Guewen Baconnier 2c5805e858 Add (de-)serialization of set objects in sessions 2020-05-26 11:39:39 +02:00
Guewen Baconnier 2a022ba537 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-26 11:39:30 +02:00
Guewen BaconnierandGitHub a6f4e7990f Merge pull request #180 from guewen/12.0-fix-server-env
[12.0] Fix build after changes in server_environment
2020-05-11 09:39:21 +02:00
Guewen Baconnier 8524eeff2d 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:25:59 +02:00
Akim Juillerat 123947100b [FIX] attachment_s3: Close fileobjects after usage 2020-03-18 13:22:02 +01:00
Akim Juillerat bd3be08203 [IMP] attachment_s3: Consider bin_size context key
When bin_size context key is set, read operations on attachments
are supposed to return the size of the attachment and not its content
2020-03-18 12:51:48 +01:00
Akim JuilleratandGitHub 20a8493a63 Merge pull request #165 from grindtildeath/12.0-fix_auth_to_keystone_v3
[12.0] attachment_swift: Fix authentication to Keystone v3
2020-03-09 13:32:56 +01:00
Akim Juillerat 4a7ac33d9f Fix authentication to Keystone v3
- Use newer version from python lib.
 - Define project_domain_id + user_domain_id in auth
2020-03-09 12:07:59 +01:00
Patrick TombezandGitHub 6d92bd626b Merge pull request #152 from p-tombez/12.0-keystoneauth_v3
[12.0] Use keystoneauth v3 for Swift attachments
2020-03-04 10:45:41 +01:00
Mussie SirakandPatrick Tombez 8ac54f4773 Use keystoneauth v3 for Swift attachments 2020-03-04 10:23:59 +01:00
Akim JuilleratandGitHub cca48fb020 Merge pull request #141 from grindtildeath/12.0_dev_s3_attachments
[12.0] Require AWS_BUCKETNAME for prod and integration environments only
2020-02-26 14:40:13 +01:00
Akim Juillerat 928faced58 Require AWS_BUCKETNAME for prod, integration and labs environments only
AWS_BUCKETNAME is only needed in order to write on the bucket, but
read-only access should be allowed for other environments.

Fixes bug introduced by 6c3b610610
2020-02-25 17:19:48 +01:00
Yannick VaucherandGitHub 312a4001c4 Merge pull request #116 from yvaucher/aws-bucketname-unstrctured
Add AWS_BUCKETNAME_UNSTRUCTURED to by-pass check
2020-02-25 16:27:46 +01:00
Yannick Vaucher a6533576f2 Swift same by-pass structured store location 2020-02-25 15:36:19 +01:00
Simone Orsi 3c7f9f951b cloud_platform: fix default config
`_config_by_server_env` should always retutn a `PlatformConfig` instance
2020-02-04 13:39:40 +01:00
Patrick TombezandGitHub ccbae04ae0 Merge pull request #135 from p-tombez/12.0-anon_redis_session
[12.0] Add anonymous redis session expiration configuration
2020-01-31 11:14:56 +01:00
Patrick Tombez c139b4da0a Add anonymous redis session expiration configuration 2020-01-29 16:31:38 +01:00
Guewen BaconnierandGitHub d544a881f8 Merge pull request #125 from acsone/12.0-fix-pythonjsonlogger-setup
[FIX] pythonjsonlogger external dependency in setup.py
2020-01-14 16:17:42 +01:00
Stéphane Bidoul (ACSONE) 1c5a5088b6 [FIX] pythonjsonlogger external dependency in setup.py 2019-12-21 12:09:43 +01:00
Vincent RenavilleandGitHub ed7c246493 Merge pull request #79 from sebalix/12.0-add-force-storage-special-fields
[12.0] Add method to force storage of special attachments to DB
2019-12-12 15:52:43 +01:00
Denis LeemannandGitHub 0ea58439f6 Merge pull request #117 from leemannd/description_added
Add description to model
2019-12-09 16:06:53 +01:00
Denis Leemann 07f7b3b19f Add description to model
This removes the useless warning at startup
2019-12-09 15:06:55 +01:00
Yannick Vaucher 7be1cebeeb Add AWS_BUCKETNAME_UNSTRUCTURED to by-pass check
Curently the name of the bucket is cross checked with the
running environment. In rare case you can have a bucket name
that doesn't match the structure <project>-odoo-<env> in place.
2019-12-05 15:33:54 +01:00
Guewen BaconnierandGitHub 7a6adaffec Merge pull request #105 from camptocamp/revert-100-12.0-monitoring_check_db_connection
Revert "[12.0] [IMP] monitoring_status: check the db is reachable"
2019-11-18 13:50:32 +01:00
Guewen BaconnierandGitHub 1a907eea02 Merge pull request #110 from guewen/add-support-running-env-labs
[12.0] Add support of 'labs' RUNNING_ENV in cloud_platform
2019-11-18 13:41:06 +01:00
Guewen Baconnier d04e7d558f Add an advice in error message 2019-11-18 13:07:54 +01:00
Guewen Baconnier 6c3b610610 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 13:07:54 +01:00
Guewen BaconnierandGitHub 8ecd50b293 Revert "[12.0] [IMP] monitoring_status: check the db is reachable" 2019-10-29 17:32:32 +01:00
Simone OrsiandGitHub eb91ecf352 Merge pull request #100 from gurneyalex/12.0-monitoring_check_db_connection
[12.0] [IMP] monitoring_status: check the db is reachable
2019-10-28 08:13:11 +01:00
Alexandre Fayolle f83e502d72 [IMP] monitoring_status: check the db is reachable
make a real SQL query on GET /monitoring/status and return a 503
if the query failed.
2019-10-25 16:25:31 +02:00
CharlineDumontetandGitHub 9655641f22 Merge pull request #80 from Tonow-c2c/change_re_check_prod
cloud_platform: support client name w/ number
2019-09-09 09:25:55 +02:00
Tonow-c2c 6b87b1c604 cloud_platform: support client name w/ number 2019-09-08 15:48:23 +02:00
sebalix 493e49ba00 attachment_s3: remove old migration script 2019-08-09 16:05:06 +02:00
Guewen Baconnierandsebalix 19126ee4f0 Update base_attachment_object_storage/models/ir_attachment.py 2019-08-09 15:47:40 +02:00
Guewen Baconnierandsebalix 2f8fcedd88 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-08-09 15:47:40 +02:00