Lxd: lxc list when not on default project results in Error: Not Found

Created on 20 Oct 2018  Â·  16Comments  Â·  Source: lxc/lxd

Required information

  • Distribution: Ubuntu
  • Distribution version: 18.10
  • The output of "lxc info" or if that fails:

    • Kernel version: 4.18.0-1002-gcp

    • LXC version: 3.0.2

    • LXD version: "3.6"

    • Storage backend in use: zfs

Issue description

When I try to list containers when i'm not on a default project I get Error: Not Found

Steps to reproduce

  1. create a container in default
  2. create a project
  3. create a new container in the new project
  4. lxc list when on the new project

All 16 comments

Actually It was while I was running another build using packer. seems lxd can't list container in the same project if packer build is running.

I got this error when using packer build on a container when the project is not default

app-image output will be in this color.

==> app-image: Creating container...
==> app-image: Provisioning with shell script: initialize.sh
==> app-image: Unregistering and deleting deleting container...
Build 'app-image' errored: Retryable error: Error uploading script: exit status 1

Why do you have unmatched version between LXC and LXD ?
LXC version: 3.0.2
LXD version: "3.6"

I have the lastest commit of LXD / LXC (meaning, Client and Server 3.6 )and I don't have any problem on this procedure.

If you have the snap version and deb version installed , remove the deb version to allow the snap version to take over.

I think that’s how it’s supposed to be, I think the lxd in this case is the container engine underneath not the client. Try running lxc info, these version numbers came from there.

Try running a packer build while on a project, I’ve realized that’s where the problem is.

Yes, my bad I thought about the output of lxc --version command instead.
Btw actually my versions LXC and LXD are the lastest commit from the master branches, LXC (3.0.0 - https://github.com/lxc/lxc/commit/65322e5c52bc1792d81efd0076a995fc8a1c0042) and LXD (3.6 - 2e0a016). Ironically LXC 3.0.2 is a tag of two months ago, so I assume my version is beyond what you have installed now, and I couldn't find any error.

I realized your error is not the same as I replicated so I decided to creates another thread about that.
https://github.com/lxc/lxd/issues/5194

I just released an update to stable snap user which fixes a number of issues with projects including this one. Please run snap refresh lxd and try again, your container should then appear.

(One issue which we fixed and matches those symptoms here was about the /1.0/containers ?recursion listing API having bad project filtering in some listing modes)

@stgraber not sure if I'm running the latest one with the fix but the problem still persists, I also can't console into a container in a project. When I type sudo snap info lxd I can see that it was refreshed 3 days ago.

name:      lxd
summary:   System container manager and API
publisher: Canonical✓
contact:   https://github.com/lxc/lxd/issues
license:   unset
description: |
  LXD is a container manager for system containers.

  It offers a REST API to remotely manage containers over the network, using an image based workflow
  and with support for live migration.

  Images are available for all Ubuntu releases and architectures as well as for a wide number of
  other Linux distributions.

  LXD containers are lightweight, secure by default and a great alternative to virtual machines.
commands:
  - lxd.benchmark
  - lxd.buginfo
  - lxd.check-kernel
  - lxd.lxc
  - lxd
  - lxd.migrate
services:
  lxd.activate: oneshot, enabled, inactive
  lxd.daemon:   simple, enabled, active
snap-id:      J60k4JY0HppjwOjW8dZdYc8obXKxujRu
tracking:     stable/ubuntu-18.10
refresh-date: 3 days ago, at 23:05 UTC
channels:
  stable:        3.6         (9263) 69MB -
  candidate:     3.6         (9263) 69MB -
  beta:          ↑
  edge:          git-9fbdafc (9250) 69MB -
  3.0/stable:    3.0.2       (8715) 65MB -
  3.0/candidate: 3.0.2       (9043) 68MB -
  3.0/beta:      ↑
  3.0/edge:      git-c89ae11 (9266) 68MB -
  2.0/stable:    2.0.11      (8023) 28MB -
  2.0/candidate: 2.0.11      (8023) 28MB -
  2.0/beta:      ↑
  2.0/edge:      git-c7c4cc8 (9257) 26MB -
installed:       3.6         (9263) 69MB -

I confirm this bug. I can reproduce it with the steps indicated in the issue description. I'll fix it.

@zacksiri regarding the other issue you mention, what do you mean exactly by "I can't console into a container in a project" ?

@freeekanayaka when I create a container under a project that's not default, I type lxc console test and i get an error

➜  ~ lxc project switch upmaru
➜  ~ lxc launch images:alpine/3.8 test
Creating test
Starting test
➜  ~ lxc list
+------+---------+------------------+------+------------+-----------+-------------------------+
| NAME |  STATE  |       IPV4       | IPV6 |    TYPE    | SNAPSHOTS |        LOCATION         |
+------+---------+------------------+------+------------+-----------+-------------------------+
| test | RUNNING | 240.7.0.2 (eth0) |      | PERSISTENT |           | artello-foundation-hv2v |
+------+---------+------------------+------+------------+-----------+-------------------------+
➜  ~ lxc console test
To detach from the console, press: <ctrl>+a q
Error: Failed running forkconsole: "container is not running: \"test\""
Error: exit status 1

Sorry, actually I retract. I can't reproduce it, I was doing it wrong. I have this test which passes:

# Use containers in a project.
test_issue_5192() {
  ensure_import_testimage

  # Create a container in the default project
  lxc init testimage c1

  # Create a project and switch to it
  lxc project create foo
  lxc project switch foo

  deps/import-busybox --project foo --alias testimage

  # Add a root device to the default profile of the project
  lxc profile device add default root disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")"

  # Create a container in the project
  lxc init testimage c1

  # The container is listed when using this project
  lxc list
  lxc delete c1
  lxc image delete testimage

  # Delete the project
  lxc project delete foo
}

@zacksiri does the test above reflect what you are doing?

I can list the container inside the project now, it's just other operations, like trying to console into the container, is a problem, or when I run packer, because packer pretty much hangs leaving the container in a 'stuck' state making lxc list not work.

if I launch a container it launches fine, and i can run list to see it. but when I run lxc console test i get the error above.

Your test does pass for my case too, I can launch containers and list containers just fine, it's other operations that are the problem.

I confirm the console bug, will provide a fix.

I'm not sure exactly what issues are you hitting with packer tho (if they are related to the lxc console one, or they are separate).

I've reopened the issue, although it has basically changed, since it's now about lxc console.

@freeekanayaka regards to packer it’s probably making calls using commands that is broken when using a project so I’m guess fixing those calls to work with projects will fix issues with packer commands like exec, pushing files etc... I will test out the different commands and let you know what works and what doesn’t.

Was this page helpful?
0 / 5 - 0 ratings