Skip to content
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

Protobuf v3 osgi #29172

Merged
merged 6 commits into from
Jun 15, 2020
Merged

Protobuf v3 osgi #29172

merged 6 commits into from
Jun 15, 2020

Conversation

barthorre
Copy link
Contributor

I noticed OSGi header information was missing from the Manifest when installing akka-protobuf-v3 (to be used with akka-cluster) in apache karaf.

I managed to fix my issue with the following changes, but I am quiet new to writing code in SBT, meaning any pointers, concerns, best practices etc. are most welcome

@akka-ci
Copy link

akka-ci commented Jun 3, 2020

Thank you for your pull request! After a quick sanity check one of the team will reply with 'OK TO TEST' to kick off our automated validation on Jenkins. This compiles the project, runs the tests, and checks for things like binary compatibility and source code formatting. When two team members have also manually reviewed and (perhaps after asking for some amendments) accepted your contribution, it should be good to be merged.

For more details about our contributing process, check out CONTRIBUTING.md - and feel free to ask!

@akka-ci akka-ci added validating PR is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed validating PR is currently being validated by Jenkins labels Jun 3, 2020
@akka-ci
Copy link

akka-ci commented Jun 3, 2020

Test FAILed.

@raboof
Copy link
Member

raboof commented Jun 3, 2020

@akka-ci akka-ci added validating PR is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR is currently being validated by Jenkins labels Jun 3, 2020
@akka-ci
Copy link

akka-ci commented Jun 3, 2020

Test PASSed.

configImport(),
"*"),
OsgiKeys.exportPackage := Seq("akka.protobufv3.internal.*"),
OsgiKeys.privatePackage := Seq("com.google.protobuf")
Copy link

Choose a reason for hiding this comment

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

Looks like we're embedding the com.google.protobuf package here. Is this intentional? Shouldn't we import these instead?

Copy link
Contributor Author

@barthorre barthorre Jun 3, 2020

Choose a reason for hiding this comment

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

This was indeed intentional, but it should be google.protobuf.* instead of com.google.protobuf, to include the *.proto files instead, no? At least that reflects the current jar's contents.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the question is rather if it is intentional to include the classes from (com.)google.protobuf in the akka protobuf jar . With your instruction you are saying, please include that package in my own jar file, but do not export it to the out side world. If there are bundles that require the google protobuf API, they won't see it from the akka bundle (again, which might be was you are intending to do).

There is another thing that strikes me, but it might be ok: You are exporting a package that is marked as "internal". It might be required to make bundles that depend on the protobuf bundle work, but it looks strange. In our own project we never export "internal" packages as they are not for public consumption.

Perhaps you can validate that your bundle works in Karaf - then the suggested changes are ok from my side as well.

Copy link
Contributor

@briantopping briantopping Jun 3, 2020

Choose a reason for hiding this comment

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

Quick scan here, it looks like there's JAR shading going on in the build, in combination with the OSGi embedding, has anyone confirmed that com.google.protobuf is not being included twice at separate package roots? EDIT: I see that the packaging was changed to only include the protobuf descriptors in b765835.

Copy link
Contributor Author

@barthorre barthorre Jun 3, 2020

Choose a reason for hiding this comment

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

@atooni It was indeed intended to include the protobuf descriptors in the jar, since that was the existing behaviour. As of why they are in there to begin with, I'm not sure. My guess would be the included compiler needs them for adhoc stuff, so I don't see a problem such keeping them in the private package.

I did a small test of creating an akka cluster with 2 nodes each running in a different bundle inside karaf and that works just fine. If needed I can provide a features.xml I assembled to make it run locally.

Copy link
Contributor

@briantopping briantopping Jun 3, 2020

Choose a reason for hiding this comment

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

Not sure if this was for me, my original comment was to make sure there was not two copies of the dependency contents, one shaded and one not. Since it's just the descriptors, an oversight is less of a big deal IMO. Correctness is best tho and it would be good to dump the jar and make sure nothing unexpected is duplicated.

Copy link

Choose a reason for hiding this comment

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

So, why do we export the *.proto files again? Aren't these only useful at compile time? If we only need them to be present in the jar file they can also be marked as Private-Package. I don't see the need for exporting them at runtime.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins and removed tested PR that was successfully built and tested by Jenkins labels Jun 3, 2020
@atooni
Copy link
Contributor

atooni commented Jun 3, 2020

@barthorre You might be aware of #28304. I would be curious about your use case of using akka in OSGi. If you have a minute or two, perhaps you could leave a comment in the issue quoted as we are currently investigating how we can continue with Akka under OSGi in our own project.

@akka-ci akka-ci added tested PR that was successfully built and tested by Jenkins and removed validating PR is currently being validated by Jenkins labels Jun 3, 2020
@akka-ci
Copy link

akka-ci commented Jun 3, 2020

Test PASSed.

@oheger
Copy link
Contributor

oheger commented Jun 4, 2020

I checked the protobuf-v3 bundle produced with these changes with my setup based on Apache Felix and can confirm that it is working as expected. So the content of the bundle and the meta data seem to be fine.

@patriknw patriknw added 2 - pick next Used to mark issues which are next up in the queue to be worked on. The tag is non-binding and removed 2 - pick next Used to mark issues which are next up in the queue to be worked on. The tag is non-binding labels Jun 5, 2020
Copy link
Contributor

@atooni atooni left a comment

Choose a reason for hiding this comment

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

After it has been confirmed that the suggested change works in an OSGi container I am happy with the change

Copy link
Member

@raboof raboof left a comment

Choose a reason for hiding this comment

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

thanks for checking!

@patriknw
Copy link
Member

I compared the contents of the jar from this PR with corresponding jar in master. Looking good. Only difference is MANIFEST.MF

before (master):

Manifest-Version: 1.0
Automatic-Module-Name: akka.protobuf.v3
Implementation-Title: akka-protobuf-v3
Implementation-URL: https://akka.io/
Implementation-Vendor-Id: com.typesafe.akka
Implementation-Vendor: Lightbend Inc.
Implementation-Version: 2.6.6+25-17f7f110
Specification-Title: akka-protobuf-v3
Specification-Vendor: Lightbend Inc.
Specification-Version: 2.6.6+25-17f7f110

after (this PR):

Manifest-Version: 1.0
Automatic-Module-Name: akka.protobuf.v3
Bnd-LastModified: 1592220269523
Bundle-Description: Akka Protobuf V3 is a shaded version of the protob
 uf runtime. Original POM: https://github.com/protocolbuffers/protobuf
 /blob/v3.9.0/java/pom.xml
Bundle-DocURL: https://doc.akka.io/api/akka/2.6.5+112-b7658350
Bundle-License: https://www.apache.org/licenses/LICENSE-2.0.html;descr
 iption=Apache-2.0
Bundle-ManifestVersion: 2
Bundle-Name: akka-protobuf-v3
Bundle-SymbolicName: com.typesafe.akka.protobuf.v3
Bundle-Vendor: Lightbend Inc.
Bundle-Version: 2.6.5.b7658350
Created-By: 11.0.5 (AdoptOpenJDK)
Export-Package: akka.protobufv3.internal;version="2.6.5.b7658350",akka
 .protobufv3.internal.compiler;uses:="akka.protobufv3.internal";versio
 n="2.6.5.b7658350"
Implementation-Title: akka-protobuf-v3
Implementation-URL: https://akka.io/
Implementation-Vendor: Lightbend Inc.
Implementation-Vendor-Id: com.typesafe.akka
Implementation-Version: 2.6.5+112-b7658350
Import-Package: akka.protobufv3.internal
Private-Package: google.protobuf.compiler,google.protobuf
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version>=1.8))
 "
Specification-Title: akka-protobuf-v3
Specification-Vendor: Lightbend Inc.
Specification-Version: 2.6.5+112-b7658350
Tool: Bnd-4.0.0.201805111645

The google/protobuf contains some .proto files, and those are probably not important.

Copy link
Member

@patriknw patriknw left a comment

Choose a reason for hiding this comment

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

LGTM

@patriknw patriknw merged commit 2c4e114 into akka:master Jun 15, 2020
@patriknw patriknw mentioned this pull request Jun 22, 2020
@patriknw patriknw added this to the 2.6.7 milestone Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tested PR that was successfully built and tested by Jenkins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants