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

[libvirtd] Unable to deploy to libvirtd - "error: cannot figure out user name" #1216

Open
d4g opened this issue Jan 6, 2020 · 11 comments
Open

Comments

@d4g
Copy link

d4g commented Jan 6, 2020

Describe the bug
When I try to deploy a vm via nixops to libvrtd on nixos, it fails with the error:

error: cannot figure out user name

during the step

filling Nix store...

To Reproduce
Steps to reproduce the behavior:

  1. setup libvirtd in nixos according to https://nixos.org/nixops/manual/#idm140737322394336
  2. create 2 config file:
    testvm.nix:
{
  webserver =
    { 
      services.httpd.enable = true;
      services.httpd.documentRoot = "/data";
      fileSystems."/data" =
        { fsType = "nfs4";
          device = "fileserver:/"; };
      users.users.root = {
        password = "toor";
      };
    };

  fileserver =
    { 
      services.nfs.server.enable = true;
      services.nfs.server.exports = "...";
      users.users.root = {
        password = "toor";
      };
    };
}

testvm.libvirtd.nix:

{
  webserver =
    { 
      deployment.targetEnv = "libvirtd";
      deployment.libvirtd.headless = true;
      deployment.libvirtd.extraDevicesXML = ''
      <serial type='pty'>
        <target port='0'/>
      </serial>
      <console type='pty'>
        <target type='serial' port='0'/>
      </console>
    '';
    };

  fileserver =
    { 
      deployment.targetEnv = "libvirtd";
      deployment.libvirtd.headless = true;
      deployment.libvirtd.extraDevicesXML = ''
      <serial type='pty'>
        <target port='0'/>
      </serial>
      <console type='pty'>
        <target type='serial' port='0'/>
      </console>
    '';
    };
}
  1. run nixops create -d netsample testvm.nix testvm.libvirtd.nix
  2. run nixops deploy -d netsample

Expected behavior
VM is setup successfully

Screenshots
Console log:

fileserver> warning: SQLite database '/nix/var/nix/db/db.sqlite' is busy
fileserver> these derivations will be built:
fileserver>   /nix/store/gqr43n26d53hqm9a8pwqrp09ps3cq6n6-libvirtd-image.drv
fileserver>   /nix/store/5kfhh0d3fsznhz1gf5vxgnv7bk5lxs13-libvirtd-ssh-image.drv
fileserver> building '/nix/store/gqr43n26d53hqm9a8pwqrp09ps3cq6n6-libvirtd-image.drv'...
fileserver> Formatting '/nix/store/nbkbr5mvj3jfcj3w5q55x2jfrb9bhr8g-libvirtd-image/image', fmt=qcow2 size=10737418240 cluster_size=65536 lazy_refcounts=off refcount_bits=16
fileserver> cSeaBIOS (version rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org)
fileserver> 
fileserver> 
fileserver> iPXE (http://ipxe.org) 00:03.0 CA00 PCI2.10 PnP PMM+2FF90620+2FEF0620 CA00
fileserver> 
fileserver> 
fileserver> 
fileserver> Booting from ROM...
fileserver> Probing EDD (edd=off to disable)... ocloading kernel modules...
fileserver> insmod: can't insert '/nix/store/dy6p0f3rzfm0hljidhpzh2pwv01mfvag-linux-4.19.92-shrunk/lib/modules/4.19.92/kernel/arch/x86/crypto/crc32c-intel.ko.xz': No such device
fileserver> warning: unable to load /nix/store/dy6p0f3rzfm0hljidhpzh2pwv01mfvag-linux-4.19.92-shrunk/lib/modules/4.19.92/kernel/arch/x86/crypto/crc32c-intel.ko.xz
fileserver> mounting Nix store...
fileserver> mounting host's temporary directory...
fileserver> starting stage 2 (/nix/store/zf0scav9lsqpxliqxi8rj0zs4yqcifv1-vm-run-stage2)
fileserver> Information: You may need to update /etc/fstab.
fileserver> 
fileserver> Information: You may need to update /etc/fstab.
fileserver> 
fileserver> mke2fs 1.45.4 (23-Sep-2019)
fileserver> Creating filesystem with 2621184 4k blocks and 655360 inodes
fileserver> Filesystem UUID: 40968311-6df3-4e73-9eff-922077bb6f85
fileserver> Superblock backups stored on blocks:
fileserver>         32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
fileserver> 
fileserver> Allocating group tables: done 
fileserver> Writing inode tables: done 
fileserver> Creating journal (16384 blocks): done
fileserver> Writing superblocks and filesystem accounting information: done 
fileserver> 
fileserver> tune2fs 1.45.4 (23-Sep-2019)
fileserver> Setting maximal mount count to -1
fileserver> Setting interval between checks to 0 seconds
fileserver> filling Nix store...
fileserver> error: cannot figure out user name
fileserver> [  116.600509] reboot: Power down
fileserver> builder for '/nix/store/gqr43n26d53hqm9a8pwqrp09ps3cq6n6-libvirtd-image.drv' failed with exit code 1
fileserver> cannot build derivation '/nix/store/5kfhh0d3fsznhz1gf5vxgnv7bk5lxs13-libvirtd-ssh-image.drv': 1 dependencies couldn't be built
fileserver> error: build of '/nix/store/5kfhh0d3fsznhz1gf5vxgnv7bk5lxs13-libvirtd-ssh-image.drv' failed
webserver.> these derivations will be built:
webserver.>   /nix/store/gqr43n26d53hqm9a8pwqrp09ps3cq6n6-libvirtd-image.drv
webserver.>   /nix/store/dxljk7ak8g5qjqw8dd4wxmw7sr8b2kl4-libvirtd-ssh-image.drv
webserver.> waiting for locks or build slots...
webserver.> building '/nix/store/gqr43n26d53hqm9a8pwqrp09ps3cq6n6-libvirtd-image.drv'...
webserver.> Formatting '/nix/store/nbkbr5mvj3jfcj3w5q55x2jfrb9bhr8g-libvirtd-image/image', fmt=qcow2 size=10737418240 cluster_size=65536 lazy_refcounts=off refcount_bits=16
webserver.> cSeaBIOS (version rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org)
webserver.> 
webserver.> 
webserver.> iPXE (http://ipxe.org) 00:03.0 CA00 PCI2.10 PnP PMM+2FF90620+2FEF0620 CA00
webserver.> 
webserver.> 
webserver.> 
webserver.> Booting from ROM...
webserver.> Probing EDD (edd=off to disable)... ok
webserver.> cloading kernel modules...
webserver.> insmod: can't insert '/nix/store/dy6p0f3rzfm0hljidhpzh2pwv01mfvag-linux-4.19.92-shrunk/lib/modules/4.19.92/kernel/arch/x86/crypto/crc32c-intel.ko.xz': No such device
webserver.> warning: unable to load /nix/store/dy6p0f3rzfm0hljidhpzh2pwv01mfvag-linux-4.19.92-shrunk/lib/modules/4.19.92/kernel/arch/x86/crypto/crc32c-intel.ko.xz
webserver.> mounting Nix store...
webserver.> mounting host's temporary directory...
webserver.> starting stage 2 (/nix/store/zf0scav9lsqpxliqxi8rj0zs4yqcifv1-vm-run-stage2)
webserver.> Information: You may need to update /etc/fstab.
webserver.> 
webserver.> Information: You may need to update /etc/fstab.
webserver.> 
webserver.> mke2fs 1.45.4 (23-Sep-2019)
webserver.> Creating filesystem with 2621184 4k blocks and 655360 inodes
webserver.> Filesystem UUID: 13e43b29-57b4-4253-a24b-a20c9cb24436
webserver.> Superblock backups stored on blocks:
webserver.>         32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
webserver.> 
webserver.> Allocating group tables: done 
webserver.> Writing inode tables: done 
webserver.> Creating journal (16384 blocks): done
webserver.> Writing superblocks and filesystem accounting information: done 
webserver.> 
webserver.> tune2fs 1.45.4 (23-Sep-2019)
webserver.> Setting maximal mount count to -1
webserver.> Setting interval between checks to 0 seconds
webserver.> filling Nix store...
webserver.> error: cannot figure out user name
webserver.> [  115.287043] reboot: Power down
webserver.> builder for '/nix/store/gqr43n26d53hqm9a8pwqrp09ps3cq6n6-libvirtd-image.drv' failed with exit code 1
webserver.> cannot build derivation '/nix/store/dxljk7ak8g5qjqw8dd4wxmw7sr8b2kl4-libvirtd-ssh-image.drv': 1 dependencies couldn't be built
webserver.> error: build of '/nix/store/dxljk7ak8g5qjqw8dd4wxmw7sr8b2kl4-libvirtd-ssh-image.drv' failed

Additional context
Add any other context about the problem here.

Metadata

 - system: `"x86_64-linux"`
 - host os: `Linux 5.4.1-hardened, NixOS, 20.03pre207998.e0470e11c7a (Markhor)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.1`
 - channels(root): `"nixos-20.03pre207998.e0470e11c7a"`
 - channels(dag): `"nixos-18.03pre121253.2f1a818d00"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@d4g
Copy link
Author

d4g commented Jan 6, 2020

Could be related to:
NixOS/nixpkgs#71157

@d4g d4g changed the title Unable to deploy to libvirtd - "error: cannot figure out user name" [libvirtd] Unable to deploy to libvirtd - "error: cannot figure out user name" Jan 6, 2020
@DavHau
Copy link
Member

DavHau commented Jan 25, 2020

I'm experiencing the same issue on 19.09

@d4g
Copy link
Author

d4g commented Jan 29, 2020

This package should be marked as broken in NixOS, I think. I will open an issue on nixpkgs and crosslink this one.

@mmilata
Copy link
Member

mmilata commented Jan 29, 2020

Workaround is to install nixops from git:

git clone https://github.com/NixOS/nixops.git
cd nixops
echo "nix-community/nixops-libvirtd" >> all-plugins.txt
./update-all
nix-build release.nix -A build.x86_64-linux --arg p "(p: [ p.libvirtd ])"
nix-env -i result/

@RoGryza
Copy link

RoGryza commented Feb 13, 2020

I made an overlay from @mmilata's answer:

self: super:
let
  nixopsLibvirtdSrc = self.fetchFromGitHub {
    owner = "nix-community";
    repo = "nixops-libvirtd";
    sha256 = "0g2ag4mhgrxws3h4q8cvfh4ks1chgpjm018ayqd48lagyvi32l8m";
    rev = "1c29f6c716dad9ad58aa863ebc9575422459bf95";
  };
  nixopsLibvirtdPlugin = self.callPackage "${nixopsLibvirtdSrc}/release.nix" {};
  nixopsSrc = self.fetchFromGitHub {
    owner = "NixOS";
    repo = "nixops";
    sha256 = "0irf9wha2rxla6z7mywj5z29bvjbpwlxqj2s29ygsbhp6hnlbzzz";
    rev = "4cfb70513bad149183adc3ac741c176d83b0e9d5";
  };
  nixopsPlugins = _: [ nixopsLibvirtdPlugin ];

in
{
  nixops = (self.callPackage "${nixopsSrc}/release.nix" { p = nixopsPlugins; }).build.x86_64-linux;
}

@ncryptid
Copy link

Having the overlay to install a more recent version of the libvirt plugin helped, though there are still a couple other problems (for me at least) preventing a trivial libvirt deployment. Opened some issues in the nix-community repo:

nix-community/nixops-libvirtd#7
nix-community/nixops-libvirtd#8

samueldr added a commit to samueldr/nixpkgs that referenced this issue Feb 20, 2020
This includes, but is not limited to:

 * whoami
 * nix >= 2.3.1

See

 * NixOS#71157
 * NixOS/nixops#1216
 * nix-community/nixops-libvirtd#5
samueldr added a commit to NixOS/nixpkgs that referenced this issue Feb 23, 2020
This includes, but is not limited to:

 * whoami
 * nix >= 2.3.1

See

 * #71157
 * NixOS/nixops#1216
 * nix-community/nixops-libvirtd#5

(cherry picked from commit 687e219)
samueldr added a commit to NixOS/nixpkgs that referenced this issue Feb 23, 2020
This includes, but is not limited to:

 * whoami
 * nix >= 2.3.1

See

 * #71157
 * NixOS/nixops#1216
 * nix-community/nixops-libvirtd#5

(cherry picked from commit 687e219)
@samueldr
Copy link
Member

samueldr commented Feb 23, 2020

The Nix-caused NixOS-side regression at the root cause of this issue should be fixed soon in channel bumps. See NixOS/nixpkgs#80680 for details.

It did not fix this particular issue.

This is because there is a chroot involved.

mkaito pushed a commit to serokell/nixpkgs that referenced this issue Mar 2, 2020
This includes, but is not limited to:

 * whoami
 * nix >= 2.3.1

See

 * NixOS#71157
 * NixOS/nixops#1216
 * nix-community/nixops-libvirtd#5
@justinlovinger
Copy link

I made an overlay from @mmilata's answer:

self: super:
let
  nixopsLibvirtdSrc = self.fetchFromGitHub {
    owner = "nix-community";
    repo = "nixops-libvirtd";
    sha256 = "0g2ag4mhgrxws3h4q8cvfh4ks1chgpjm018ayqd48lagyvi32l8m";
    rev = "1c29f6c716dad9ad58aa863ebc9575422459bf95";
  };
  nixopsLibvirtdPlugin = self.callPackage "${nixopsLibvirtdSrc}/release.nix" {};
  nixopsSrc = self.fetchFromGitHub {
    owner = "NixOS";
    repo = "nixops";
    sha256 = "0irf9wha2rxla6z7mywj5z29bvjbpwlxqj2s29ygsbhp6hnlbzzz";
    rev = "4cfb70513bad149183adc3ac741c176d83b0e9d5";
  };
  nixopsPlugins = _: [ nixopsLibvirtdPlugin ];

in
{
  nixops = (self.callPackage "${nixopsSrc}/release.nix" { p = nixopsPlugins; }).build.x86_64-linux;
}

This overlay broke NixOps ec2 for me. In case anyone is wondering why ec2 isn't working after trying this overlay.

@mmilata
Copy link
Member

mmilata commented Jun 7, 2020

You probably also need to include the AWS plugin in nixopsPlugins in addition to the libvirt one. Or did it break in some other way?

@justinlovinger
Copy link

You probably also need to include the AWS plugin in nixopsPlugins in addition to the libvirt one. Or did it break in some other way?

I think that's it. I just wanted to mention it, because the current stable release does not require you to specify extra plugins for AWS.

JoeDupuis added a commit to JoeDupuis/nixos-config that referenced this issue Jun 13, 2020
@pjones
Copy link
Contributor

pjones commented Jul 8, 2020

Any idea how to override plugins with the new flakes build system?

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

No branches or pull requests

9 participants