Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Fix upgrade error #303

Merged
merged 1 commit into from Nov 21, 2014
Merged

Fix upgrade error #303

merged 1 commit into from Nov 21, 2014

Conversation

terrencehan
Copy link
Contributor

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
@terrencehan
Copy link
Contributor Author

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.

@ferd
Copy link
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?

@terrencehan
Copy link
Contributor Author

@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 

@ghost
Copy link

ghost commented Nov 16, 2014

ping?

@ferd
Copy link
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:

@terrencehan
Copy link
Contributor Author

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

@terrencehan
Copy link
Contributor Author

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

@ferd
Copy link
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.

@ferd
Copy link
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?

@terrencehan
Copy link
Contributor Author

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"]),
Copy link

Choose a reason for hiding this comment

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

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

Copy link
Contributor

Choose a reason for hiding this comment

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

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.

@ghost
Copy link

ghost 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.

@ferd
Copy link
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?

@terrencehan
Copy link
Contributor Author

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

@ferd ferd merged commit a17ee35 into rebar:master Nov 21, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
2 participants