Skip to content

Remove name collisions of replaced files in multi-node setups#427

Merged
lrascao merged 1 commit intoerlware:masterfrom
saleyn:vars
Nov 11, 2016
Merged

Remove name collisions of replaced files in multi-node setups#427
lrascao merged 1 commit intoerlware:masterfrom
saleyn:vars

Conversation

@saleyn
Copy link
Copy Markdown
Contributor

@saleyn saleyn commented Dec 22, 2015

Generated vm.2.args and sys.2.config files are renamed to vm.${NAME}.args and sys.${NAME}.config to avoid naming collisions in the multi-node startup off of the same release dir.

@saleyn saleyn mentioned this pull request Dec 22, 2015
@evanmcc
Copy link
Copy Markdown
Contributor

evanmcc commented Dec 22, 2015

Thanks! I can't get this to work right now but have to run. Hopefully I will have some time this afternoon to poke at it.

@saleyn
Copy link
Copy Markdown
Contributor Author

saleyn commented Dec 22, 2015

It seems to work fine in my Linux setup with multiple nodes.

@evanmcc
Copy link
Copy Markdown
Contributor

evanmcc commented Dec 23, 2015

From reading the code, this seems like it'd work well, and I vlosed my PR #357 in favor of this one. That said, I can't make it play nice with rebar3 on my local setup for reasons that seem unrelated to relx. So can't test right now. Happy to dig into it more after vacation, or just to see if merged if no one else is having issues getting it to work as my problem is likely unrelated.

@saleyn
Copy link
Copy Markdown
Contributor Author

saleyn commented Dec 23, 2015

What you need to do to make it work with rebar3 is to remove the rebar.lock, so that it'd get regenerated, and also apply this (until rebar3 is modified to take the latest relx changes):

diff --git a/rebar.config b/rebar.config
index 276acff..156219c 100644
--- a/rebar.config
+++ b/rebar.config
@@ -7,7 +7,7 @@
         {providers,           "1.6.0"},
         {getopt,              "0.8.2"},
         {bbmustache,          "1.0.4"},
-        {relx,                "3.9.0"},
+        {relx,  ".*",         {git, "https://github.com/saleyn/relx.git", {branch, "vars"}}},
         {cf,                  "0.2.1"},
         {cth_readable,        "1.1.0"},
         {eunit_formatters,    "0.3.1"}]}.

@ferd
Copy link
Copy Markdown
Collaborator

ferd commented Dec 23, 2015

you don't need to remove the rebar.lock. You can call rebar3 upgrade <app> or rebar3 unlock <app> so you can modify only the required dependencies without unfreezing the other ones (unless transient dependencies are modified by the upgrade, which then gets reflected in the lock file)

@saleyn
Copy link
Copy Markdown
Contributor Author

saleyn commented Dec 23, 2015

Thanks for the tip.

@tsloughter
Copy link
Copy Markdown
Member

@saleyn rebase pls

@evanmcc still planning to give this a try? Would like your feedback.

Comment thread priv/templates/extended_bin Outdated
# Generate a random id
relx_gen_id() {
od -t x -N 4 /dev/urandom | head -n1 | awk '{print $2}'
od -X -N 4 /dev/urandom | head -n1 | gawk '{print $2}'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is there some behavior of gawk that we need here? it isn't universally installed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's not needed in this particular line, but may be needed in other place (see comments below), so this one has been renamed to match other gawk invocations.

@evanmcc
Copy link
Copy Markdown
Contributor

evanmcc commented Jun 13, 2016

Sorry that I took ages to look at this; however it does not seem to work correctly with rebar3. It isn't getting the correct location for my vm.args and thus can't generate per-node versions.

@saleyn
Copy link
Copy Markdown
Contributor Author

saleyn commented Jun 13, 2016

Perhaps you can elaborate a bit more with examples? I have been using this approach/patch in production on multi-node Linux systems for a while now without issues.

@lrascao
Copy link
Copy Markdown
Collaborator

lrascao commented Sep 25, 2016

@saleyn i know it's been a while but could you please rebase onto master so i could give a try as well?
thanks!

@saleyn
Copy link
Copy Markdown
Contributor Author

saleyn commented Sep 26, 2016

I rebased the branch to master.

@lrascao
Copy link
Copy Markdown
Collaborator

lrascao commented Oct 4, 2016

@saleyn, we've since put some tests in place that exercise the extended_bin script, could you please rebase onto master (again, i'm sorry) and try those out? Also it would be helpful if you could squash the 3 commits into just 1 please

@saleyn
Copy link
Copy Markdown
Contributor Author

saleyn commented Oct 4, 2016

Done

@lrascao
Copy link
Copy Markdown
Collaborator

lrascao commented Oct 4, 2016

commit cf5ed97 removed a lot of bash related stuff due to it not being supported in Solaris/SmartOS, is the switch to bash strictly necessary to make the multi-node setup work?

@saleyn
Copy link
Copy Markdown
Contributor Author

saleyn commented Oct 5, 2016

The multi-node setup doesn't depend on bash features. The bash dependency was created to support advanced variable substitution (e.g. ${NODE_NAME,,}, ${SOME_NAME^^}, ${SOME_OTHER_VALUE:-default_value}) - which were the features I was after in the first place. Support for multi-node setup was a secondary feature added into this commit, which is merely naming sys.config and vm.args to include a node name to make it unique.

@lrascao
Copy link
Copy Markdown
Collaborator

lrascao commented Oct 5, 2016

I see, maybe it's best to separate the two issues, one PR for multi-node setup and a different one for advanced variable substitution (perhaps with a different approach than replace sh with bash)

@saleyn
Copy link
Copy Markdown
Contributor Author

saleyn commented Oct 5, 2016

How about having two separate extended_bin files - one for those OS's that have bash (which is the majority) and one for those that don't. The alternative is to have a more complex script that checks the value of current $SHELL and calls shell-specific functions.

@lrascao
Copy link
Copy Markdown
Collaborator

lrascao commented Oct 5, 2016

That's one way, i'm sure more people will want to weigh in on this, still i think we should split this into PRs and keep the bash discussion in the new one, what do you think?

@saleyn
Copy link
Copy Markdown
Contributor Author

saleyn commented Oct 5, 2016

I'll look into it some time next week.

@lrascao lrascao mentioned this pull request Oct 27, 2016
@GoelDeepak
Copy link
Copy Markdown
Contributor

@saleyn I agree with you to keep separate script for different OS. It keeps the individual script clean. Also, as @lrascao mentioned we should probably separate bash related changes into a separate PR.

saleyn added a commit to saleyn/relx that referenced this pull request Oct 28, 2016
This update extends PR erlware#427 by supporting variable replacement
syntax of bash to be used in vm.args and sys.config.

The changes are backward-compatible with non-bash shells.
@GoelDeepak
Copy link
Copy Markdown
Contributor

@lrascao @saleyn The latest commit (faddc92) creates files with random name in /tmp directory. Wouldn't that resolve the problem of multi-node? Is there anything else that we still have to achieve?

@saleyn
Copy link
Copy Markdown
Contributor Author

saleyn commented Oct 28, 2016

I believe that the approach of creating random files in /tmp makes the problem more complex than it should be - it creates a ton of files that need to be garbage collected somehow, and also when there are several users testing, the issue of finding the right files is not straight-forward.

Additionally, the proposed version allows for the node name in the vm.args to contain variables as well, and the NAME gets properly evaluated prior to including it in the generated vm.*.args and sys.*.config.

@GoelDeepak
Copy link
Copy Markdown
Contributor

@saleyn Make sense. Can we add a parameter for the location of the modified vm..args (sys..config)? By default, it would use the same location as vm.args. However, if some other location is provided then we could use that.

@saleyn
Copy link
Copy Markdown
Contributor Author

saleyn commented Oct 29, 2016

You are welcome to send a patch.

@lrascao
Copy link
Copy Markdown
Collaborator

lrascao commented Oct 29, 2016

so to sum up the changes still needed:

  • a separate env var to specify the location of the replaced vm.args/sys.config, default is same location as original ones
  • when creating vm.args/sys.config with replaced vars add ${NAME} to the filename

am i missing anything else?

@saleyn
Copy link
Copy Markdown
Contributor Author

saleyn commented Oct 30, 2016

Not sure if you described the changes needed before or after applying my reworked patch. If you meant the changes needed after applying the patch, then it's only the first bullet. The second bullet is already covered by the patch.

@lrascao
Copy link
Copy Markdown
Collaborator

lrascao commented Oct 30, 2016

i meant before your patch, do you think you can narrow down the changes to only contain the strictly necessary to implement the second bullet? There are a lot of other changes that seem unrelated

@saleyn
Copy link
Copy Markdown
Contributor Author

saleyn commented Oct 30, 2016

If your comment is for changes "before the patch", then the third bullet is to allow for node name in vm.args to contain shell variables as well.

My patch addresses bullets 2 and 3 only. Aside from that there's only one slight change that readlink is used with '-f' option, which canonicalizes the real script's path, so that it's clear where the script actually is if components of the path are links as well. Even though it seems like there are many changes - if you follow the changes, the majority is a result of merely rearranging the same code, so that the formation of ${NAME} takes place early enough to make it available BEFORE naming the OUT_FILE_PATH. Aside from that they bare no functional changes.

@GoelDeepak
Copy link
Copy Markdown
Contributor

@saleyn @lrascao If we do not include first bullet then this patch will undo whatever I did in my patch. I feel we should include env variable in this patch itself.

@lrascao
Copy link
Copy Markdown
Collaborator

lrascao commented Nov 1, 2016

i also agree that is best to include it, @saleyn could you please make this change? i think it's just a matter of consulting a new env var that defaults to empy string and prefix the .orig files path with it

saleyn added a commit to saleyn/relx that referenced this pull request Nov 1, 2016
This update extends PR erlware#427 by supporting variable replacement
syntax of bash to be used in vm.args and sys.config.

The changes are backward-compatible with non-bash shells.
@saleyn
Copy link
Copy Markdown
Contributor Author

saleyn commented Nov 1, 2016

Added optional RELX_OUT_FILE_PATH variable which customizes the location of generated vm.${NAME}.args and sys.${NAME}.config.

@GoelDeepak
Copy link
Copy Markdown
Contributor

lgtm. Should we also append few tests to cover RELX_OUT_FILE_PATH case?

@lrascao
Copy link
Copy Markdown
Collaborator

lrascao commented Nov 2, 2016

thanks @saleyn, looks good
@GoelDeepak i've already got some in the works, i'm now trying to figure out how to squash into @saleyn's commit

@lrascao
Copy link
Copy Markdown
Collaborator

lrascao commented Nov 2, 2016

@saleyn could you please cherry-pick 77450da (lrascao@77450da) into your branch so the new tests can run?

@lrascao
Copy link
Copy Markdown
Collaborator

lrascao commented Nov 2, 2016

@saleyn sorry, the previous commit was missing the new test in the suite all/0, could you please pick again this time lrascao/relx@5227de18?

@lrascao
Copy link
Copy Markdown
Collaborator

lrascao commented Nov 3, 2016

cool, looks good, now it's just a matter of squashing 7cef84e and 09dc948 (6bc7af4 can be dropped) and rebasing onto master and it's good to merge

@GoelDeepak
Copy link
Copy Markdown
Contributor

Any update on this one?

@lrascao
Copy link
Copy Markdown
Collaborator

lrascao commented Nov 9, 2016

@saleyn need a hand with this or just too busy?

@saleyn
Copy link
Copy Markdown
Contributor Author

saleyn commented Nov 9, 2016

Was busy with other stuff. Check out now.

@lrascao lrascao merged commit c305c89 into erlware:master Nov 11, 2016
@lrascao
Copy link
Copy Markdown
Collaborator

lrascao commented Nov 11, 2016

thanks!

saleyn added a commit to saleyn/relx that referenced this pull request Nov 11, 2016
This update extends PR erlware#427 by supporting variable replacement
syntax of bash to be used in vm.args and sys.config.

The changes are backward-compatible with non-bash shells.
saleyn added a commit to saleyn/relx that referenced this pull request Dec 9, 2016
This update extends PR erlware#427 by supporting variable replacement
syntax of bash to be used in vm.args and sys.config.

The changes are backward-compatible with non-bash shells.
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.

6 participants