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

subprocess.CalledProcessError: Command '['dracut', '--conf', 'tmp.conf']' returned non-zero exit status 1. #1296

Closed
Rtoax opened this issue Dec 28, 2022 · 1 comment
Assignees

Comments

@Rtoax
Copy link

Rtoax commented Dec 28, 2022

Error Reason

Lorax need DracutChroot() class during make initrd.img, and lorax support --dracut-conf argument to pass the dracut_args for dracut --conf argument. In old dracut(<055-105-g7de9ffc05747) version, dracut.sh will skip the --conf conffile check if it is not exist, However, the new dracut(>=055-105-g7de9ffc05747, commit 7de9ffc05747("fix(dracut.sh): do not ignore invalid config file or dir path")) will exit 1 if --conf conffile is not exist, the patch as follows:

 # if we were not passed a config file, try the default one
-if [[ ! -f $conffile ]]; then
+if [[ -z $conffile ]]; then
     if [[ $allowlocal ]]; then
         conffile="$dracutbasedir/dracut.conf"
     else
         conffile="$dracutsysrootdir/etc/dracut.conf"
     fi
+elif [[ ! -f $conffile ]]; then
+    printf "%s\n" "dracut: Configuration file '$conffile' not found." >&2
+    exit 1
 fi

What we can do?(maybe)

  1. forbidden lorax --dracut-conf argument;
  2. find a good way to pass the --dracut-conf conffile in DracutChroot(), so that, [[ ! -f $conffile ]] will not exit 1;

Lorax Fatal Message

$ sudo lorax --dracut-conf /home/rongtao/cclinux/tools/dracut/conf.d/01.conf ...
...
rebuilding initramfs images
2022-12-27 10:51:01,768: dracut args = ['--conf', '/home/rongtao/cclinux/tools/dracut/conf.d/01.conf']
dracut args = ['--conf', '/home/rongtao/cclinux/tools/dracut/conf.d/01.conf']
2022-12-27 10:51:01,768: anaconda args = ['--conf', '/home/rongtao/cclinux/tools/dracut/conf.d/01.conf', '--add', 'anaconda pollcdrom qemu qemu-net prefixdevname-tools']
anaconda args = ['--conf', '/home/rongtao/cclinux/tools/dracut/conf.d/01.conf', '--add', 'anaconda pollcdrom qemu qemu-net prefixdevname-tools']
2022-12-27 10:51:01,800: rebuilding boot/initramfs-5.15.67-1.cl9.x86_64.img
rebuilding boot/initramfs-5.15.67-1.cl9.x86_64.img
Traceback (most recent call last):
  File "/sbin/lorax", line 226, in <module>
    main()
  File "/sbin/lorax", line 207, in main
    lorax.run(dnfbase, opts.product, opts.version, opts.release,
  File "/usr/lib/python3.9/site-packages/pylorax/__init__.py", line 358, in run
    treebuilder.rebuild_initrds(add_args=anaconda_args)
  File "/usr/lib/python3.9/site-packages/pylorax/treebuilder.py", line 338, in rebuild_initrds
    dracut.Run(args + [outfile, kernel.version])
  File "/usr/lib/python3.9/site-packages/pylorax/imgutils.py", line 509, in Run
    runcmd(["dracut"] + args, root=self.root)
  File "/usr/lib/python3.9/site-packages/pylorax/executils.py", line 367, in runcmd
    return execWithRedirect(cmd[0], cmd[1:], **kwargs)
  File "/usr/lib/python3.9/site-packages/pylorax/executils.py", line 230, in execWithRedirect
    return _run_program(argv, stdin=stdin, stdout=stdout, root=root, env_prune=env_prune,
  File "/usr/lib/python3.9/site-packages/pylorax/executils.py", line 205, in _run_program
    raise subprocess.CalledProcessError(proc.returncode, argv, output)
subprocess.CalledProcessError: Command '['dracut', '--nomdadmconf', '--nolvmconf', '--conf', '/home/rongtao/cclinux/tools/dracut/conf.d/01.conf', '--add', 'anaconda pollcdrom qemu qemu-net prefixdevname-tools', '--force', 'boot/initramfs-5.15.67-1.cl9.x86_64.img', '5.15.67-1.cl9.x86_64']' returned non-zero exit status 1.
2022-12-27 10:51:01,853: Cleaning up tempdir - /home/rongtao/cclinux/cclinux.out/tmp/lorax.w443f2n7

/home/rongtao/cclinux/tools/dracut/conf.d/01.conf

# dracut config file customized for My Linux OS

stdloglvl=3
sysloglvl=5

# see https://github.com/weldr/lorax.git: src/pylorax/__init__.py
# DRACUT_DEFAULT="--xz --install /.buildstamp --no-early-microcode --add fips"
compress="xz"
install_items+=" /.buildstamp "
early_microcode="no"
add_dracutmodules+=" fips "

# New Arch need ignition module
add_dracutmodules+=" ignition "
@bcl
Copy link
Contributor

bcl commented Jan 9, 2023

Thanks for the report, the right thing to do is to copy it into the chroot somewhere and rewrite the --dracut-conf argument.

@bcl bcl self-assigned this Jan 9, 2023
bcl added a commit to bcl/lorax that referenced this issue Jan 31, 2023
dracut now runs inside a chroot, so the file passed to --dracut-conf
needs to be copied inside and the path rewritten to point to the right
location.

This also includes tests for DracutChroot when the tests are run as
root, without a container, because it uses bind mounts.

Fixes weldr#1296
@bcl bcl closed this as completed in 9e6a37d Feb 8, 2023
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