[IMP] base: improve assetbundle logging

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) <xdo@odoo.com>
This commit is contained in:
Xavier-Do
2023-12-04 08:51:55 +00:00
parent a42f975df2
commit f744e90fc4
+3
View File
@@ -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