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

Preserve the order of goals in rel file #812

Closed
wants to merge 1 commit into from

Conversation

moiseev
Copy link

@moiseev moiseev commented Aug 20, 2020

According to the systools documentation:

The applications are sorted according to the dependencies between the applications. Where there are no dependencies, the order in the .rel file is kept.

This allows a certain level of control of the application start
sequence, which, unfortunately, is not available if one is to generate
releases using relx, due to the use of an unordered container (map) to
store release app goals.

Say, you have two applications, without any dependencies between them,
that you'd like to include in the same release. The release spec would
then look like: {release, {my_release, "0.0.1"}, [b_app, a_app]}.
Expectation is that, since there are no dependencies between them, b_app
would be first in the boot script, which is not the case due to the way
maps:to_list/0 currently works.

This change adds an extra field to the parsed_goal() map, which stores
the index of the goal in the original release specification. Goals order
is then restored according to this index value prior to generating the
.rel file. No other functionality is affected.

According to the systools documentation:

> The applications are sorted according to the dependencies between the applications. Where there are no dependencies, the order in the .rel file is kept.

This allows a certain level of control of the application start
sequence, which, unfortunately, is not available if one is to generate
releases using relx, due to the use of an unordered container (map) to
store release app goals.

Say, you have two applications, without any dependencies between them,
that you'd like to include in the same release. The release spec would
then look like: `{release, {my_release, "0.0.1"}, [b_app, a_app]}`.
Expectation is that, since there are no dependencies between them, b_app
would be first in the boot script, which is not the case due to the way
`maps:to_list/0` _currently_ works.

This change adds an extra field to the `parsed_goal()` map, which stores
the index of the goal in the original release specification. Goals order
is then restored according to this index value prior to generating the
.rel file. No other functionality is affected.
@tsloughter
Copy link
Member

Thanks, this was definitely a mistake on my part, the apps for a release should always stay as a list with its original order until passed to systools. I'm concerned that this got through tests... I wonder if its the sad case of tests that were meant to catch any change to this passing just by chance.

I'd prefer goals simply be a list, or goals not to be used for the call to realize/2, instead of adding an index. I thought the order would have been kept by the app_specs or applications while goals used simply as a lookup but that clearly isn't the case.

I'll dig around at some point today to see about a fix based on goals as a list or not using goals for the apps passed to realize.

@tsloughter
Copy link
Member

Please see if #813 works for you.

@moiseev
Copy link
Author

moiseev commented Aug 21, 2020

As long as the test passes, should be good for me. Thanks!

@moiseev moiseev closed this Aug 21, 2020
@moiseev moiseev deleted the release-ordering branch August 21, 2020 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants