Automatic kernel upgrade for Custom image from MaaS

Hi @r00ta /@troyanov /all I can see that one of my Ubuntu 24- 6.8.0-87-generic custom image with mellanox ofed package gets failed deployment which was working earlier throwing kernel related errors as below. I am suspecting kernel might got upgraded, Is MaaS automatically updates image kernel while deployment? How can I stop that.

Find the installation output logs below

Building module:
        Cleaning build area...(bad exit status: 2)
        ./configure --with-kernel-dir=/lib/modules/6.8.0-88-generic/build && cd kernel && make...(bad exit status: 1)
        ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/xpmem-dkms.0.crash'
        Error! Bad return status for module build on kernel: 6.8.0-88-generic (x86_64)
        Consult /var/lib/dkms/xpmem/2.7.4/build/make.log for more information.
        dkms autoinstall on 6.8.0-88-generic/x86_64 succeeded for iser isert kernel-mft-dkms knem mlnx-ofed-kernel nvidia-srv srp
        dkms autoinstall on 6.8.0-88-generic/x86_64 failed for xpmem(10)
        Error! One or more modules failed to install during autoinstall.
        Refer to previous errors for more information.
         * dkms: autoinstall for kernel 6.8.0-88-generic
           ...fail!
        run-parts: /etc/kernel/postinst.d/dkms exited with return code 11
        dpkg: error processing package linux-image-6.8.0-88-generic (--configure):
         installed linux-image-6.8.0-88-generic package post-installation script subprocess returned error exit status 11
        No apport report written because MaxReports is reached already
        Errors were encountered while processing:
         linux-headers-6.8.0-88-generic
         linux-headers-generic
         linux-headers-virtual
         linux-generic
         linux-virtual
         linux-image-6.8.0-88-generic
        needrestart is being skipped since dpkg has failed
        E: Sub-process /usr/bin/dpkg returned an error code (1)
        Running command ['udevadm', 'settle'] with allowed return codes [0] (capture=False)
        TIMED subp(['udevadm', 'settle']): 0.005
        Running command ['mount', '--make-private', '/tmp/tmpp4zv8umm/target/sys/firmware/efi/efivars'] with allowed return codes [0] (capture=False)
        Running command ['umount', '/tmp/tmpp4zv8umm/target/sys/firmware/efi/efivars'] with allowed return codes [0] (capture=False)
        Running command ['mount', '--make-private', '/tmp/tmpp4zv8umm/target/sys'] with allowed return codes [0] (capture=False)
        Running command ['umount', '/tmp/tmpp4zv8umm/target/sys'] with allowed return codes [0] (capture=False)
        Running command ['mount', '--make-private', '/tmp/tmpp4zv8umm/target/run'] with allowed return codes [0] (capture=False)
        Running command ['umount', '/tmp/tmpp4zv8umm/target/run'] with allowed return codes [0] (capture=False)
        Running command ['mount', '--make-private', '/tmp/tmpp4zv8umm/target/proc'] with allowed return codes [0] (capture=False)
        Running command ['umount', '/tmp/tmpp4zv8umm/target/proc'] with allowed return codes [0] (capture=False)
        Running command ['mount', '--make-private', '/tmp/tmpp4zv8umm/target/dev'] with allowed return codes [0] (capture=False)
        Running command ['umount', '/tmp/tmpp4zv8umm/target/dev'] with allowed return codes [0] (capture=False)
        finish: cmd-install/stage-curthooks/builtin/cmd-curthooks/installing-kernel: FAIL: installing kernel
        finish: cmd-install/stage-curthooks/builtin/cmd-curthooks: FAIL: curtin command curthooks
        Traceback (most recent call last):
          File "/curtin/curtin/commands/curthooks.py", line 399, in install_kernel
            map_suffix = mapping[codename][version]
                         ~~~~~~~^^^^^^^^^^
        KeyError: 'noble'

When you create your image with packer-maas you also specify the curthooks. It should be in there

Can I get any reference

it depends on the template you used to build your custom image, btw packer-maas/ubuntu/scripts at main · canonical/packer-maas · GitHub

You can control the kernel version during deployment with a custom Curtin userdata file.
Assuming you’re on the Snap-based install, create a file called /var/snap/maas/current/preseeds/curtin_userdata_ubuntu and put in the following content:

#cloud-config
kernel:
  package: linux-image-6.8.0-87-generic
  flavor: hwe
debconf_selections:
 maas: |
  {{for line in str(curtin_preseed).splitlines()}}
  {{line}}
  {{endfor}}
late_commands:
  maas: [wget, '--no-proxy', {{node_disable_pxe_url|escape.json}}, '--post-data', {{node_disable_pxe_data|escape.json}}, '-O', '/dev/null']
  extra_modules: ["curtin", "in-target", "--", "apt", "install", "-y", "--allow-change-held-packages", "linux-modules-extra-6.8.0-87-generic"]

This will pin the Ubuntu kernel to the version you want, instead of always installing the latest one.

Thanks @kevin-reeuwijk /@r00ta … my doubt is if I pin the kernel 6.8.0-87-generic which is for Ubuntu 24, I also deploy servers Ubuntu 22 with kernel 5.15.0-161-generic from the same MaaS… so will it make any issue ? since in curtin file Ubuntu 24 is pinned.

You can have different templates Custom machine setup

@akashram611 as long as you use the builtin Ubuntu images, you can differentiate curtin files by name:

  • Ubuntu 22.04 → curtin_userdata_ubuntu_amd64_generic_jammy
  • Ubuntu 24.04 → curtin_userdata_ubuntu_amd64_generic_noble

Unfortunately this doesn’t work for custom images, where the only usable curtin filename is curtin_userdata_custom.