-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add optional_applications to .app resource files #2675
Conversation
Big +1 from me. But to be clear, at least with relx/systools, the order is not subject to be "reordered at any time". A relx release definition passed to systools uses a stable sort even for the top level applications listed for the release. So you can ensure a dependency is started before another by using this. The issue with it is just that it is that it is annoying and pushed on to the end user to get right, meaning every time it is important it must be documented for that particular project, like OpenTelemetry does https://github.com/open-telemetry/opentelemetry-erlang#using |
So scratch that, I'm a "big +1" only with the change I mention in my review comments -- without it, assuming it at least correctly fails in the case of a release when the included optional dep fails to boot, I'm a small +1 :) I believe in the case of a release the boot script does a |
Thanks @tsloughter for the review. "at any time" was poorly phrased on my end, I should have said "at any time new dependencies are introduced", so I have edited it accordingly. Your other feedback is also great, I will do those changes and push them soon. |
All feedback from @tsloughter has been addressed. Docs have been amended and tests have been improved. |
Pushed support for optional applications on systools too. |
We'll take a look at this once vacation times are over, i.e. sometime in august. |
Bumping this :) |
I think |
What do you think about allowing applications in |
@sverker do you have examples of how That is the only thing I could think of as being a reason to include but not start an application. |
One way we use The gotcha is that using |
This seems to fix an issue where `:mdns_lite` is started before `:vintage_net` in the OTP release. When this happens, `:mdns_lite`'s Application.start fails and terminates initialization. This is due to dependency order not being respected on optional dependencies. See erlang/otp#2675 for the work to fix this.
This seems to fix an issue where `:mdns_lite` is started before `:vintage_net` in the OTP release. When this happens, `:mdns_lite`'s Application.start fails and terminates initialization. This is due to dependency order not being respected on optional dependencies. See erlang/otp#2675 for the work to fix this.
9e01563
to
f8ff054
Compare
@sverker I have added reltool support. Note that in Regarding the adding support for optional applications not in the applications list, is it ok if we have this discussion later on? I am hoping this patch is functionally complete and if we add more scenarios, we can do so in a separate discussion. |
They should be removed. Unless I'm misunderstanding. Removal from the |
f8ff054
to
9fbc17c
Compare
I briefly talked to @tsloughter on IRC and, to make sure we are all on the same page, keeping the missing optional applications is not an issue because we are keeping both |
Yes this, and library applications which have no requirement to be started. We also have the scenario with mutual dependency. In that case it would be problematic for both applications to list each other under
I'm not too fond of merging things without ironing out the details. I also think it would be really unfortunate to unnecessarily have to introduce yet another parameter if we can use this new one to solve both problems. I'm not sure using |
If only the At this time we simply document that you need to include it in the release list of apps before your applications that use opentelemetry https://github.com/open-telemetry/opentelemetry-erlang#including-in-release If any app that used it could put it in their |
OK, I understand that it could be important to start an optional application if it exists. And as I understand it We also need to consider the case of circular optional dependencies, which I can agree on should be avoided, but they do exist and might not be so easy to resolve (as inets (optional HTTPS) and ssl (optional CRL handling with HTTP)), a required start will not work in this case. There are probably other such cases as this is something that was not previously disallowed, even if it is in rebar case. |
There are a bunch of testcase failures in sasl related to this change, mostly in systools_SUITE and release_handler_SUITE. |
Thanks @garazdawi, I will investigate. |
I also suspect system:upgrade_SUITE may fail as a result of this change, though it does not fail on all our machines, so I'm not 100% sure.
|
Removed from testing while waiting for testcases to be fixed. |
@garazdawi just a quick update. I am unable to reproduce the sasl failures locally, I am investigating why that is the case. |
I don't know if it makes any difference in this case, but it is always good to test sasl using a released Erlang/OTP and not the source tree. i.e. |
62e3c97
to
1d9819c
Compare
This is where the bug was! The reason it passed locally is because apparently I had fixed it 10 days ago but I forgot to push. :D All tests pass for me now (edit: all tests in sasl) except for 5 tests in systools because they can't find "lib/kernel-7.1". I assume this is exactly because I was running the tests from
But unfortunately the suite never started. I assume I messed up the installation somehow. |
You may need to add it to the PATH for the test to catch the correct I'll re-add this to the tests tomorrow in order to get one night without this patch to more easily see which testcases fail because of it. |
It has ran now! We are down to one failure in |
Hi! 👋 I have rebased the PR to latest master. Please let me know if there is anything I can do to move this forward. Thank you! |
Both Mix and Rebar allow some applications to be absent at runtime - sometimes also known as optional dependencies. However, given optional applications are not stored in .app resource files, releases do not consider optional applications in its boot order, leaving it up to chance if an optional app will be started before its parent. Users can try to explicitly list optional applications on their release definition files, but given the order is not enforced, this manual specification may be reordered when new apps are added, leaving developers with broken releases. This PR introduces the "optional_applications" field to .app resource files. If an application is listed on both "applications" and "optional_applications", it will be attempted to be started before its parent but the parent won't fail to start in case it is missing: If application "b" is an optional application for application "a", and application "b" is missing, "application:start(a)" will still succeed. If application "b" is an optional application for application "a", and application "b" is available, "application:ensure_all_started(a)" will automatically start application "b" before "a". systools and reltool have also been modified to consider optional_applications.
@josevalim I have rebased your single commit on top of a fresh master and force pushed it to jv-opt-apps in your repo. (You had done a merge of master into topic branch which we usually try to avoid). I will put it into test again and if no more issues merge it. |
Both Mix and Rebar allow some applications to be absent
at runtime - sometimes also known as optional dependencies.
However, given optional applications are not stored in .app
resource files, releases do not consider optional applications
in its boot order, leaving it up to chance if an optional app
will be started before its parent.
Users can try to explicitly list optional applications on their
release definition files, but given the order is not enforced,
this manual specification may be reordered when new apps
are added, leaving developers with broken releases.
This PR introduces the "optional_applications" field to .app
resource files. This field must be a subset of the "applications"
field. The reason why it is a subset rather than its own list
of applications is exactly to keep application start order
on "application:start/2" and during releases.
If application "b" is an optional application for application "a",
and application "b" is missing, "application:start(a)" will still
succeed.
If application "b" is an optional application for application "a",
and application "b" is available, "application:ensure_all_started(a)"
will automatically start application "b" before "a".