environment-setup.sh fails

Bug #1847774 reported by Robie Basak
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
New
Undecided
Unassigned

Bug Description

Following the instructions at HACKING.md:

git clone https://github.com/snapcore/snapcraft.git
cd snapcraft
sudo snap install lxd
sudo lxd init --auto --storage-backend=dir

The following commands seem to be unnecessary in a fresh Ubuntu VM from a cloud
image as the ubuntu user is already a member of the lxd group as confirmed by
"groups".
# sudo adduser "$USER" lxd
# newgrp lxd

Then:

$ ./tools/environment-setup.sh
Creating snapcraft-dev
Error: Failed to run: /usr/lib/lxd/lxd forkstart snapcraft-dev /var/lib/lxd/containers /var/log/lxd/snapcraft-dev/lxc.conf:
Try `lxc info --show-log snapcraft-dev` for more info
$ lxc info --show-log snapcraft-dev
Name: snapcraft-dev
Remote: unix://
Architecture: x86_64
Created: 2019/10/11 14:00 UTC
Status: Stopped
Type: persistent
Profiles: default

Log:

lxc snapcraft-dev 20191011140030.686 ERROR conf - conf.c:lxc_map_ids:2999 - newuidmap failed to write mapping "newuidmap: uid range [1000-1001) -> [1000-1001) not allowed": newuidmap 7549 0 100000 1000 1000 1000 1 1001 101001 64535
lxc snapcraft-dev 20191011140030.686 ERROR start - start.c:lxc_spawn:1708 - Failed to set up id mapping.
lxc snapcraft-dev 20191011140030.706 WARN network - network.c:lxc_delete_network_priv:2613 - Invalid argument - Failed to remove interface "vethRXAOYT" from "lxdbr0"
lxc snapcraft-dev 20191011140030.706 ERROR lxccontainer - lxccontainer.c:wait_on_daemonized_start:842 - Received container state "ABORTING" instead of "RUNNING"
lxc snapcraft-dev 20191011140030.707 ERROR start - start.c:__lxc_start:1939 - Failed to spawn container "snapcraft-dev"
lxc 20191011140030.720 WARN commands - commands.c:lxc_cmd_rsp_recv:132 - Connection reset by peer - Failed to receive response for command "get_state"

Expected: container successfully created
Actual: lxd error on the uid mapping

I don't understand why this isn't working. Here's the problem reduced to just
lxd: https://pastebin.ubuntu.com/p/8Sfk349bJf/

It isn't clear to me if this is a problem with the instructions in HACKING.md, with your
setup script, or an lxd bug. However this is a great big obstacle in getting a
development environment set up for snapcraft, so I'm filing it here.

Revision history for this message
Robie Basak (racb) wrote :

Thanks to albert23 in #lxcontainers

The following additional entries were required to be added manually:

/etc/subuid:
root:1000:1

/etc/subgid:
root:1000:1

(where 1000 is, I think, $UID on the host).

I guess this needs adding to HACKING.md? Note: I haven't tried this through yet, but the above fix seems to get around the immediate problem.

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

What base image was used for this Ubuntu VM on the cloud?

Revision history for this message
Robie Basak (racb) wrote :

I believe it was 20191008 (bionic, amd64). Let me try it again though just to make sure.

$ cat /etc/cloud/build.info
build_name: server
serial: 20191008

$ sudo apt update && sudo apt upgrade # on 2019-10-16
...

Then following steps to reproduce as in the bug description, I still get the same failure:

$ ./tools/environment-setup.sh
Creating snapcraft-dev
Error: Failed to run: /usr/lib/lxd/lxd forkstart snapcraft-dev /var/lib/lxd/containers /var/log/lxd/snapcraft-dev/lxc.conf:
Try `lxc info --show-log snapcraft-dev` for more info

$ lxc info --show-log snapcraft-dev
Name: snapcraft-dev
Remote: unix://
Architecture: x86_64
Created: 2019/10/16 11:09 UTC
Status: Stopped
Type: persistent
Profiles: default

Log:

lxc snapcraft-dev 20191016111008.606 ERROR conf - conf.c:lxc_map_ids:2999 - newuidmap failed to write mapping "newuidmap: uid range [1000-1001) -> [1000-1001) not allowed": newuidmap 8229 0 100000 1000 1000 1000 1 1001 101001 64535
lxc snapcraft-dev 20191016111008.606 ERROR start - start.c:lxc_spawn:1708 - Failed to set up id mapping.
lxc snapcraft-dev 20191016111008.627 WARN network - network.c:lxc_delete_network_priv:2613 - Invalid argument - Failed to remove interface "vethCBQKWJ" from "lxdbr0"
lxc snapcraft-dev 20191016111008.628 ERROR lxccontainer - lxccontainer.c:wait_on_daemonized_start:842 - Received container state "ABORTING" instead of "RUNNING"
lxc snapcraft-dev 20191016111008.629 ERROR start - start.c:__lxc_start:1939 - Failed to spawn container "snapcraft-dev"
lxc 20191016111008.645 WARN commands - commands.c:lxc_cmd_rsp_recv:132 - Connection reset by peer - Failed to receive response for command "get_state"

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.