lxc / incus

Powerful system container and virtual machine manager
https://linuxcontainers.org/incus
Apache License 2.0
2.73k stars 225 forks source link

`incus admin init --preseed` may fail (almost) silently #374

Closed mcondarelli closed 10 months ago

mcondarelli commented 10 months ago

Required information

Reinstalling on the same server I had a partially clobbered ZFS partition.

This situation lead to a failure in incus admin init --preseed

I fixed the error forcing regeneration of zpool and a successive incus admin init --preseed succeeded without any error but default profile was created completely empty (possibly it was created in failed attempt and not fixed afterwards)

Steps to reproduce

I attach full log of everything I did after plain Debian install from netinst with no Desktop Environment selected and with "SSH Server" selected.

Only output of apt install ... was trimmed for brevity (I have full log and I can provide it if useful)

terminal.log

Information to attach

None relevant, if something is needed please ask.

stgraber commented 10 months ago

I'm not sure I see the problem.

Your preseed contains:

When run with the missing zpool, an error was properly reported. When run with the zpool present, it ran correctly and didn't cause an error.

You seem to assume that running a preseed that creates a network and a storage pool will automatically also add those to the default profile, but that's not the case, you need to actually have that defined in the preseed too.

The easiest way to get a full working preseed is to capture the one generated during an interactive incus admin init, for this scenario, you'd obtain:

root@v1:~# incus admin init
Would you like to use clustering? (yes/no) [default=no]: 
Do you want to configure a new storage pool? (yes/no) [default=yes]: 
Name of the new storage pool [default=default]: 
Name of the storage backend to use (dir, zfs) [default=zfs]: 
Create a new ZFS pool? (yes/no) [default=yes]: no
Name of the existing ZFS pool or dataset: default
Would you like to create a new local network bridge? (yes/no) [default=yes]: 
What should the new bridge be called? [default=incusbr0]: 
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: 
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: none
Would you like the server to be available over the network? (yes/no) [default=no]: yes
Address to bind to (not including port) [default=all]: 
Port to bind to [default=8443]: 
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]: 
Would you like a YAML "init" preseed to be printed? (yes/no) [default=no]: yes
config:
  core.https_address: '[::]:8443'
networks:
- config:
    ipv4.address: auto
    ipv6.address: none
  description: ""
  name: incusbr0
  type: ""
  project: default
storage_pools:
- config:
    source: default
  description: ""
  name: default
  driver: zfs
profiles:
- config: {}
  description: ""
  devices:
    eth0:
      name: eth0
      network: incusbr0
      type: nic
    root:
      path: /
      pool: default
      type: disk
  name: default
projects: []
cluster: null

root@v1:~# 

Which means the following preseed:

config:
  core.https_address: '[::]:8443'
networks:
- config:
    ipv4.address: auto
    ipv6.address: none
  description: ""
  name: incusbr0
  type: ""
  project: default
storage_pools:
- config:
    source: default
  description: ""
  name: default
  driver: zfs
profiles:
- config: {}
  description: ""
  devices:
    eth0:
      name: eth0
      network: incusbr0
      type: nic
    root:
      path: /
      pool: default
      type: disk
  name: default
projects: []
cluster: null

Pretty similar to yours, but notably, this comes with a profiles section which adds the two device entries to the default profile.

mcondarelli commented 10 months ago

Thanks @stgraber

I stand corrected and we can close this; I completely missed understanding implications of https://linuxcontainers.org/incus/docs/main/howto/initialize/#default-profile.

I still think this different behavior is a bit confusing (especially so since a "default profile" is created, although empty) but it behaves as documented.

Other thing I am struggling to understand is if it's possible to define a root device from incus create/init command line without resorting to some profile; I know how to add a disk device to a defined instance, but incus create will refuse to create an instance without root so I cannot add it later. I didn't find the right spell in docs (it might well be I missed it).

stgraber commented 10 months ago

--storage will do it