Skip to content

[MIG][module_auto_update] Backport from v10 - #918

Merged
pedrobaeza merged 6 commits into
OCA:9.0from
Tecnativa:9.0-module_auto_update
Aug 3, 2017
Merged

[MIG][module_auto_update] Backport from v10#918
pedrobaeza merged 6 commits into
OCA:9.0from
Tecnativa:9.0-module_auto_update

Conversation

@yajo

@yajo yajo commented Aug 1, 2017

Copy link
Copy Markdown
Member

Backporting #882

@Tecnativa

@yajo yajo self-assigned this Aug 1, 2017
@yajo yajo added this to the 9.0 milestone Aug 1, 2017
@yajo

yajo commented Aug 1, 2017

Copy link
Copy Markdown
Member Author

Cool! all 💚

'sha1',
excluded_extensions=exclude,
)
try:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do this, but assign dirhash = None in import, and check here if dirhash:, but this should be declared as external dependency, so if the code get this, it's because you make sure the lib to be installed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is here because get_module_path can return False if an addon is installed bus it not found on disk. Then, dirhash raises a TypeError because it expects a str.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks for clarifying. Can you please put the same comment in code for later references?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already there, above the pass

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch, got it

@pedrobaeza pedrobaeza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The case we have mentioned in the Docker project (new dependency added to installed modules) should be treated also:

  • Check which modules need to be updated (already done).
  • Update module list (but removing the part in this method that call again to update).
  • Check dependencies of these modules.
  • If some of the dependencies are not installed, then marked them for being installed.

There's still the chance that your installation doesn't contain the new dependency, but at least we reduce the possibilities.

Comment thread module_auto_update/README.rst Outdated

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/149/10.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9.0

'category': 'Extra Tools',
'website': 'https://odoo-community.org/',
'author': 'LasLabs, '
'Juan José Scarafía, '

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be Ingeniería AdHoc? cc @jjscarafia

Comment thread module_auto_update/models/module.py Outdated

@api.model
def update_list(self):
res = super(Module, self).update_list()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed, as it's totally anti-performance, specially on OCB, where installing or updating a module first trigger a module list update, which in case of very large installations will take a lot of time. You already have a method for updating pending modules (running cron job manually), so don't force it here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't actually investigate, but I think this could be some of the issue behind the deadlocks I mentioned

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested in a production database and indeed running odoo --stop-after-init -u any_module reloads dir hashes for all installed addons. Let's move all of this to the wizard method (which is also the one called from cron and Tecnativa/doodba#64) and I'll forward-port the patches.

@lasley

lasley commented Aug 1, 2017

Copy link
Copy Markdown
Contributor

cc @hughesbm

@yajo

yajo commented Aug 2, 2017

Copy link
Copy Markdown
Member Author

The refactor goes in no-fixup commits to be able to cherry-pick it later for v10. It required to change some tests.

Comment thread module_auto_update/models/module.py Outdated
'sha1',
excluded_extensions=exclude,
)
_logger.debug("Computed %s for %s", r.checksum_dir, r.name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep this message?

@lasley lasley Aug 2, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah I think we should move it to the fail case instead (although with fail verbiage instead)

Comment thread module_auto_update/models/module.py Outdated
_logger.debug("Computed %s for %s", r.checksum_dir, r.name)
except TypeError:
# Module path not found
pass

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never pass silently

hughesbm and others added 6 commits August 3, 2017 10:02
* [IMP] module_auto_update: Create new module
* Add checksum_dir and checksum_installed fields to ir.module.module
  * Add checksum_dir to compute current checksum of module directory
    in addons path
  * Add checksum_installed to store checksum of module directory
    when module was last installed or upgraded
* Use checksumdir Python library to compute module directory sha1
  hashes, ignoring pyc and pyo extensions
* Extend update_list method to compare modules' checksum_dir and
  checksum_installed, then change state of modules with differing
  checksums to 'to upgrade'
* Replace Apps/Updates menu item with menu item of same name, which
  updates apps list and displays tree view of ir.module.module
  records with state 'to upgrade'
* Extend create and write methods to store computed checksum_dir as
  checksum_installed during module installation and upgrade, and
  set checksum_installed to False on uninstall
* Use context to stop checksum_installed from being updated during
  upgrade/uninstall cancellation
* Add cron job to periodically check for module upgrades by
  comparing checksums, then perform any available upgrades
* Extend upgrade_module method (called by cron and 'Apply Scheduled
  Upgrades' menu item) to call update_list
* Add post_init_hook to store checksum_installed of existing
  modules
* Add test coverage

* [FIX] module_auto_update: Fix test broken by changes
* Use dummy module to test update_list method instead of
  module_auto_update
By removing the recomputation from `update_list` we get faster CLI module upgrades and it only performs the autoupdate when using the autoupdate wizard or cron.
@yajo
yajo force-pushed the 9.0-module_auto_update branch from bedb81d to f0ed842 Compare August 3, 2017 08:02
@yajo

yajo commented Aug 3, 2017

Copy link
Copy Markdown
Member Author

Rebased, squashed for merge

@rafaelbn rafaelbn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using it in production enviroments

@pedrobaeza
pedrobaeza merged commit c0a0b9a into OCA:9.0 Aug 3, 2017
@pedrobaeza
pedrobaeza deleted the 9.0-module_auto_update branch August 3, 2017 08:22
SiesslPhillip pushed a commit to grueneerde/OCA-server-tools that referenced this pull request Nov 20, 2024
Syncing from upstream OCA/server-tools (14.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants