This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git

commit 4d9d99eeda888b8366c77fd05115c3bcf1862ecb
Author: Alex Heneveld <[email protected]>
AuthorDate: Mon Dec 6 14:28:56 2021 +0000

    don't mark a bundle for persistence until it is started
    
    suppress persistence attempt and subsequent warnings for bundles which are 
being upgraded
---
 .../core/catalog/internal/CatalogInitialization.java     |  4 ++--
 .../core/mgmt/ha/BrooklynBomOsgiArchiveInstaller.java    | 16 ++++++++--------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git 
a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java
 
b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java
index b16000c..dd0bc22 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java
@@ -663,7 +663,7 @@ public class CatalogInitialization implements 
ManagementContextInjectable {
         for (Map.Entry<VersionedName, InstallableManagedBundle> entry : 
persistedState.getBundles().entrySet()) {
             if (catalogUpgrades.isBundleRemoved(entry.getKey())) {
                 rebindLogger.debug("Filtering out persisted bundle 
"+entry.getKey());
-                
getManagementContext().getRebindManager().getChangeListener().onUnmanaged(entry.getValue().getManagedBundle());
+                // will skip persistence while not yet installed, and will 
remove when uninstalled
             } else {
                 bundles.put(entry.getKey(), entry.getValue());
             }
@@ -673,7 +673,7 @@ public class CatalogInitialization implements 
ManagementContextInjectable {
         for (CatalogItem<?, ?> legacyCatalogItem : 
persistedState.getLegacyCatalogItems()) {
             if (catalogUpgrades.isLegacyItemRemoved(legacyCatalogItem)) {
                 rebindLogger.debug("Filtering out persisted legacy catalog 
item "+legacyCatalogItem.getId());
-                
getManagementContext().getRebindManager().getChangeListener().onUnmanaged(legacyCatalogItem);
+                // will skip persistence while not yet installed, and will 
remove when uninstalled
             } else {
                 legacyCatalogItems.add(legacyCatalogItem);
             }
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/BrooklynBomOsgiArchiveInstaller.java
 
b/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/BrooklynBomOsgiArchiveInstaller.java
index 4dd0fd3..a7d4bc4 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/BrooklynBomOsgiArchiveInstaller.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/BrooklynBomOsgiArchiveInstaller.java
@@ -653,10 +653,6 @@ public class BrooklynBomOsgiArchiveInstaller {
                 osgiManager.managedBundlesRecord.addManagedBundle(result, 
zipFile);
                 result.code = 
OsgiBundleInstallationResult.ResultCode.INSTALLED_NEW_BUNDLE;
                 result.message = "Installed Brooklyn catalog bundle 
"+result.getMetadata().getVersionedName()+" with ID 
"+result.getMetadata().getId()+" ["+result.bundle.getBundleId()+"]";
-                if (!isBlacklistedForPersistence(result.getMetadata())) {
-                    
((BasicManagedBundle)result.getMetadata()).setPersistenceNeeded(true);
-                    
mgmt().getRebindManager().getChangeListener().onManaged(result.getMetadata());
-                }
             } else {
                 Pair<File, ManagedBundle> olds = 
osgiManager.managedBundlesRecord.updateManagedBundleFileAndMetadata(result, 
zipFile);
                 oldZipFile = olds.getLeft();
@@ -664,10 +660,6 @@ public class BrooklynBomOsgiArchiveInstaller {
 
                 result.code = 
OsgiBundleInstallationResult.ResultCode.UPDATED_EXISTING_BUNDLE;
                 result.message = "Updated Brooklyn catalog bundle 
"+result.getMetadata().getVersionedName()+" as existing ID 
"+result.getMetadata().getId()+" ["+result.bundle.getBundleId()+"]";
-                if (!isBlacklistedForPersistence(result.getMetadata())) {
-                    
((BasicManagedBundle)result.getMetadata()).setPersistenceNeeded(true);
-                    
mgmt().getRebindManager().getChangeListener().onChanged(result.getMetadata());
-                }
             }
             log.debug(result.message + " (partial): OSGi bundle installed, 
with bundle start and Brooklyn management to follow");
             // can now delete and close (copy has been made and is available 
from OsgiManager)
@@ -722,6 +714,14 @@ public class BrooklynBomOsgiArchiveInstaller {
                     if (start) {
                         try {
                             log.debug("Starting bundle 
"+result.getVersionedName());
+                            if 
(!isBlacklistedForPersistence(result.getMetadata())) {
+                                
((BasicManagedBundle)result.getMetadata()).setPersistenceNeeded(true);
+                                if (updating) {
+                                    
mgmt().getRebindManager().getChangeListener().onChanged(result.getMetadata());
+                                } else {
+                                    
mgmt().getRebindManager().getChangeListener().onManaged(result.getMetadata());
+                                }
+                            }
                             result.bundle.start();
                         } catch (BundleException e) {
                             log.warn("Error starting bundle 
"+result.getVersionedName()+", uninstalling, restoring any old bundle, then 
re-throwing error: "+e);

Reply via email to