From f744e90fc4fa05c224194a80cb44b01734fac081 Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Mon, 27 Nov 2023 12:03:34 +0100 Subject: [PATCH] [IMP] base: improve assetbundle logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The clean attachement was invalidation the cache before 16.4, mainly because if an attachement is in cache of another worker and deleted, this will cause a 404 when this worker serves a page needing this attachment. This was changed because an attachment should be unlink through clean_attachments in two cases: - the code source change on the server and a cold worker generates a bundle - an ir_asset was modified In the first case, we consider that the server restarted (normally) and all caches should be emptied. In the second case, a specific invalidation is made. But when something goes wrong, it is hard to debug, especially because there is no information on when the new attachment was created, and the previous one deleted. This should solve the issue by helping to identify the cause of the deletion. closes odoo/odoo#143962 Signed-off-by: Xavier Dollé (xdo) --- odoo/addons/base/models/assetsbundle.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/odoo/addons/base/models/assetsbundle.py b/odoo/addons/base/models/assetsbundle.py index 4ce7b682d71..6f5d85bc9f4 100644 --- a/odoo/addons/base/models/assetsbundle.py +++ b/odoo/addons/base/models/assetsbundle.py @@ -197,6 +197,7 @@ class AssetsBundle(object): # avoid to invalidate cache if it's already empty (mainly useful for test) if attachments: + _logger.info('Deleting attachments %s (matching %s) because it was replaced with %s', attachments.ids, to_clean_pattern, keep_url) self._unlink_attachments(attachments) # clear_cache was removed @@ -306,6 +307,8 @@ class AssetsBundle(object): } attachment = ira.with_user(SUPERUSER_ID).create(values) + _logger.info('Generating a new asset bundle attachment %s (id:%s)', attachment.url, attachment.id) + self._clean_attachments(extension, url) # For end-user assets (common and backend), send a message on the bus