Skip to content

Plugins installation improvements - #8503

Merged
SchrodingersGat merged 36 commits into
inventree:masterfrom
SchrodingersGat:plugins-install
Nov 20, 2024
Merged

SchrodingersGat merged 36 commits into
inventree:masterfrom
SchrodingersGat:plugins-install

Conversation

@SchrodingersGat

@SchrodingersGat SchrodingersGat commented Nov 17, 2024 •

Copy link
Copy Markdown
Member

Summary

This PR improves plugin loading and install to ensure that the plugins are properly synced between different running containers, e.g. when running under docker. Ensures that the required system packages are installed before collecting plugins.

Installation Process

  • Install plugin via the web interface (frontend server)
  • Plugin is installed and added to plugins.txt
  • Activate plugin (via frontend server)
  • Server offloads task (to background worker) to copy static files, etc
  • Background worker checks plugins.txt - sees it has changed - and installs the new plugin
  • Background worker then runs offline processing for the newly activated plugin

@SchrodingersGat SchrodingersGat added enhancement This is an suggested enhancement or new feature plugin Plugin ecosystem docker Docker / docker-compose setup Relates to the InvenTree setup / installation process breaking Indicates a major update or change which breaks compatibility labels Nov 17, 2024
@SchrodingersGat SchrodingersGat added this to the 0.17.0 milestone Nov 17, 2024
@netlify

netlify Bot commented Nov 17, 2024 •

Copy link
Copy Markdown

✅ Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit 566fea5
🔍 Latest deploy log https://app.netlify.com/sites/inventree-web-pui-preview/deploys/673d11a67a6e02000858458b
😎 Deploy Preview https://deploy-preview-8503--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 86 (no change from production)
Best Practices: 100 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@SchrodingersGat SchrodingersGat mentioned this pull request Nov 17, 2024
@codecov

codecov Bot commented Nov 17, 2024 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 75.29412% with 21 lines in your changes missing coverage. Please review.

Project coverage is 84.45%. Comparing base (3a81e03) to head (566fea5).
Report is 280 commits behind head on master.

Files with missing lines Patch % Lines
src/backend/InvenTree/plugin/installer.py 71.15% 15 Missing ⚠️
src/backend/InvenTree/plugin/helpers.py 57.14% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8503      +/-   ##
==========================================
- Coverage   84.61%   84.45%   -0.17%     
==========================================
  Files        1178     1179       +1     
  Lines       53582    53693     +111     
  Branches     2026     2029       +3     
==========================================
+ Hits        45341    45349       +8     
- Misses       7718     7823     +105     
+ Partials      523      521       -2     
Flag Coverage Δ
backend 85.94% <75.29%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@SchrodingersGat

Copy link
Copy Markdown
Member Author

@wolflu05 I have refactored this (again) - a much simpler approach now which ensures that the plugins get installed into all running containers as appropriate

@wolflu05

Copy link
Copy Markdown
Member

Thanks, that looks promising, I'd like to take a closer look and test it myself, but that can take me some days...

@SchrodingersGat

Copy link
Copy Markdown
Member Author

Let me know when you've had a chance to test it. This is one of the final outstanding Issues for 0.17.0

@SchrodingersGat

Copy link
Copy Markdown
Member Author

@matmair if you have a chance to cast your eye over this I'd appreciate it :)

@matmair matmair 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.

Looks good in general; It would really be good to have #4150 available to know how prevalent instances without workers are

Comment on lines -1187 to +1188
if not settings.DOCKER:
# Check an install run
response = registry.install_plugin_file()
self.assertEqual(response, 'first_run')

# Set dynamic setting to True and rerun to launch install
InvenTreeSetting.set_setting('PLUGIN_ON_STARTUP', True, self.user)
registry.reload_plugins(full_reload=True)

# Check that there was another run
response = registry.install_plugin_file()
self.assertEqual(response, True)
registry.reload_plugins(full_reload=True, collect=True)
self.assertGreater(len(settings.PLUGIN_FILE_HASH), 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.

Q: Does this test ensure that the installation actually runs with this setup?

Comment thread src/backend/InvenTree/plugin/plugin.py Resolved
@matmair

matmair commented Nov 19, 2024

Copy link
Copy Markdown
Member

@SchrodingersGat I might be blind but where exactly is the offloading happening? Maybe I am too tired but I seem to miss that change in the diff

@SchrodingersGat

Copy link
Copy Markdown
Member Author

@SchrodingersGat I might be blind but where exactly is the offloading happening? Maybe I am too tired but I seem to miss that change in the diff

When you activate a plugin, the collection of static files is offloaded to the background worker:

image

For this to succeed, the background worker needs to have the same set of plugins installed!

@matmair

matmair commented Nov 20, 2024 •

Copy link
Copy Markdown
Member

Ah now I found the link, the check_for_migrations function is doing the installing

@SchrodingersGat
SchrodingersGat merged commit 01aa8bb into inventree:master Nov 20, 2024
@SchrodingersGat
SchrodingersGat deleted the plugins-install branch November 20, 2024 20:38
@wolflu05

Copy link
Copy Markdown
Member

Sorry, I had no time yet, I was planning to test this on the weekend. But if anything pops up then, I'll just reply here.

@SchrodingersGat

Copy link
Copy Markdown
Member Author

Sorry @wolflu05 got my wires crossed. LMK if you find anything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Indicates a major update or change which breaks compatibility docker Docker / docker-compose enhancement This is an suggested enhancement or new feature plugin Plugin ecosystem setup Relates to the InvenTree setup / installation process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatic plugin static files collection broken after install

3 participants