-
Notifications
You must be signed in to change notification settings - Fork 53
Bundle uninstall and snapshot #672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
doesn't yet remove catalog items, and no effort yet to test reinstall. (need to record the defining bundle on registered types.)
…emantics rebind can break however -- we need to phase the bundle installs and the bundle starts
also recognise bundles from their originally installed URL, and misc other related cleanups; upgrade tests and others now passing! note: transformers are only allowed to delete bundles, not change
Tests assume BOMs wouldn't be installed, and either test wasn't expecting to read BOM or BOM had a problem
Removal of XML catalog support caused minor conflicts in imports and tests, easily resolved.
|
Failure due to deadlock described and fixed in #671 . Tests pass locally. |
|
@ahgittin have made a start to this but not got all the way through it yet; looks great; I like the tests |
conflicts - imports (resolved), and osgi test jars (rebuilt)
geomacy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great; I like that the catalog items can now include the references to the bundles they are installed from.
Some minor comments, the main one of which is in discoverManifestFromCatalog.bom.
I haven't tested this yet but will run some tests too.
| ((BasicManagedBundle)suppliedKnownBundleMetadata).setVersion(mbFromUrl.getVersion()); | ||
| } | ||
| } | ||
| if (installedBundle.isAbsent() && suppliedKnownBundleMetadata.getOsgiUniqueUrl()!=null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sequence of ifs here looks like it has the potential to overwrite installedBundle repeatedly; are these various tests meant to be exclusive possibilities? Perhaps there should be elses between the ifs here, with the clauses organised in an appropriate order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's an isAbsent check in each if test and the result of each body might be an absent so `else wouldn't be sufficient
|
|
||
| /** See {@link OsgiArchiveInstaller#install()} - this exposes custom options */ | ||
| @Beta | ||
| public ReferenceWithError<OsgiBundleInstallationResult> install(@Nullable ManagedBundle knownBundleMetadata, @Nullable InputStream zipIn, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's interesting that the only place this is called is in test code; in one sense this maybe isn't needed! But good to have it for completeness's sake.
| try { | ||
| FileOutputStream fos = new FileOutputStream(zipFile); | ||
| Streams.copy(zipIn, fos); | ||
| zipIn.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the closes in the finally.
| throw new IllegalArgumentException("Missing bundle version in BOM or MANIFEST"); | ||
| } | ||
| if (discoveredManifest.getMainAttributes().getValue(Attributes.Name.MANIFEST_VERSION)==null) { | ||
| discoveredManifest.getMainAttributes().putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of "1.0", should this not be consistent with what's declared in the catalog.bom, if any - i.e. should be discoveredBomVersionedName.getVersion() (with checks that discoveredBomVersionedName != null if needed?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is always "1.0" (I think it's about the version of the manifest format?), rather than being the version of the code within the jar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah good point thanks @aledsage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have extracted "1.0" as a private static final with comment that this is what it has to be
|
|
||
| private File osgiCacheDir; | ||
| Map<String, ManagedBundle> managedBundles = MutableMap.of(); | ||
| Map<VersionedName, String> managedBundlesByNam = MutableMap.of(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo managedBundlesByNam
| } | ||
| } | ||
| result.code = OsgiBundleInstallationResult.ResultCode.INSTALLED_NEW_BUNDLE; | ||
| result.message = "Installed "+result.getMetadata().getVersionedName()+" with ID "+result.getMetadata().getId(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth adding a log message in here as well, and below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea
| * <p> | ||
| * Callers should typically fail if anything from this bundle is in use. | ||
| */ | ||
| public void uninstallUploadedBundle(ManagedBundle bundleMetadata) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, this is only called from test code. Arguably the Catalog API is missing a delete method to let you remove bundles you've added via upload. That would be another PR, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to needing delete
| final RegisteredTypeKind kind; | ||
| final String symbolicName; | ||
| final String version; | ||
| String containingBundle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it not be better to make this a VersionedName?
|
|
||
| public String getSymbolicName(); | ||
|
|
||
| public String getContainingBundle(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not make this a VersionedName?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done this and a commit, but then reverted it. I'm not sure everything comes from a bundle just yet. When it does we can reinstate. To me it is tied up with use of search paths etc.
| //RegisteredType ci = mgmt.getTypeRegistry().get(id); | ||
|
|
||
| CatalogItem<?, ?> ci = CatalogUtils.getCatalogItemOptionalVersion(mgmt, id); | ||
| CatalogTransformer.catalogItemSummary(brooklynU, ci, ui.getBaseUriBuilder()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be
CatalogItemSummary summary = CatalogTransformer.catalogItemSummary(brooklynU, ci, ui.getBaseUriBuilder());
result.types().put(id, summary);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
absolutely -- good spot!
|
I have finally got round to doing a test on this, sorry to have taken so long. I will attach a couple of zip files here for test purposes, each being a separate -SNAPSHOT revision of a simple blueprint. The second builds upon the first, getting a bit more complicated. My first test zip file causes an error when I try to upload it; what you see on the command line is and in the Karaf log you get I tested the same file against I will see if I can make a bit of time next week to look at this again and investigate what's going on. |
|
Test files attached (both cause the problem described above. |
… as per PR" This reverts commit f4205fd. The "containingBundle" might, for a transitional period, need to support a reference to a catalog item instead of a bundle, in which case OSGi conventions might not be valid and we want this to be a string. TBC. Will add comment to that effect in the code shortly. If/when reinstated we should also ensure the deserialization accepts strings (should probably also give a custom serializer so VersionedName is always written as a string to prevent bloat in the serialized format).
|
Great comments @geomacy - most addressed. Now working on the bug you found which is caused by making the "simple" |
preserves backwards compatibility, adding a detail=true flag which gives richer info. see extended comment in code. also fixes bug where the added/changed items weren't actually listed, and where it tried to return the full BasicManagedBundle when it just wants an ID.
1954ee2 to
33d9fd6
Compare
|
This should address everything, including backwards compatibility so the existing CLI works (though it doesn't show the detail). New PR coming for the CLI to be able to show the detail. All changes minor and obvious in light of the PR except for 33d9fd6#diff-3da051230841536d82a7bcceabdb280aR113 which has a detailed comment in the code (above the method). @geomacy LMK if you think that is too bad or worth it as a temporary fix until we have a new |
|
@ahgittin changes look good. I'm comfortable with the variant return type on |
|
Tests all look good, I added test672a.zip to catalog then deployed a and again deployed a LGTM, will merge. |
|
Thanks @geomacy. Merged apache/brooklyn-client#53 following @Graeme-Miller 's review there but as I'm a go newbie (g00b ?) appreciate any comments you have there. |
Fixes break from apache#672, I merged without re-running unit tests :-(
Fixes break from apache#672, I merged without re-running unit tests :-(
|
I've been catching up on some of the merged PRs and noticed the following. When doing I get the error: In The code must take this into account and:
|
|
Very good point Svet. I got my test above working with snapshot versions exactly by supplying the OSGI version in the bom, without really thinking about whether that was the right thing to do or not: but indeed it's not right that someone should have to do that. +1 to your bullets above. |
|
P.S. I can have a look at implementing those changes, unless anyone else is particularly keen to do so? |
|
@neykov @geomacy I've been working in this area for a different reason - if people use wdyt about using OSGi versions everywhere, treating anything else including maven versions, as legacy/deprecated? i'm hoping in future all catalog item versions inherit from the bundle version, IE we stop versioning items separately, but that needs to be discussed. (if you installed a non-bundle BOM and bundle would be created.) for convenience if uploading a bundle with a maven (non-osgi) version, we should convert it (one-way) to an osgi version, and also log a warning. if we do that i guess there is a question should we use the converted-to-osgi version string for items that inherit (items that define their own version will use what they define but if that differs from bundle maybe we will warn?) |
|
@ahgittin re. the version numbers; suggest we take this to the mailing list to disuss, but my feeling is that people are used to using Maven versions and it's convenient to regard those as "the" version for a module ( = bundle). Could be annoying/error-prone to have to maintain both a version in a pom.xml and another (separate, but almost the same) version in a catalog.bom. |
|
I'm not sold on the idea, but that could be because I spend too much time in Java land. I like the vision of having bundle-first design, but feel it's hidden from the user so we are free not not leak the details to the UI. In any case this deserves a mailing list discussion. |
|
Results of ML discussion summarised in apache/brooklyn-docs#198 , with PR to follow on this project implementing that (which will be referenced there) |
Supports bundle install and auto-reinstall for snapshot POSTs.
Doesn't do anything for auto-upgrade but if you POST a new snapshot ZIP then redeploy, the newer version gets used. Also cleanly uninstalls catalog items.