← Back to team overview

curtin-dev team mailing list archive

[Merge] ~raharper/curtin:fix/tip-flake8 into curtin:master

 

Ryan Harper has proposed merging ~raharper/curtin:fix/tip-flake8 into curtin:master.

Commit message:
Replace 'l' for 'L' to make tip flake8 happy

- Update and renaming tox environment flake8 -> tip-flake8 to reproduce
  flake8 failure on 3.8.0 flake8 release.

LP: #1878236

Requested reviews:
  curtin developers (curtin-dev)
Related bugs:
  Bug #1878236 in curtin: "flake8 >= 3.8.0 emits E741 ambiguous variable name 'l'"
  https://bugs.launchpad.net/curtin/+bug/1878236

For more details, see:
https://code.launchpad.net/~raharper/curtin/+git/curtin/+merge/383810
-- 
Your team curtin developers is requested to review the proposed merge of ~raharper/curtin:fix/tip-flake8 into curtin:master.
diff --git a/curtin/block/__init__.py b/curtin/block/__init__.py
index 35a91c6..4d7f694 100644
--- a/curtin/block/__init__.py
+++ b/curtin/block/__init__.py
@@ -1315,8 +1315,8 @@ def get_supported_filesystems():
     if not os.path.exists(proc_fs):
         raise RuntimeError("Unable to read 'filesystems' from %s" % proc_fs)
 
-    return [l.split('\t')[1].strip()
-            for l in util.load_file(proc_fs).splitlines()]
+    return [L.split('\t')[1].strip()
+            for L in util.load_file(proc_fs).splitlines()]
 
 
 def _discover_get_probert_data():
diff --git a/curtin/block/bcache.py b/curtin/block/bcache.py
index 188b4e0..a8bbf0d 100644
--- a/curtin/block/bcache.py
+++ b/curtin/block/bcache.py
@@ -318,11 +318,11 @@ def validate_bcache_ready(bcache_device, bcache_sys_path):
         LOG.debug("validating bcache caching device '%s' from sys_path"
                   " '%s'", bcache_device, bcache_sys_path)
         # we expect a cacheN symlink to point to bcache_device/bcache
-        sys_path_links = [os.path.join(bcache_sys_path, l)
-                          for l in os.listdir(bcache_sys_path)]
-        cache_links = [l for l in sys_path_links
-                       if os.path.islink(l) and (
-                          os.path.basename(l).startswith('cache'))]
+        sys_path_links = [os.path.join(bcache_sys_path, L)
+                          for L in os.listdir(bcache_sys_path)]
+        cache_links = [L for L in sys_path_links
+                       if os.path.islink(L) and (
+                          os.path.basename(L).startswith('cache'))]
 
         if len(cache_links) == 0:
             msg = ('Failed to find any cache links in %s:%s' % (
diff --git a/curtin/block/lvm.py b/curtin/block/lvm.py
index da29c7b..322febd 100644
--- a/curtin/block/lvm.py
+++ b/curtin/block/lvm.py
@@ -23,7 +23,7 @@ def _filter_lvm_info(lvtool, match_field, query_field, match_key, args=None):
                           '-o', ','.join([match_field, query_field])] + args,
                          capture=True)
     return [qf for (mf, qf) in
-            [l.strip().split(_SEP) for l in out.strip().splitlines()]
+            [L.strip().split(_SEP) for L in out.strip().splitlines()]
             if mf == match_key]
 
 
diff --git a/examples/tests/crashdump.cfg b/examples/tests/crashdump.cfg
new file mode 100644
index 0000000..e010961
--- /dev/null
+++ b/examples/tests/crashdump.cfg
@@ -0,0 +1,19 @@
+_install_crashdump:
+ - &install_crashdump |
+   command -v apt &>/dev/null && {
+       DEBIAN_FRONTEND=noninteractive apt-get -qy install linux-image-generic
+       debconf-set-selections <<< "kexec-tools  kexec-tools/load_kexec  boolean true"
+       debconf-set-selections <<< "kdump-tools  kdump-tools/use_kdname  boolean true"
+       DEBIAN_FRONTEND=noninteractive apt-get -qy install linux-crashdump;
+       mkdir -p /var/lib/kdump
+       # fix up crashdump post-inst to just put all of the modules in
+       sed -i -e 's,MODULES=dep,MODULES=most,' /etc/kernel/postinst.d/kdump-tools
+       kdump-config load
+       kdump-config show
+    }
+    exit 0
+
+
+early_commands:
+  # run before other install commands
+  0000_aaaa_install_crashdump: ['bash', '-c', *install_crashdump]
diff --git a/tests/unittests/test_apt_source.py b/tests/unittests/test_apt_source.py
index 6ae5579..501b846 100644
--- a/tests/unittests/test_apt_source.py
+++ b/tests/unittests/test_apt_source.py
@@ -958,7 +958,7 @@ class TestDebconfSelections(CiTestCase):
         # assumes called with *args value.
         selections = m_set_sel.call_args_list[0][0][0].decode()
 
-        missing = [l for l in lines if l not in selections.splitlines()]
+        missing = [L for L in lines if L not in selections.splitlines()]
         self.assertEqual([], missing)
 
     @mock.patch("curtin.commands.apt_config.dpkg_reconfigure")
diff --git a/tests/unittests/test_block_dasd.py b/tests/unittests/test_block_dasd.py
index 95788b0..3772cc5 100644
--- a/tests/unittests/test_block_dasd.py
+++ b/tests/unittests/test_block_dasd.py
@@ -17,7 +17,7 @@ def random_device_id():
 
 class TestDasdValidDeviceId(CiTestCase):
 
-    nonhex = [l for l in string.ascii_lowercase if l not in
+    nonhex = [L for L in string.ascii_lowercase if L not in
               ['a', 'b', 'c', 'd', 'e', 'f']]
 
     invalids = [None, '', {}, ('', ), 12, '..', CiTestCase.random_string(),
diff --git a/tests/vmtests/__init__.py b/tests/vmtests/__init__.py
index 222adcc..e102b6d 100644
--- a/tests/vmtests/__init__.py
+++ b/tests/vmtests/__init__.py
@@ -601,6 +601,7 @@ class VMBaseClass(TestCase):
     arch_skip = []
     boot_timeout = BOOT_TIMEOUT
     collect_scripts = []
+    crashdump = False
     extra_collect_scripts = []
     conf_file = "examples/tests/basic.yaml"
     nr_cpus = None
@@ -967,6 +968,25 @@ class VMBaseClass(TestCase):
                     for service in ["systemd.mask=snapd.seeded.service",
                                     "systemd.mask=snapd.service"]])
 
+        # We set guest kernel panic=1 to trigger immediate rebooot, combined
+        # with the (xkvm) -no-reboot qemu parameter should prevent vmtests from
+        # wasting time in a soft-lockup loop. Add the params after the '---'
+        # separator to extend the parameters to the target system as well.
+        cmd.extend(["--no-reboot", "--append=panic=-1",
+                    "--append=softlockup_panic=1",
+                    "--append=hung_task_panic=1",
+                    "--append=nmi_watchdog=panic,1"])
+
+        # configure guest with crashdump to capture kernel failures for debug
+        if cls.crashdump:
+            # we need to install a kernel and modules so bump the memory by 2g
+            # for the ephemeral environment to hold it all
+            cls.mem = int(cls.mem) + 2048
+            logger.info(
+                'Enabling linux-crashdump during install, mem += 2048 = %s',
+                cls.mem)
+            cmd.extend(["--append=crashkernel=384M-5000M:192M"])
+
         # getting resolvconf configured is only fixed in bionic
         # the iscsi_auto handles resolvconf setup via call to
         # configure_networking in initramfs
@@ -1353,7 +1373,7 @@ class VMBaseClass(TestCase):
         target_disks.extend([output_disk])
 
         # create xkvm cmd
-        cmd = (["tools/xkvm", "-v", dowait] +
+        cmd = (["tools/xkvm", "-v", dowait, '--no-reboot'] +
                uefi_flags + netdevs +
                cls.mpath_diskargs(target_disks + extra_disks + nvme_disks) +
                ["--disk=file=%s,if=virtio,media=cdrom" % cls.td.seed_disk] +
@@ -2111,6 +2131,7 @@ def check_install_log(install_log, nrchars=200):
     # regexps expected in curtin output
     install_pass = INSTALL_PASS_MSG
     install_fail = "({})".format("|".join([
+                   'INFO:.* blocked for more than.*seconds.',
                    'Installation failed',
                    'ImportError: No module named.*',
                    'Out of memory:',
diff --git a/tests/vmtests/test_fs_battery.py b/tests/vmtests/test_fs_battery.py
index ecd1729..067e91b 100644
--- a/tests/vmtests/test_fs_battery.py
+++ b/tests/vmtests/test_fs_battery.py
@@ -165,7 +165,7 @@ class TestFsBattery(VMBaseClass):
             "/etc /my/bind-ro-etc none bind,ro 0 0".split(),
         ]
         fstab_found = [
-            l.split() for l in self.load_collect_file("fstab").splitlines()]
+            L.split() for L in self.load_collect_file("fstab").splitlines()]
         self.assertEqual(expected, [e for e in expected if e in fstab_found])
 
     def test_mountinfo_has_mounts(self):
diff --git a/tests/vmtests/test_network.py b/tests/vmtests/test_network.py
index 601cad4..2657fdd 100644
--- a/tests/vmtests/test_network.py
+++ b/tests/vmtests/test_network.py
@@ -108,7 +108,7 @@ class TestNetworkBaseTestsAbs(VMBaseClass):
 
         eni_lines = eni.split('\n') + eni_cfg.split('\n')
         print("\n".join(eni_lines))
-        for line in [l for l in expected_eni.split('\n') if len(l) > 0]:
+        for line in [L for L in expected_eni.split('\n') if len(L) > 0]:
             if line.startswith("#"):
                 continue
             if "hwaddress ether" in line:
diff --git a/tools/launch b/tools/launch
index db18c80..b49dd76 100755
--- a/tools/launch
+++ b/tools/launch
@@ -50,6 +50,7 @@ Usage: ${0##*/} [ options ] curtin install [args]
            --serial-log F  : log to F (default 'serial.log')
            --root-arg X pass 'X' through as the root= param when booting a
                         kernel.  default: $DEFAULT_ROOT_PARAM
+           --no-reboot  Pass '-no-reboot' through to QEMU
       -v | --verbose    be more verbose
            --no-install-deps  do not install insert '--install-deps'
                               on curtin command invocations
@@ -408,7 +409,7 @@ get_img_fmt() {
 
 main() {
     local short_opts="a:A:d:h:i:k:n:p:s:v"
-    long_opts="add:,append:,arch:,bios:,boot-image:,disk:,dowait,help,initrd:,kernel:,mem:,netdev:,no-dowait,no-proxy-config,power:,publish:,root-arg:,silent,serial-log:,smp:,uefi-nvram:,verbose,vnc:"
+    long_opts="add:,append:,arch:,bios:,boot-image:,disk:,dowait,help,initrd:,kernel:,mem:,netdev:,no-dowait,no-proxy-config,no-reboot,power:,publish:,root-arg:,silent,serial-log:,smp:,uefi-nvram:,verbose,vnc:"
     local getopt_out=""
     getopt_out=$(getopt --name "${0##*/}" \
         --options "${short_opts}" --long "${long_opts}" -- "$@") &&
@@ -461,6 +462,7 @@ main() {
                --no-dowait) pt[${#pt[@]}]="$cur"; dowait=false;;
                --no-install-deps) install_deps="";;
                --no-proxy-config) proxy_config=false;;
+               --no-reboot) pt[${#pt[@]}]="--no-reboot";;
                --power)
                 case "$next" in
                     off) pstate="poweroff";;
diff --git a/tools/xkvm b/tools/xkvm
index 4bb4343..02b9f62 100755
--- a/tools/xkvm
+++ b/tools/xkvm
@@ -339,7 +339,7 @@ get_bios_opts() {
 
 main() {
     local short_opts="hd:n:v"
-    local long_opts="bios:,help,dowait,disk:,dry-run,kvm:,no-dowait,netdev:,uefi,uefi-nvram:,verbose"
+    local long_opts="bios:,help,dowait,disk:,dry-run,kvm:,no-dowait,no-reboot,netdev:,uefi,uefi-nvram:,verbose"
     local getopt_out=""
     getopt_out=$(getopt --name "${0##*/}" \
         --options "${short_opts}" --long "${long_opts}" -- "$@") &&
@@ -371,6 +371,7 @@ main() {
     #  We default to dowait=false if input and output are a terminal
     local dowait=""
     [ -t 0 -a -t 1 ] && dowait=false || dowait=true
+    local noreboot=false
     while [ $# -ne 0 ]; do
         cur=${1}; next=${2};
         case "$cur" in
@@ -384,6 +385,7 @@ main() {
             -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));;
             --dowait) dowait=true;;
             --no-dowait) dowait=false;;
+            --no-reboot) noreboot=true;;
             --bios) bios="$next"; shift;;
             --uefi) uefi=true;;
             --uefi-nvram) uefi=true; uefi_nvram="$next"; shift;;
@@ -683,6 +685,10 @@ main() {
     local rng_devices
     rng_devices=( -object "rng-random,filename=/dev/urandom,id=objrng0"
                   -device "$virtio_rng_device,rng=objrng0,id=rng0" )
+    local reboot_arg
+    if $noreboot; then
+        kvmcmd=( "${kvmcmd[@]}" -no-reboot )
+    fi
     cmd=( "${kvmcmd[@]}" "${archopts[@]}"
           "${bios_opts[@]}"
           "${bus_devices[@]}"
diff --git a/tox.ini b/tox.ini
index 6efc3f9..063477a 100644
--- a/tox.ini
+++ b/tox.ini
@@ -144,6 +144,7 @@ deps = pycodestyle
 commands = {envpython} -m pyflakes {posargs:curtin/ tests/ tools/}
 deps = pyflakes
 
-[flake8]
-builtins = _
+[testenv:tip-flake8]
 exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build
+deps = flake8
+commands = {envpython} -m flake8 {posargs:curtin/ tests/ tools/}

Follow ups