It looks like the snap requires *both* core and core18 preinstalled to
skip the prerequisite checks for the etcd snap. However, it doesn't make
sense since the snap explicitly states it depends on core18.

$ snap info --verbose etcd | grep base:
base: core18

Also, in terms of the etcd charm, it's not designed to have multiple core snaps 
as resources at this point so it can either upload core or core18.
https://api.jujucharms.com/charmstore/v5/etcd-521/archive/metadata.yaml

** Description changed:

  Simpler reproducer:
  
  $ snap version
- snap    2.45.1+18.04.2
- snapd   2.45.1+18.04.2
+ snap    2.42.1+18.04
+ snapd   2.42.1+18.04
  series  16
  ubuntu  18.04
- kernel  4.15.0-112-generic
+ kernel  4.15.0-91-generic
+ 
+ $ snap info --verbose etcd | grep base:
+ base:    core18
  
  $ snap download core18
  Fetching snap "core18"
  Fetching assertions for "core18"
  Install the snap with:
     snap ack core18_1885.assert
     snap install core18_1885.snap
  
  $ snap download --channel 3.3/stable etcd
  Fetching snap "etcd"
  Fetching assertions for "etcd"
  Install the snap with:
     snap ack etcd_229.assert
     snap install etcd_229.snap
  
  $ sudo iptables -A OUTPUT -p tcp --destination-port 80 -j REJECT 
--reject-with tcp-reset
  $ sudo iptables -A OUTPUT -p tcp --destination-port 443 -j REJECT 
--reject-with tcp-reset
  
  $ sudo snap install --dangerous ./core18_1885.snap
  core18 20200724 installed
  
  $ sudo snap install --dangerous ./etcd_229.snap
  error: cannot perform the following tasks:
- - Ensure prerequisites for "etcd" are available (cannot install system snap 
"snapd": cannot get nonce from store: Post 
https://api.snapcraft.io/api/v1/snaps/auth/nonces: dial tcp 91.189.92.41:443: 
connect: connection refused)
- 
+ - Ensure prerequisites for "etcd" are available (Post 
https://api.snapcraft.io/v2/snaps/refresh: dial tcp 91.189.92.41:443: connect: 
connection refused)
  
  ===
  
  How to reproduce:
  
  1. set apt-http-proxy for deb package downloads
  
  $ juju model-config apt-http-proxy
  http://squid-deb-proxy.lxd:8000/
  
  2. block outgoing connections to port 80 and 443 to simulate the air-
  gapped env
  
  $ cat ./userdata.yaml
  cloudinit-userdata: |
    preruncmd:
      - iptables -A OUTPUT -p tcp --destination-port 80 -j REJECT --reject-with 
tcp-reset
      - iptables -A OUTPUT -p tcp --destination-port 443 -j REJECT 
--reject-with tcp-reset
  
  $ juju model-config ./userdata.yaml
  
  3. deploy the charm with the pre-downloaded charm and pre-downloaded
  resources (note: core.snap is core18.snap required by the etcd
  3.3/stable snap).
  
  juju deploy -n 1 --resource core=./resources/etcd/core.snap --resource
  etcd=./resources/etcd/etcd.snap --resource
  snapshot=./resources/etcd/snapshot.gz ./charms/etcd
  
  Then, the charm will fail with the following:
  
  2020-08-12 01:50:29 ERROR juju-log Hook error:
  Traceback (most recent call last):
    File 
"/var/lib/juju/agents/unit-etcd-0/.venv/lib/python3.6/site-packages/charms/reactive/__init__.py",
 line 74, in main
      bus.dispatch(restricted=restricted_mode)
    File 
"/var/lib/juju/agents/unit-etcd-0/.venv/lib/python3.6/site-packages/charms/reactive/bus.py",
 line 390, in dispatch
      _invoke(other_handlers)
    File 
"/var/lib/juju/agents/unit-etcd-0/.venv/lib/python3.6/site-packages/charms/reactive/bus.py",
 line 359, in _invoke
      handler.invoke()
    File 
"/var/lib/juju/agents/unit-etcd-0/.venv/lib/python3.6/site-packages/charms/reactive/bus.py",
 line 181, in invoke
      self._action(*args)
    File "/var/lib/juju/agents/unit-etcd-0/charm/reactive/etcd.py", line 313, 
in snap_install
      snap.install('etcd', channel=channel, classic=False)
    File "lib/charms/layer/snap.py", line 66, in install
      _install_local(res_path, **kw)
    File "lib/charms/layer/snap.py", line 328, in _install_local
      subprocess.check_call(cmd)
    File "/usr/lib/python3.6/subprocess.py", line 311, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['snap', 'install', 
'--channel=3.3/stable', '--dangerous', 
'/var/lib/juju/agents/unit-etcd-0/resources/etcd/etcd.snap']' returned non-zero 
exit status 1.
  
  2020-08-12 01:50:29 ERROR juju.worker.uniter.operation runhook.go:136
  hook "install" (via explicit, bespoke hook script) failed: exit status 1
  
  by running the command by hand, I get the following:
  
  ubuntu@juju-cb1bd7-1:~$ sudo snap install --channel=3.3/stable --dangerous 
/var/lib/juju/agents/unit-etcd-0/resources/etcd/etcd.snap
  error: cannot perform the following tasks:
  - Ensure prerequisites for "etcd" are available (cannot install system snap 
"snapd": Post https://api.snapcraft.io/v2/snaps/refresh: dial tcp 
91.189.92.41:443: connect: connection refused)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1891259

Title:
  snap installation fails at 'Ensure prerequisites for "etcd" are
  available' in air-gapped environments

To manage notifications about this bug go to:
https://bugs.launchpad.net/charm-etcd/+bug/1891259/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to