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

lctl get_param -n -y prints the name of a multi-line parameter

XMLWordPrintable

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

      Problem

      lctl get_param -n -y prints the parameter name for a multi-line value. The -n option must print only the value. For a single-line value, -n -y prints only the value, as expected.

      Environment

      Reproduction

      1. On the MGS, create a nodemap with 2 idmaps: lctl nodemap_add c0, then lctl nodemap_add_idmap --name c0 --idtype uid --idmap 1003:11000 and lctl nodemap_add_idmap --name c0 --idtype gid --idmap 1003:11000.
      2. Run lctl get_param -n -y nodemap.c0.idmap.

      Expected output is the value only:

      [
       { idtype: uid, client_id: 1003, fs_id: 11000 },
       { idtype: gid, client_id: 1003, fs_id: 11000 }
      ]
      

      Actual output starts with the name:

      nodemap.c0.idmap: [
       { idtype: uid, client_id: 1003, fs_id: 11000 },
       { idtype: gid, client_id: 1003, fs_id: 11000 }
      ]
      

      This result comes from a source review. We did not run the reproduction.

      Analysis

      In print_param_internal() in lustre/utils/lustre_param.c, the multi-line branch runs when po_yaml or po_header is set. That branch prints lpf_name on the first line and does not check po_show_name. The single-line branch (the else branch) prints the name only when po_show_name is set.

      Before 5768bf35fd, only po_header selected the multi-line branch. A -n -y request went to the single-line branch, so it printed only the value.

      The AI review of https://review.whamcloud.com/69687 found this defect. 69687 indents the lines of a multi-line value for -y, so with -n the output now also has the indent.

      Proposed fix

      In the multi-line branch, print the name and the separator only when po_show_name is set. When po_show_name is clear, print the value without the name and without the extra indent. Add a -n -y case for a multi-line parameter to sanity-sec test_25c.

            wc-triage WC Triage
            hornc Chris Horn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: