From 595b31578ff4c7906e49f596516e4e2f5c9fa6d9 Mon Sep 17 00:00:00 2001 From: sonicaj Date: Sun, 11 Aug 2024 20:00:04 +0500 Subject: [PATCH] Send app events on upgrade for UI (#14183) --- src/middlewared/middlewared/plugins/apps/crud.py | 4 ++-- src/middlewared/middlewared/plugins/apps/rollback.py | 4 +++- src/middlewared/middlewared/plugins/apps/upgrade.py | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/middlewared/middlewared/plugins/apps/crud.py b/src/middlewared/middlewared/plugins/apps/crud.py index 754671c02069e..0e522e066271e 100644 --- a/src/middlewared/middlewared/plugins/apps/crud.py +++ b/src/middlewared/middlewared/plugins/apps/crud.py @@ -223,7 +223,7 @@ def create_internal( update_app_config(app_name, version, new_values) update_app_metadata(app_name, app_version_details, migrated_app) # At this point the app exists - self.middleware.send_event('app.query', 'ADDED', id=app_name) + self.middleware.send_event('app.query', 'ADDED', id=app_name, fields=self.get_instance__sync(app_name)) job.set_progress(60, 'App installation in progress, pulling images') if dry_run is False: @@ -294,7 +294,7 @@ def update_internal(self, job, app, data, progress_keyword='Update'): # TODO: Eventually we would want this to be executed for custom apps as well update_app_metadata_for_portals(app_name, app['version']) job.set_progress(60, 'Configuration updated, updating docker resources') - self.middleware.send_event('app.query', 'CHANGED', id=app_name) + self.middleware.send_event('app.query', 'CHANGED', id=app_name, fields=self.get_instance__sync(app_name)) compose_action(app_name, app['version'], 'up', force_recreate=True, remove_orphans=True) job.set_progress(100, f'{progress_keyword} completed for {app_name!r}') diff --git a/src/middlewared/middlewared/plugins/apps/rollback.py b/src/middlewared/middlewared/plugins/apps/rollback.py index ee0078417b0e0..627a37e87ef61 100644 --- a/src/middlewared/middlewared/plugins/apps/rollback.py +++ b/src/middlewared/middlewared/plugins/apps/rollback.py @@ -61,7 +61,9 @@ def rollback(self, job, app_name, options): # 5) Roll back ix_volume dataset's snapshots if available # 6) Finally update collective metadata config to reflect new version update_app_metadata(app_name, rollback_version) - self.middleware.send_event('app.query', 'CHANGED', id=app_name) + self.middleware.send_event( + 'app.query', 'CHANGED', id=app_name, fields=self.middleware.call_sync('app.get_instance', app_name) + ) try: if options['rollback_snapshot'] and ( app_volume_ds := self.middleware.call_sync('app.get_app_volume_ds', app_name) diff --git a/src/middlewared/middlewared/plugins/apps/upgrade.py b/src/middlewared/middlewared/plugins/apps/upgrade.py index 367496e2414c1..91e999aa644c6 100644 --- a/src/middlewared/middlewared/plugins/apps/upgrade.py +++ b/src/middlewared/middlewared/plugins/apps/upgrade.py @@ -67,7 +67,9 @@ def upgrade(self, job, app_name, options): job.set_progress(40, f'Configuration updated for {app_name!r}, upgrading app') - self.middleware.send_event('app.query', 'CHANGED', id=app_name) + self.middleware.send_event( + 'app.query', 'CHANGED', id=app_name, fields=self.middleware.call_sync('app.get_instance', app_name) + ) try: compose_action(app_name, upgrade_version['version'], 'up', force_recreate=True, remove_orphans=True) finally: