Skip to content

SYN-3465: Storm Package Uninstall Hook#4840

Draft
MichaelSquires wants to merge 19 commits intosynapse-3xxfrom
blackout/SYN-3465/pkg-uninstall
Draft

SYN-3465: Storm Package Uninstall Hook#4840
MichaelSquires wants to merge 19 commits intosynapse-3xxfrom
blackout/SYN-3465/pkg-uninstall

Conversation

@MichaelSquires
Copy link
Copy Markdown
Contributor

@MichaelSquires MichaelSquires commented Mar 27, 2026

Core Logic (synapse/cortex.py — +225 lines)

  • New uninstallStormPkg() API — graceful uninstall by name with an optional keep list to preserve specific resources (pkg-vars, vaults, dmons, queues, model)
  • onuninstall hook — runs a Storm query from the package definition before cleanup, passing the keep list as a variable
  • _cleanupStormPkg() — automatically deletes dmons, queues, vaults, package variables, and extended model elements (types, forms, props, tag props) unless kept
  • Onload task tracking_pkgOnloadTasks dict tracks async onload tasks so they can be cancelled during delete/uninstall
  • _loadStormPkgDmons() — packages can now declaratively define dmons that are auto-created after onload
  • Guard against re-install during uninstall — blocks addStormPkg if _uninstalling flag is set
  • Startup recovery — resumes in-progress uninstalls on Cortex restart

Schema (synapse/lib/schemas.py — +104 lines)

  • Added onuninstall, dmons, and model fields to the package definition JSON schema
  • model supports declarative types, forms, props, and tagprops

Storm CLI (synapse/lib/stormlib/pkg.py — +63 lines)

  • pkg.del --uninstall flag triggers the new uninstall flow
  • --uninstall-keep argument to specify resources to preserve
  • pkg.list shows uninstall status for in-progress uninstalls

Supporting Changes

  • Tests — +1134 lines in test_lib_stormlib_pkg.py covering uninstall, keep options, model cleanup, dmon lifecycle, onuninstall hooks, restart recovery, and error cases.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.25%. Comparing base (c3aaad9) to head (14ae8ef).

Additional details and impacted files
@@               Coverage Diff               @@
##           synapse-3xx    #4840      +/-   ##
===============================================
+ Coverage        96.23%   96.25%   +0.01%     
===============================================
  Files              259      259              
  Lines            63244    63433     +189     
===============================================
+ Hits             60866    61059     +193     
+ Misses            2378     2374       -4     
Flag Coverage Δ
linux 96.25% <100.00%> (+0.01%) ⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MichaelSquires

This comment was marked as resolved.

Comment thread synapse/lib/stormlib/pkg.py Outdated
Comment thread synapse/tests/test_lib_stormlib_pkg.py Outdated
Comment thread synapse/cortex.py
@MichaelSquires MichaelSquires marked this pull request as ready for review March 28, 2026 11:33
Comment thread synapse/lib/stormlib/pkg.py Outdated
Comment thread synapse/lib/stormlib/pkg.py Outdated
Comment thread synapse/lib/stormlib/pkg.py
Comment thread synapse/lib/stormlib/pkg.py Outdated
Comment thread synapse/lib/schemas.py
Comment thread synapse/cortex.py
Comment thread synapse/cortex.py Outdated
Comment thread synapse/cortex.py Outdated
Comment thread synapse/cortex.py Outdated
Comment thread synapse/cortex.py Outdated
except asyncio.CancelledError:
raise
except Exception as exc:
logger.warning(f'onuninstall failed for package: {name}', exc_info=exc, extra=logextra)
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.

Similar to the question about safemode, won't the uninstall still complete even it "failed"?

Comment thread synapse/cortex.py Outdated
Comment thread synapse/cortex.py
Comment thread synapse/cortex.py
if keep is None or 'pkg-vars' not in keep:
pkgvars = self._getStormPkgVarKV(name)
for key in list(pkgvars.keys()):
await self.popStormPkgVar(name, key)
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 can imagine the things we are storing in storm pkgvars could grow over time, so maybe we would want a delStormPkgVarKV so its just one nexus txn?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can open a ticket for this.

Comment thread synapse/lib/stormlib/pkg.py
Comment thread synapse/lib/stormlib/pkg.py Outdated
Comment thread synapse/lib/stormlib/pkg.py Outdated
Comment thread synapse/lib/stormlib/pkg.py Outdated
Comment thread synapse/lib/stormlib/pkg.py Outdated
Comment thread synapse/lib/schemas.py
Comment thread synapse/cortex.py Outdated
Comment thread synapse/cortex.py Outdated
Comment thread synapse/cortex.py Outdated
Comment thread synapse/cortex.py
@vEpiphyte vEpiphyte added this to the v3.0.0 milestone Apr 2, 2026
@MichaelSquires MichaelSquires marked this pull request as draft April 13, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants