Fix upgrade error #303

Merged
merged 1 commit into from Nov 21, 2014

Conversation

Projects
None yet
3 participants
Contributor

terrencehan commented Jun 19, 2014

When following instructions in test/upgrade_project/README.md, I failed during releasing another dummy_0.3 with an error message — {error, {no_matching_relup, "0.3", "0.2"}}, supposing 0.2 is the base version. Because, at this moment, rebar uses wildcard to extract the base version. — filelib:wildcard(filename:join([Path, "releases", "*", Name ++ ".rel"])). In this case, we always got releases/0.1/dummy.rel, NOT releases/0.2/dummy_0.2.rel. I think that is a mistake.

In this pull request, I use releases/start_erl.data as a source to get the permanent version, and make sure we could get the specific relup and *.rel file for upgrade.

Beside, now, we pass NewName to systools:make_relup (run_systools/2 in rebar_upgrade.erl ). That results in a mistake, I think, which leads systool to get NewName.rel every time. Again, in this case, dummy_0.2 is right. So, before calling run_systools, I use wildcard Name ++ "*.rel” to expend the second parameter. Because in sasl, it calls file:path_open/3 to read .rel file. If we pass dummy_VERSION, we could get the specific file.

Thanks for your reviewing.

@ferd ferd added the bug label Jun 19, 2014

Contributor

terrencehan commented Jun 20, 2014

Hi, I changed my last commit using git rebase. Now, I check Name_VERSION.rel(with high priority) and Name.rel to get the rel file. Because wildcard will fail when there are more than one rel in reltool.config with same prefix.

Contributor

ferd commented Jul 7, 2014

So I've been trying this one even earlier and following instructions yield issues before this even shows up, with or without the patch:

#### Building version 0.2

    # Now, in another terminal we prepare an upgrade..

    # change release version numbers from 0.1 to 0.2 in
    $EDITOR apps/dummy/src/dummy.app.src
    $EDITOR rel/reltool.config

    rebar compile
    rebar generate
    # previous_release path is relative to your rel directory
    rebar generate-appups previous_release=dummy_0.1
    rebar generate-upgrade previous_release=dummy_0.1
    tar -zvtf rel/dummy_0.2.tar.gz

Right about there:

→ ./rebar generate
==> rel (generate)
WARN:  'generate' command does not apply to directory /Users/ferd/code/self/rebar/test/upgrade_project
→ ./rebar rebar generate-appups previous_release=dummy_0.1
WARN:  'rebar' command does not apply to directory /Users/ferd/code/self/rebar/test/upgrade_project
Command 'rebar' not understood or not applicable
WARN:  ''generate-appups'' command does not apply to directory /Users/ferd/code/self/rebar/test/upgrade_project
Command ''generate-appups'' not understood or not applicable
→ ./rebar generate-upgrade previous_release=dummy_0.1
WARN:  ''generate-upgrade'' command does not apply to directory /Users/ferd/code/self/rebar/test/upgrade_project
Command ''generate-upgrade'' not understood or not applicable
→ tar -zvtf rel/dummy_0.2.tar.gz
tar: Error opening archive: Failed to open 'rel/dummy_0.2.tar.gz'

Despite me getting warnings all the time, the commands do appear to work, but what I get is a 'dummy/' directory, none of the tar files, and really nothing working well.

Git blame seems to say Joe Williams worked on this in 2011 and I'm guessing it's old stuff there. @terrencehan how did you get past these steps?

Contributor

terrencehan commented Jul 10, 2014

@ferd To avoid warnings, all operations were done in rel/ directory.

➜  upgrade_project git:(master) rebar compile                                        
==> dummy (compile)                                                                  
==> rel (compile)                                                                    
==> upgrade_project (compile)                                                        
➜  upgrade_project git:(master) cd rel                                               
➜  rel git:(master) rebar generate                                                   
==> rel (generate)                                                                   
➜  rel git:(master) mv dummy dummy_0.1                                               
➜  rel git:(master) vim reltool.config                                               
➜  rel git:(master) vim ../apps/dummy/src/dummy.app.src                              
➜  rel git:(master) cd ..                                                            
➜  upgrade_project git:(master) ls                                                   
README.md    apps         rebar.config rel                                           
➜  upgrade_project git:(master) rebar compile                                        
==> dummy (compile)                                                                  
==> rel (compile)                                                                    
==> upgrade_project (compile)                                                        
➜  upgrade_project git:(master) cd rel                                               
➜  rel git:(master) rebar generate                                                   
==> rel (generate)                                                                   
➜  rel git:(master) rebar generate-appups previous_release=dummy_0.1                 
==> rel (generate-appups)                                                            
Generated appup for dummy                                                            
Appup generation complete                                                            
➜  rel git:(master) rebar generate-upgrade previous_release=dummy_0.1                                                                                                                                         
==> rel (generate-upgrade)                                                           
dummy_0.2 upgrade package created                                                    
➜  rel git:(master) ls                                                               
dummy            dummy_0.1        dummy_0.2.tar.gz files            reltool.config 
Contributor

tuncer commented Nov 16, 2014

ping?

Contributor

ferd commented Nov 18, 2014

Ah yes, sorry for the long delay. This fell off my radar entirely. So I did all the steps again (and they worked), up until 0.3. So for 0.3, I could replicate your crash fine. I stashed my changes, updated to your branch, and tried again, but found the following issue:

DEBUG=1 ../../../rebar generate-appups previous_release=dummy_0.2
==> rel (generate-appups)
ERROR: start_erl.data is missingERROR: 'generate-appups' failed while processing /home/ferd/code/self/rebar/test/upgrade_project/rel: rebar_abort

Looking into the pull request, it appears nothing actually creates this file. Any idea what this should be about?


I've also drafted up the following change for the README, which makes it easier to follow:

diff --git a/test/upgrade_project/README.md b/test/upgrade_project/README.md
index a644b21..692689d 100644
--- a/test/upgrade_project/README.md
+++ b/test/upgrade_project/README.md
@@ -1,7 +1,9 @@
 #### Building version 0.1
     rebar compile
+    cd rel
     rebar generate
-    mv rel/dummy rel/dummy_0.1
+    mv dummy dummy_0.1
+    cd ../
     rebar clean
     # start the release:
     cd rel/dummy_0.1
@@ -20,15 +22,16 @@
     $EDITOR rel/reltool.config

     rebar compile
+    cd rel
     rebar generate
     # previous_release path is relative to your rel directory
     rebar generate-appups previous_release=dummy_0.1
     rebar generate-upgrade previous_release=dummy_0.1
-    tar -zvtf rel/dummy_0.2.tar.gz
+    tar -zvtf dummy_0.2.tar.gz


 #### Deploying with release_handler
-    mv rel/dummy_0.2.tar.gz rel/dummy_0.1/releases/
+    mv dummy_0.2.tar.gz dummy_0.1/releases/

     # Now use release_handler in the running erlang console for the deploy:
Contributor

terrencehan commented Nov 19, 2014

start_erl.data is created by reltool and that happened after you run 'rebar generate`.

Contributor

terrencehan commented Nov 19, 2014

previous_release=*path*
Is dummy_0.2 a path in your side?

Contributor

ferd commented Nov 19, 2014

Ugh, yeah it was probably something like that. I'll retry again and make sure everything's moved in the right places. Sorry.

Contributor

ferd commented Nov 19, 2014

I got it to work fine, but updated the README to show this:

diff --git a/test/upgrade_project/README.md b/test/upgrade_project/README.md
index a644b21..d0d4a4b 100644
--- a/test/upgrade_project/README.md
+++ b/test/upgrade_project/README.md
@@ -1,7 +1,9 @@
 #### Building version 0.1
     rebar compile
+    cd rel
     rebar generate
-    mv rel/dummy rel/dummy_0.1
+    mv dummy dummy_0.1
+    cd ..
     rebar clean
     # start the release:
     cd rel/dummy_0.1
@@ -20,15 +22,17 @@
     $EDITOR rel/reltool.config

     rebar compile
+    cd rel
     rebar generate
     # previous_release path is relative to your rel directory
     rebar generate-appups previous_release=dummy_0.1
     rebar generate-upgrade previous_release=dummy_0.1
-    tar -zvtf rel/dummy_0.2.tar.gz
+    tar -zvtf dummy_0.2.tar.gz
+    mv dummy dummy_0.2


 #### Deploying with release_handler
-    mv rel/dummy_0.2.tar.gz rel/dummy_0.1/releases/
+    mv dummy_0.2.tar.gz dummy_0.1/releases/

     # Now use release_handler in the running erlang console for the deploy:

@@ -43,3 +47,4 @@
     rm -r rel/dummy

     # Now repeat steps in 'Building version 0.2' and 'Deploying with release_handler'
+    # while replacing '0.2' by '0.3' and '0.1' by '0.2'.

We should give this a proper code review, but if you want to apply the diff to README to it and take credit for it, that's fine by me. I can also apply it myself when merging if you prefer.

@tuncer this appears to pass all the tests, is there anything else we'd need to do in your opinion?

Contributor

terrencehan commented Nov 19, 2014

Thanks for reviewing. Please apply the diff to README :)

+get_rel_file_path(Name, Path, Version) ->
+ Dir = filename:join([Path, "releases", Version]),
+ Path1 = filename:join([Dir, Name ++ "_" ++ Version ++".rel"]),
+ Path2 = filename:join([Dir, Name ++ ".rel"]),
@tuncer

tuncer Nov 19, 2014

Contributor

Maybe we shouldn't align (=) here, as we don't do that in the rest of the tree. @ferd thoughts?

@ferd

ferd Nov 19, 2014

Contributor

I'd agree with that, but I think this one can go through without being fixed. By my fault this pull req has waited long enough I can possibly fix it myself when merging.

+ " "),
+ Version;
+ {error, enoent} ->
+ ?ABORT("start_erl.data is missing", [])
@tuncer

tuncer Nov 19, 2014

Contributor

It's probably a good idea to print the full path (DataPath) for easier debugging when this happens. @ferd?

@ferd

ferd Nov 19, 2014

Contributor

Agreed. This would have saved me time looking where rebar was looking for. Also it needs to have a line break added at the end, given the log I printed showed:

ERROR: start_erl.data is missingERROR: 'generate-appups' failed while processing /home/ferd/code/self/rebar/test/upgrade_project/rel: rebar_abort
Contributor

tuncer commented Nov 19, 2014

@ferd wrote:

this appears to pass all the tests, is there anything else we'd need to do in your opinion?

Made two minor code comments, and other than that we should mirror the README fixes in the wiki (https://github.com/rebar/rebar/wiki/Upgrades) as well.

Contributor

ferd commented Nov 19, 2014

@terrencehan do you want to do the edits, or you're fine with me patching them in as repentance for having left this pull req rot for months for no good reason?

Contributor

terrencehan commented Nov 20, 2014

@ferd It's fine with me. Feel free to edit it when necessary.

@ferd ferd merged commit a17ee35 into rebar:master Nov 21, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment