Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating an instance with a bogus source config gives a cryptic error #573

Open
simondeziel opened this issue Feb 26, 2024 · 2 comments
Open

Comments

@simondeziel
Copy link
Member

With this bogus config:

from pylxd import Client

def create_container(instance_name):
    client = Client()
    print("Creating container")
    config = {
        "name": instance_name,
        # bogus source
        "source": {
            "type": "image",
            "mode": "pull",
            "alias": "ubuntu:22.04",
        },
        "type": "container"
    }
    container = client.instances.create(config, wait=True)
    print("Starting Container")
    container.start(wait=True)

create_container("foo")

We get the following cryptic error:

$ python3 c.py 
Creating container
Traceback (most recent call last):
  File "/home/ubuntu/git/pylxd/c.py", line 19, in <module>
    create_container("foo")
  File "/home/ubuntu/git/pylxd/c.py", line 15, in create_container
    container = client.instances.create(config, wait=True)
  File "/home/ubuntu/git/pylxd/pylxd/models/instance.py", line 343, in create
    client.operations.wait_for_operation(response.json()["operation"])
  File "/home/ubuntu/git/pylxd/pylxd/models/operation.py", line 57, in wait_for_operation
    operation.wait()
  File "/home/ubuntu/git/pylxd/pylxd/models/operation.py", line 94, in wait
    response = self._client.api.operations[self.id].wait.get()
  File "/home/ubuntu/git/pylxd/pylxd/client.py", line 207, in get
    self._assert_response(
  File "/home/ubuntu/git/pylxd/pylxd/client.py", line 178, in _assert_response
    raise exceptions.LXDAPIException(response)
pylxd.exceptions.LXDAPIException: <exception str() failed>

While lxc monitor --pretty has:

# lxc monitor --pretty
DEBUG  [2024-02-26T15:01:52Z] Event listener server handler started         id=33d585a0-2ba3-43bf-9cac-5d8dda84e083 local=/var/snap/lxd/common/lxd/unix.socket remote=@
DEBUG  [2024-02-26T15:01:58Z] Handling API request                          ip=@ method=GET protocol=unix url=/1.0 username=ubuntu
DEBUG  [2024-02-26T15:01:58Z] Handling API request                          ip=@ method=POST protocol=unix url=/1.0/instances username=ubuntu
DEBUG  [2024-02-26T15:01:58Z] Responding to instance create                
DEBUG  [2024-02-26T15:01:58Z] New operation                                 class=task description="Creating instance" operation=49a9e353-a37b-4198-97b8-135d224d56e7 project=default
INFO   [2024-02-26T15:01:58Z] ID: 49a9e353-a37b-4198-97b8-135d224d56e7, Class: task, Description: Creating instance  CreatedAt="2024-02-26 15:01:58.473108941 +0000 UTC" Err= Location=none MayCancel=false Metadata="map[]" Resources="map[containers:[/1.0/instances/foo] instances:[/1.0/instances/foo]]" Status=Pending StatusCode=Pending UpdatedAt="2024-02-26 15:01:58.473108941 +0000 UTC"
INFO   [2024-02-26T15:01:58Z] ID: 49a9e353-a37b-4198-97b8-135d224d56e7, Class: task, Description: Creating instance  CreatedAt="2024-02-26 15:01:58.473108941 +0000 UTC" Err="Image not provided for instance creation" Location=none MayCancel=false Metadata="map[]" Resources="map[containers:[/1.0/instances/foo] instances:[/1.0/instances/foo]]" Status=Failure StatusCode=Failure UpdatedAt="2024-02-26 15:01:58.473108941 +0000 UTC"
DEBUG  [2024-02-26T15:01:58Z] Failure for operation                         class=task description="Creating instance" err="Image not provided for instance creation" operation=49a9e353-a37b-4198-97b8-135d224d56e7 project=default
DEBUG  [2024-02-26T15:01:58Z] Started operation                             class=task description="Creating instance" operation=49a9e353-a37b-4198-97b8-135d224d56e7 project=default
INFO   [2024-02-26T15:01:58Z] ID: 49a9e353-a37b-4198-97b8-135d224d56e7, Class: task, Description: Creating instance  CreatedAt="2024-02-26 15:01:58.473108941 +0000 UTC" Err= Location=none MayCancel=false Metadata="map[]" Resources="map[containers:[/1.0/instances/foo] instances:[/1.0/instances/foo]]" Status=Running StatusCode=Running UpdatedAt="2024-02-26 15:01:58.473108941 +0000 UTC"
DEBUG  [2024-02-26T15:01:58Z] Handling API request                          ip=@ method=GET protocol=unix url=/1.0/operations/49a9e353-a37b-4198-97b8-135d224d56e7 username=ubuntu
DEBUG  [2024-02-26T15:01:58Z] Handling API request                          ip=@ method=GET protocol=unix url=/1.0/operations/49a9e353-a37b-4198-97b8-135d224d56e7/wait username=ubuntu

For reference, a valid source would look like that (equivalent of a lxc launch ubuntu:22.04):

        "source": {
            "type": "image",
            "mode": "pull",
            "server": "https://cloud-images.ubuntu.com/releases",
            "protocol": "simplestreams",
            "alias": "22.04",
        },
@tomponline
Copy link
Member

@simondeziel did you reproduce the error?

pytest-cos lxc start cos-bar                 
Error: Failed to handle idmapped storage: No such file or directory: "/var/snap/lxd/common/lxd/storage-pools/default/containers/cos-bar/rootfs"
Try `lxc info --show-log cos-bar` for more info

I'm wondering how LXD got so far as to trying to idmap a non-existent dir because invalid image source was specified.

@simondeziel
Copy link
Member Author

@tomponline no, I cannot reproduce that missing rootfs as it leaves me without any instance after the cryptic error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants