Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-21059

tests: stack_trap in a test chains the script EXIT trap

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Medium Medium
    • None
    • None
    • None
    • 3
    • 9223372036854775807

      Problem

      A stack_trap ... EXIT call in a test also runs the EXIT trap of the test script when the test ends. The script trap then runs once for each test that calls stack_trap, and again when the script exits.

      In sanity-lnet.sh, the script trap is cleanup_testsuite. If the suite starts with Lustre mounted, restore_mounts is true, and cleanup_testsuite calls setupall in the middle of the suite. The later tests then find Lustre mounted and fail. For this reason, no sanity-lnet test uses stack_trap today.

      Environment

      • master at 2.17.60
      • bash 5.1.8 (EL9) and bash 5.3. Bash 3.2 does not show the problem.

      Reproduction

      1. Mount Lustre.
      2. Add a sanity-lnet test that calls stack_trap "echo cleanup" EXIT and prints trap -p EXIT.
      3. Run the test with ONLY.

      The test prints:

      trap -- 'echo test_30 cleanup; cleanup_testsuite' EXIT
      

      After the test, the log shows "Starting client" from setupall.

      Analysis

      run_one_logged runs each test in a subshell. The subshell does not run the EXIT trap of the script. But trap -p in the subshell still prints that trap. stack_trap reads the trap -p output and adds the script trap to the test trap.

      Other suites with a script-level EXIT trap have the same problem:

      • large-lun.sh sets trap cleanupall EXIT. test_2 and test_5 call stack_trap, so each of them runs cleanupall when it ends.
      • sanity-ec.sh sets stack_trap "unset LFS_EC_OK" EXIT. Each sanity-ec test that calls stack_trap runs that command again. The effect is harmless.

      sanity.sh sets no script-level EXIT trap, so sanity.sh does not show the problem.

      Proposed fix

      Clear the EXIT trap at the start of run_one with trap - EXIT. Add a sanity-lnet test that checks that a test EXIT trap holds only the test commands.

            hornc Chris Horn
            hornc Chris Horn
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: