Repository: openvstorage/framework

Issue:
multiple diskpartitions with same mountpoint & wrong offsets after updating the cluster
After upgrading OVH from `fargo 2.7.3` to `2.7.5` we saw strange behavior when checking the storagerouters.
All disks with a role on them were missing.
After some digging we saw the following problems: (multiple partitions with `/mnt/ssd1`, `aliasses` & `size`)
```
{
    "roles": [], 
    "aliases": [
        "/dev/disk/by-path/pci-0000:03:00.0-sas-0x4433221103000000-lun-0-part1", 
        "/dev/disk/by-id/wwn-0x55cd2e404b747acb-part1", 
        "/dev/disk/by-id/ata-INTEL_SSDSC2BB800H4_BTWH451302C2800CGN-part1"
    ], 
    "filesystem": "linux_raid_member", 
    "disk_guid": "14d70ad3-4a47-4544-b4b3-a702ae7adfbf", 
    "state": "OK", 
    "offset": 16777216, 
    "usage": [], 
    "mountpoint": null, 
    "folder": null, 
    "guid": "0fb6e087-a77e-4e6b-9df4-46251c5dc01d", 
    "size": 83885031424
}
{
    "roles": [
        "DB"
    ], 
    "aliases": [
        "/dev/disk/by-path/pci-0000:03:00.0-sas-0x4433221103000000-lun-0-part3", 
        "/dev/disk/by-id/wwn-0x55cd2e404b747acb-part3", 
        "/dev/disk/by-id/ata-INTEL_SSDSC2BB800H4_BTWH451302C2800CGN-part3"
    ], 
    "filesystem": "ext4", 
    "disk_guid": "14d70ad3-4a47-4544-b4b3-a702ae7adfbf", 
    "state": "MISSING", 
    "offset": 104857600000, 
    "usage": [], 
    "mountpoint": "/mnt/ssd1", 
    "folder": "/mnt/ssd1", 
    "guid": "37fbd5bb-19d6-4bea-aba5-c16f5218f1ce", 
    "size": 695307599872
}
{
    "roles": [], 
    "aliases": [
        "/dev/disk/by-path/pci-0000:03:00.0-sas-0x4433221103000000-lun-0-part3", 
        "/dev/disk/by-id/wwn-0x55cd2e404b747acb-part3", 
        "/dev/disk/by-id/ata-INTEL_SSDSC2BB800H4_BTWH451302C2800CGN-part3"
    ], 
    "filesystem": "ext4", 
    "disk_guid": "14d70ad3-4a47-4544-b4b3-a702ae7adfbf", 
    "state": "OK", 
    "offset": 838860800000, 
    "usage": [], 
    "mountpoint": "/mnt/ssd1", 
    "folder": "/mnt/ssd1", 
    "guid": "91e3f51c-6e2e-42ff-a63e-790cfa81972f", 
    "size": 695307599872
}
{
    "roles": [], 
    "aliases": [
        "/dev/disk/by-label/swap-sda2", 
        "/dev/disk/by-path/pci-0000:03:00.0-sas-0x4433221103000000-lun-0-part2", 
        "/dev/disk/by-id/wwn-0x55cd2e404b747acb-part2", 
        "/dev/disk/by-id/ata-INTEL_SSDSC2BB800H4_BTWH451302C2800CGN-part2"
    ], 
    "filesystem": "swap", 
    "disk_guid": "14d70ad3-4a47-4544-b4b3-a702ae7adfbf", 
    "state": "OK", 
    "offset": 671097028608, 
    "usage": [], 
    "mountpoint": "[SWAP]", 
    "folder": "[SWAP]", 
    "guid": "c052edcc-0cf1-4c35-bb01-4945680340e0", 
    "size": 20970471424
}
```

The **second thing** we noticed was that the offset of the model did not match reality.

The registered offsets in the model are: `[16777216, 671097028608, 838860800000]`
But if we check in reality they are:`2097152B, 83887128576B, 104857600000B`

Apparently the offsets are currently acquired through: `PHY-SEC(lsblk) * /sys/block/sda/sda3/start`
This calculation resulted in the wrong offset being used. After looking further it should be: `/sys/block/sda/sda3/start * LOG-SEC(lsblk)`

**EDIT:** After applying this on all nodes, redoing the `sync_with_reality`, all the missing disks were gone.

**EDIT2:** After some research why it always worked and now it doesn't anymore, we discovered this:
* On our CI testing environment:
```
root@ovs-node01-1604:~# lsblk --output=KNAME,PHY-SEC
KNAME PHY-SEC
sda       512
sda1      512
sdb       512
sdb1      512
sdc       512
sdc1      512
sdd       512
sde       512

root@ovs-node01-1604:~# lsblk --output=KNAME,LOG-SEC
KNAME LOG-SEC
sda       512
sda1      512
sdb       512
sdb1      512
sdc       512
sdc1      512
sdd       512
sde       512
```

* While on the OVH environment:
```
root@ctrl-roub-01:~# lsblk --output=KNAME,LOG-SEC
KNAME LOG-SEC
sda       512
sda1      512
md1       512
sda2      512
sda3      512
sdb       512
sdb1      512
md1       512
sdb2      512
root@ctrl-roub-01:~# lsblk --output=KNAME,PHY-SEC
KNAME PHY-SEC
sda      4096
sda1     4096
md1      4096
sda2     4096
sda3     4096
sdb      4096
sdb1     4096
md1      4096
sdb2     4096
```


Discussion:

Resolving patch:
diff --git a/ovs/lib/disk.py b/ovs/lib/disk.py
--- a/ovs/lib/disk.py
+++ b/ovs/lib/disk.py
@@ -81,8 +81,8 @@ def sync_with_reality(storagerouter_guid):
                               '--noheadings',
                               '--exclude',
                               '1,2,11',
-                              '--output=KNAME,SIZE,MODEL,STATE,MAJ:MIN,FSTYPE,TYPE,ROTA,MOUNTPOINT,PHY-SEC']).splitlines()
-        device_regex = re.compile('^KNAME="(?P<name>.*)" SIZE="(?P<size>\d*)" MODEL="(?P<model>.*)" STATE="(?P<state>.*)" MAJ:MIN="(?P<dev_nr>.*)" FSTYPE="(?P<fstype>.*)" TYPE="(?P<type>.*)" ROTA="(?P<rota>[0,1])" MOUNTPOINT="(?P<mtpt>.*)" PHY-SEC="(?P<sector_size>\d*)"$')
+                              '--output=KNAME,SIZE,MODEL,STATE,MAJ:MIN,FSTYPE,TYPE,ROTA,MOUNTPOINT,LOG-SEC']).splitlines()
+        device_regex = re.compile('^KNAME="(?P<name>.*)" SIZE="(?P<size>\d*)" MODEL="(?P<model>.*)" STATE="(?P<state>.*)" MAJ:MIN="(?P<dev_nr>.*)" FSTYPE="(?P<fstype>.*)" TYPE="(?P<type>.*)" ROTA="(?P<rota>[0,1])" MOUNTPOINT="(?P<mtpt>.*)" LOG-SEC="(?P<sector_size>\d*)"$')
         configuration = {}
         parsed_devices = []
         for device in devices:


Test patch: