truenas / py-libzfs

Python libzfs bindings
GNU Lesser General Public License v3.0
81 stars 24 forks source link

NAS-127511 / 24.10 / Retrieve path properly when spare is INUSE #276

Closed Qubad786 closed 1 month ago

Qubad786 commented 3 months ago

Problem

When we had a disk replaced by spare in a pool i.e

config:

    NAME                                        STATE     READ WRITE CKSUM
    testspare                                   ONLINE       0     0     0
      mirror-0                                  ONLINE       0     0     0
        spare-0                                 ONLINE       0     0     0
          9d92cdac-f627-446c-8ace-169b6dec27a0  ONLINE       0     0     0
          f7c8e925-6ede-4331-8fd3-ee70570772e0  ONLINE       0     0     0
        1eb6a232-9a25-4867-80bb-ffd1b0797891    ONLINE       0     0     0
      mirror-1                                  ONLINE       0     0     0
        474f99c6-a0d4-491f-8440-9c5761018b4d    ONLINE       0     0     0
        dca2f116-a998-4b2d-92d5-4389837cc8c8    ONLINE       0     0     0
    special
      58d6865e-664f-456c-a6bb-391e53e014d8      ONLINE       0     0     0
    logs
      790817f9-9e27-4576-8b99-093b8d792962      ONLINE       0     0     0
    cache
      a6f48d2e-256c-4eba-a451-e4b6bb147eee      ONLINE       0     0     0
    spares
      f7c8e925-6ede-4331-8fd3-ee70570772e0      INUSE     currently in use
      4d982589-03a3-4ae3-934a-8386a49a891c      AVAIL
      4a5ab019-d9b4-4ebe-ae54-c5d73911b4fc      AVAIL
      46f25d7f-9759-49fd-99b2-7210bfb5602b      AVAIL
      34ecb450-8aea-4e04-92d8-71845bc4e21b      AVAIL

errors: No known data errors

We were not showing the path for spare properly when retrieving information via zfs.pool.get_instance i.e

      {
        "name": "mirror-0",
        "type": "mirror",
        "path": null,
        "guid": "5026909711149930182",
        "status": "ONLINE",
        "stats": {
          "timestamp": 106300558268,
          "read_errors": 0,
          "write_errors": 0,
          "checksum_errors": 0,
          "ops": [
            0,
            13,
            177,
            0,
            0,
            0,
            0
          ],
          "bytes": [
            0,
            532480,
            8527872,
            0,
            0,
            0,
            0
          ],
          "size": 20937965568,
          "allocated": 0,
          "fragmentation": 0,
          "self_healed": 0,
          "configured_ashift": 12,
          "logical_ashift": 12,
          "physical_ashift": 9
        },
        "children": [
          {
            "name": "spare-0",
            "type": "spare",
            "path": null,
            "guid": "6196847144877069196",
            "status": "ONLINE",

Solution

Make sure we properly report the spare path which is actually being consumed when we retrieve information for a pool which has spares being used.

  "groups": {
    "data": [
      {
        "name": "mirror-0",
        "type": "mirror",
        "path": null,
        "guid": "5026909711149930182",
        "status": "ONLINE",
        "stats": {
          "timestamp": 1793844765986,
          "read_errors": 0,
          "write_errors": 0,
          "checksum_errors": 0,
          "ops": [
            0,
            13,
            177,
            0,
            0,
            0,
            0
          ],
          "bytes": [
            0,
            532480,
            8527872,
            0,
            0,
            0,
            0
          ],
          "size": 20937965568,
          "allocated": 0,
          "fragmentation": 0,
          "self_healed": 0,
          "configured_ashift": 12,
          "logical_ashift": 12,
          "physical_ashift": 9
        },
        "children": [
          {
            "name": "spare-0",
            "type": "spare",
            "path": "/dev/disk/by-partuuid/f7c8e925-6ede-4331-8fd3-ee70570772e0",
            "guid": "6196847144877069196",
            "status": "ONLINE",
            "stats": {
bugclerk commented 3 months ago

Jira URL: https://ixsystems.atlassian.net/browse/NAS-127511