IntersectMBO / cardano-db-sync

A component that follows the Cardano chain and stores blocks and transactions in PostgreSQL
Apache License 2.0
288 stars 162 forks source link

Problems during building a docker image from nix configuration #1784

Open placek opened 1 month ago

placek commented 1 month ago

OS NixOS 24.05.2411.706eef542dec (Uakari)

Versions sancho-5.1.0 (revision: https://github.com/IntersectMBO/cardano-db-sync/releases/tag/sancho-5.1.0 7dd3f60bf12c1d2853baf44e267a8dc3cb52bccf)

Problem Report The documentation for building the Docker image using Nix suggests the following commands:

nix build .#dockerImage
docker load -i ./result

However, the following issues were encountered:

  1. No such flake target as dockerImage:
    ❯ nix build .#dockerImage
    warning: ignoring untrusted substituter 'https://cache.iog.io', you are not a trusted user.
    Run `man nix.conf` for more information on the `substituters` configuration option.
    error: flake 'git+file:///home/placek/Projects/IntersectMBO/cardano-db-sync' does not provide attribute 'packages.x86_64-linux.dockerImage', 'legacyPackages.x86_64-linux.dockerImage' or 'dockerImage'
  2. Build process using other available target (cardano-db-sync-docker) is failing:
    ❯ nix build .#cardano-db-sync-docker
    warning: ignoring untrusted substituter 'https://cache.iog.io', you are not a trusted user.
    Run `man nix.conf` for more information on the `substituters` configuration option.
    error: builder for '/nix/store/gmhpdji3gnwxyf7nqs6a86v4vjyxjks1-docker-layer-cardano-db-sync-base-env.drv' failed with exit code 139;
           last 10 log lines:
           > qemu-kvm: falling back to tcg
           > cSeaBIOS (version rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org)
           >
           >
           > iPXE (http://ipxe.org) 00:03.0 CA00 PCI2.10 PnP PMM+1EFD0F00+1EF30F00 CA00
           >
           >
           >
           > Booting from ROM...
           > Probing EDD (edd=off to disable)... oc./run-vm: line 5:    13 Segmentation fault      (core dumped) /nix/store/81syc34kn8xwvrfzm08xhwf87l3nm3lf-qemu-host-cpu-only-8.1.0/bin/qemu-kvm -cpu max -nographic -no-reboot -device virtio-rng-pci -virtfs local,path=/nix/store,security_model=none,mount_tag=store -virtfs local,path=/build/xchg,security_model=none,mount_tag=xchg -drive file=./image/disk-image.qcow2,if=virtio,cache=unsafe,werror=report -kernel /nix/store/ng20x62170qvivq1ym2gbcxq1s8vpl1d-linux-6.1.53/bzImage -initrd /nix/store/ijp66m0xyb3b9h998w3i7c9in9invw72-initrd/initrd -append "console=ttyS0 panic=1 command=/nix/store/0qgga5n54adny309857n7lwaz90hnbg1-vm-run-stage2 out=/nix/store/6hg5phgzxijbz92srdmqfl37qv59bkgr-docker-layer-cardano-db-sync-base-env mountDisk= loglevel=4" -m 512 -smp cpus=16
           For full logs, run 'nix log /nix/store/gmhpdji3gnwxyf7nqs6a86v4vjyxjks1-docker-layer-cardano-db-sync-base-env.drv'.
    error: 1 dependencies of derivation '/nix/store/j7w1kibymia7d8wdysiy9c3j84dgczk2-docker-image-cardano-db-sync-base-env.tar.gz.drv' failed to build
    error: 1 dependencies of derivation '/nix/store/hwbii13frdrkyksv2pf7qf1q3ingb92x-docker-image-cardano-db-sync-env.tar.gz.drv' failed to build
    error: 1 dependencies of derivation '/nix/store/ch6sn2kwnyav475wqbh3pny63iwv236s-docker-image-cardano-db-sync.tar.gz.drv' failed to build

Additional Log Information: The detailed logs for second part indicate the following issues:

Formatting './image/disk-image.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1073741824 lazy_refcounts=off refcount_bits=16
Could not access KVM kernel module: No such file or directory
qemu-kvm: failed to initialize kvm: No such file or directory
qemu-kvm: falling back to tcg
c[?7lSeaBIOS (version rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org)

iPXE (http://ipxe.org) 00:03.0 CA00 PCI2.10 PnP PMM+1EFD0F00+1EF30F00 CA00
Press Ctrl-B to configure iPXE (PCI 00:03.0)...

Booting from ROM...
Probing EDD (edd=off to disable)... oc[?7l./run-vm: line 5:    13 Segmentation fault      (core dumped) /nix/store/81syc34kn8xwvrfzm08xhwf87l3nm3lf-qemu-host-cpu-only-8.1.0/bin/qemu-kvm -cpu max -nographic -no-reboot -device virtio-rng-pci -virtfs local,path=/nix/store,security_model=none,mount_tag=store -virtfs local,path=/build/xchg,security_model=none,mount_tag=xchg -drive file=./image/disk-image.qcow2,if=virtio,cache=unsafe,werror=report -kernel /nix/store/ng20x62170qvivq1ym2gbcxq1s8vpl1d-linux-6.1.53/bzImage -initrd /nix/store/ijp66m0xyb3b9h998w3i7c9in9invw72-initrd/initrd -append "console=ttyS0 panic=1 command=/nix/store/0qgga5n54adny309857n7lwaz90hnbg1-vm-run-stage2 out=/nix/store/6hg5phgzxijbz92srdmqfl37qv59bkgr-docker-layer-cardano-db-sync-base-env mountDisk= loglevel=4" -m 512 -smp cpus=16

The build process fails with a segmentation fault, indicating an issue with the QEMU virtual machine setup. Additionally, it seems that KVM kernel module is not accessible.

sgillespie commented 1 month ago

Build process using other available target (cardano-db-sync-docker) is failing:

This is the correct target (dockerImage was removed some time ago)

The build process fails with a segmentation fault, indicating an issue with the QEMU virtual machine setup. Additionally, it seems that KVM kernel module is not accessible.

I have been happily building cardano-db-sync-docker on NixOS unstable on a regular basis for a long time without issues (as has CI). I wonder if making yourself a trusted user will make any difference. In any case, I think it would at least allow you to download the cached artifact.

placek commented 1 month ago

I wonder if making yourself a trusted user will make any difference. In any case, I think it would at least allow you to download the cached artifact.

And how to do that? Or is it restricted for IntersectMBO organisation memners only?

sgillespie commented 1 month ago

In my NixOS config, I have:

nix.settings = {
  trusted-users = ["root" "@wheel"];
};
kderme commented 4 weeks ago

Can this close?