Edeliver removes the base release when doing upgrade


I’m trying to do hot code upgrade using edeliver + distillery.
I made a new dummy commit with just some text change and version update (0.0.3 -> 0.0.4)
Releases work just fine, but when I try to do an upgrade, I’m getting below error:

==> Upgrade failed, version 0.0.3 does not exist:
    expected at: rel/myapp/releases/0.0.3

A remote command failed on:


Output of the command is shown above and the command executed
on that host is printed below for debugging purposes:

FAILED with exit status 1:

    [ -f ~/.profile ] && source ~/.profile
    set -e
    cd /home/deploy/apps/myapp/app_build
    if [ "mix" = "rebar" ]; then
      echo "using rebar to generate release"
      ./rebar   -f generate
    elif [ "mix" = "relx" ]; then
      echo "using relx to generate release"
      ./relx release
    elif [ "mix" = "mix" ]; then
      echo "using mix to generate release"
      MIX_ENV="prod" LINK_SYS_CONFIG="" LINK_VM_ARGS="" APP="myapp" AUTO_VERSION="" BRANCH="master" SKIP_RELUP_MODIFICATIONS="" RELUP_MODIFICATION_MODULE="" USING_DISTILLERY="true" mix do release.version git-revision,  release --verbose --env="prod" --name="myapp" --upgrade --upfrom="0.0.3"

I’ve used these commands with the same result:

  • mix edeliver build upgrade --with=0.0.3 --auto-version=git-revision
  • mix edeliver upgrade production

Weird thing is, I think at the -----> Cleaning generated files from last build step, it removes releases directory all together.

Before doing upgrade, I create and upload the release using: mix edeliver build release Here’s an ls after this command:

deploy@ubuntu:~/apps/myapp$ ls -laF app_build/rel/myapp/releases/
total 20
drwxrwxr-x 3 deploy deploy 4096 Mar 18 01:35 ./
drwxrwxr-x 6 deploy deploy 4096 Mar 18 01:35 ../
drwxrwxr-x 5 deploy deploy 4096 Mar 18 01:35 0.0.3/
-rw-rw-r-- 1 deploy deploy 1819 Mar 18 01:35 RELEASES
-rw-rw-r-- 1 deploy deploy    9 Mar 18 01:35 start_erl.data

Anyone had similar issue?
PS: this is in my rel/config:
set output_dir: “rel/myapp”

any help would be really appreciated, thanks!

1 Like

Same here.

At very first time when I build with edeliver, it creates /rel/my_app/ with /releases folder in it.
But when I launch edeliver upgrade production, at stage of -----> Cleaning generated files from last build it just removes whole /my_app folder under /rel.
And at stage -----> Generating release it just outputs that previous version doesn’t exist and fails the upgrade.

Kind of nonsense.

@Echoes93 just FYI, I was able to skip deleting the folder, but the funny thing I did not solve the problem at all.
You can set SKIP_GIT_CLEAN to true before running the command, so edeliver wouldn’t remove the /releases folder. But when I do that, I started getting deployed version is the same as the upgrade version, will not upgrade. (or something along those lines since i have to wait till I get home to reproduce)

I tried with or without bumping up the version in mix.exs, or using edeliver auto-version management with no luck.

here’s a sample how to use that env var, maybe this solves your issue.
SKIP_GIT_CLEAN=true mix edeliver build upgrade --with=0.0.3 --auto-version=git-revision

btw, removing set output_dir: "rel/myapp" from distillery config solves the problem. Edeliver upgrade finishes with success now, but if I try to access updated code, it fails with NoMatchError and phoenix returns 500 to me.

[error] Ranch listener AdminWeb.Endpoint.HTTP had connection process started with :cowboy_protocol:start_link/4 at #PID<0.1740.0> exit with reason: {{%MatchError{term: :undefined}, [{:hackney_connect, :create_connection, 5, ...

But if I restart application, updated parts are starting to work. It seems like I miss some concepts about edeliver/distillery upgrades. Gonna dive deeper into docs.

@Echoes93 interesting, it still fails me if I remove that:

FAILED with exit status 2:

ssh -o ConnectTimeout=3 deploy@myapp.com
    [ -f "$HOME/.profile" ] && . "$HOME/.profile"
    set -e
    cd "/home/deploy/apps/myapp/app_build/_build/prod/rel/myapp" > /dev/null
    tar -xzvf "myapp_0.0.3.tar.gz" > /dev/null && rm "myapp_0.0.3.tar.gz" > /dev/null > /dev/null

same problem here, i think it’s because of hackney, i have huge amount of errors immediately

14:57:57.672 [error] GenServer Myapp.Telegram.UpdatesFetcher terminating
** (MatchError) no match of right hand side value: :undefined
(hackney) /home/vagrant/Elixir/myapp/build/deps/hackney/src/hackney_connect.erl:69: :hackney_connect.create_connection/5
(hackney) /home/vagrant/Elixir/myapp/build/deps/hackney/src/hackney_connect.erl:37: :hackney_connect.connect/5
(hackney) /home/vagrant/Elixir/myapp/build/deps/hackney/src/hackney.erl:315: :hackney.request/5
(httpoison) lib/httpoison/base.ex:439: HTTPoison.Base.request/9
(myapp) lib/myapp/telegram/updates.ex:29: Myapp.Telegram.UpdatesFetcher.handle_info/2
(stdlib) gen_server.erl:616: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:686: :gen_server.handle_msg/6
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

can you post full error log with hackney error plz

Not sure if this can help you much

    %MatchError{term: :undefined},
        [file: '/home/user/app_build/admin/deps/hackney/src/hackney_connect.erl', line: 69]
        [file: '/home/user/app_build/admin/deps/hackney/src/hackney_connect.erl', line: 37]
        [file: '/home/user/app_build/admin/deps/hackney/src/hackney.erl', line: 315]
        [file: 'lib/bamboo/adapters/sendgrid_adapter.ex', line: 66]
        [file: 'lib/bamboo/mailer.ex', line: 123]
        [file: 'lib/admin_web/controllers/user_controller.ex', line: 16]
        [file: 'lib/admin_web/controllers/user_controller.ex', line: 1]
        [file: 'lib/admin_web/controllers/user_controller.ex', line: 1]
      %Plug.Conn{adapter: {Plug.Adapters.Cowboy.Conn, :...},
      assigns: %{},
      before_send: [],
      body_params: %Plug.Conn.Unfetched{aspect: :body_params},
      cookies: %Plug.Conn.Unfetched{aspect: :cookies},
      halted: false,
      host: "...",
      method: "POST",
      owner: #PID<0.1738.0>,
      params: %Plug.Conn.Unfetched{aspect: :params},
      path_info: ["api", "signup"],
      path_params: %{},
      peer: {{...}, 48740},
      port: 4000,
      private: %{},
      query_params: %Plug.Conn.Unfetched{aspect: :query_params},
      query_string: "",
      remote_ip: {...},
      req_cookies: %Plug.Conn.Unfetched{aspect: :cookies},
      req_headers: [
        {"host", "...:4000"},
        {"connection", "keep-alive"},
        {"content-length", "83"},
        {"user-agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36"},
        {"cache-control", "no-cache"},
        {"origin", "chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop"},
        {"postman-token", "..."},
        {"content-type", "application/json"},
        {"accept", "*/*"},
        {"accept-encoding", "gzip, deflate"},
        {"accept-language", "en-US,en;q=0.9"}
      request_path: "/api/signup",
      resp_body: nil,
      resp_cookies: %{},
      resp_headers: [{"cache-control", "max-age=0, private, must-revalidate"}],
      scheme: :http,
      script_name: [],
      secret_key_base: nil,
      state: :unset, status: nil},

yes, same exact error on my side, so something is wrong with hackney after deploy upgrade…