You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by GitBox <gi...@apache.org> on 2022/07/13 11:31:21 UTC

[GitHub] [brooklyn-server] ahgittin opened a new pull request, #1338: Fix import state bundle order

ahgittin opened a new pull request, #1338:
URL: https://github.com/apache/brooklyn-server/pull/1338

   fixes a bug where state could be exported but not imported, because import didn't do the same gymnastics to allow for b2 referring to b1 in the case where b2 is loaded first.
   
   the `CatalogInitialization` does careful preloading to allow this, on rebind.  it is refactored and used now also for the import case.
   
   test added here fails without the fix commit, and passes now.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brooklyn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [brooklyn-server] jcabrerizo commented on a diff in pull request #1338: Fix import state bundle order

Posted by GitBox <gi...@apache.org>.
jcabrerizo commented on code in PR #1338:
URL: https://github.com/apache/brooklyn-server/pull/1338#discussion_r920970267


##########
rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ServerResource.java:
##########
@@ -609,30 +615,23 @@ public Response importPersistenceData(byte[] persistenceData) {
                     ((RebindManagerImpl)rebindManager).newExceptionHandler());
 
             // install bundles to active management context
-            for (Map.Entry<String, ByteSource> bundleJar : newMementoRawData.getBundleJars().entrySet()){
-                ManagedBundleMemento memento = mementoManifest.getBundle(bundleJar.getKey());
-                log.debug("Installing "+memento+" as part of persisted state import");
-                ReferenceWithError<OsgiBundleInstallationResult> bundleInstallResult = ((ManagementContextInternal)mgmt()).getOsgiManager().get()
-                        .install(InputStreamSource.of("Persistence import - bundle install - "+memento, bundleJar.getValue().read()), "", false, memento.getDeleteable());
-
-                if (bundleInstallResult.hasError()) {
-                    log.debug("Unable to create "+memento+", format '', throwing: "+bundleInstallResult.getError().getMessage(), bundleInstallResult.getError());
-                    String errorMsg = "";
-                    if (bundleInstallResult.getWithoutError()!=null) {
-                        errorMsg = bundleInstallResult.getWithoutError().getMessage();
-                    } else {
-                        errorMsg = Strings.isNonBlank(bundleInstallResult.getError().getMessage()) ? bundleInstallResult.getError().getMessage() : bundleInstallResult.getError().toString();
-                    }
-                    throw new Exception(errorMsg);
+            Map<VersionedName, CatalogInitialization.InstallableManagedBundle> bundles = new LinkedHashMap<>();
+            for (Map.Entry<String, ByteSource> bundleJar : newMementoRawData.getBundleJars().entrySet()) {
+                ManagedBundleMemento bundleMemento = mementoManifest.getBundle(bundleJar.getKey());
+                ManagedBundle b = RebindIteration.newManagedBundle(bundleMemento);
+                bundles.put(b.getVersionedName(), new RebindIteration.InstallableManagedBundleImpl(bundleMemento, b));
+                log.debug("Installing "+bundleMemento+" for "+b+" as part of persisted state import");

Review Comment:
   moving list line one line up  will help to see which bundle failed to install in case something goes wrong and also be more accurate



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brooklyn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [brooklyn-server] asfgit merged pull request #1338: Fix import state bundle order

Posted by GitBox <gi...@apache.org>.
asfgit merged PR #1338:
URL: https://github.com/apache/brooklyn-server/pull/1338


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brooklyn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org