New process unable to bind to network after upgrade

Hi!

A while back I snapped ejabberd, and recently I’ve updated the packaging to make use of scriptlets so I can have builds complete without having to manually patch things. However, there’s one remaining problem I haven’t managed to get to the bottom of.

Whenever I upgrade the snap, the new ejabberd process is unable to bind to the network, so I end up with my service being unavailable. A simple systemctl restart snap.ejabberd.ejabberd.service restores order, so I’m unsure what is going wrong in the upgrade process that causes it to fail. Today when I performed an upgrade this was the result:

jtait@server:~$ snap refresh --edge ejabberd
2017-05-18T12:41:05+01:00 INFO cannot auto connect ejabberd:network-bind to core:network-bind: (plug auto-connection), existing connection state "ejabberd:network-bind core:network-bind" in the way
ejabberd (edge) 17.04-snap1 from 'wyrddreams' refreshed
jtait@server:~$ netstat -lnt | grep -E '(5222|5269|5280)'
jtait@server:~$ ps -efw | grep ejabberd
root     32557     1  1 12:41 ?        00:00:01 /snap/ejabberd/16/usr/lib/erlang/erts-7.3/bin/beam -K true -P 250000 -- -root /snap/ejabberd/16/usr/lib/erlang -progname erl -- -home /root/snap/ejabberd/16 -- -sname ejabberd -noshell -noinput -noshell -noinput -mnesia dir "/var/snap/ejabberd/16/spool" -ejabberd log_rate_limit 100 log_rotate_size 0 log_rotate_date "" -s ejabberd -smp auto start
jtait@server:~$ sudo ejabberd.ejabberdctl restart
[sudo] password for jtait: 
Failed RPC connection to the node ejabberd@server: nodedown

Commands to start an ejabberd node:
  start      Start an ejabberd node in server mode
  debug      Attach an interactive Erlang shell to a running ejabberd node
  iexdebug   Attach an interactive Elixir shell to a running ejabberd node
  live       Start an ejabberd node in live (interactive) mode
  iexlive    Start an ejabberd node in live (interactive) mode, within an Elixir shell
  foreground Start an ejabberd node in server mode (attached)

Optional parameters when starting an ejabberd node:
  --config-dir dir   Config ejabberd:    /var/snap/ejabberd/16/etc
  --config file      Config ejabberd:    /var/snap/ejabberd/16/etc/ejabberd.yml
  --ctl-config file  Config ejabberdctl: /var/snap/ejabberd/16/etc/ejabberdctl.cfg
  --logs dir         Directory for logs: /var/snap/ejabberd/16/logs
  --spool dir        Database spool dir: /var/snap/ejabberd/16/spool
  --node nodename    ejabberd node name: ejabberd

The new process is running, but not bound to any network ports. That message about auto-connecting interfaces seems pertinent, but I don’t know why it’s happening. The stop script should be waiting for the old process to be completely shut down before exiting, and restarting the service via systemctl works:

jtait@server:~$ sudo systemctl restart snap.ejabberd.ejabberd.service 
jtait@server:~$ netstat -lnt | grep -E '(5222|5269|5280)'
tcp6       0      0 :::5269                 :::*                    LISTEN     
tcp6       0      0 :::5280                 :::*                    LISTEN     
tcp6       0      0 :::5222                 :::*                    LISTEN     
jtait@server:~$ 

So it doesn’t seem like a problem with the old process still hanging around and preventing a proper shutdown. How can I further investigate what’s going on here?