Skip to content

Commit

Permalink
WIP id device path resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonskie committed Dec 12, 2024
1 parent f0f0911 commit a1c4651
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 0 deletions.
165 changes: 165 additions & 0 deletions TEST.Md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
ideas so far
- best is to use disk-uuid instead of disk-id but this is not currently provided by in the metadata no idea how we can get those
- strip the disk-id of all prefixes for example `google-disk-8df5ef90-4132-4314-7ee3-e4224adf27cb` will be `8df5ef90-4132-4314-7ee3-e4224adf27cb`
and we can then set the prefixes in the stemcell. (least ammount of work and backwards compatible. but still looks like ducktape)

IDS are coming from `/var/vcap/bosh/persistent_disk_hints.json`

# IAAS

## GCP:
contents of `persistent_disk_hints.json`
```
{
"disk-69e53b13-76b3-4400-4437-633782a5cbb5": {
"ID": "disk-69e53b13-76b3-4400-4437-633782a5cbb5",
"DeviceID": "",
"VolumeID": "/dev/sdb",
"Lun": "",
"HostDeviceID": "",
"Path": "/dev/sdb",
"ISCSISettings": {
"InitiatorName": "",
"Username": "",
"Target": "",
"Password": ""
},
"FileSystemType": "",
"MountOptions": null,
"Partitioner": ""
}
}
```

files listed in /dev/disk/by-id
```
google-disk-69e53b13-76b3-4400-4437-633782a5cbb5
google-disk-69e53b13-76b3-4400-4437-633782a5cbb5-part1
google-persistent-disk-0
google-persistent-disk-0-part1
google-persistent-disk-0-part2
google-persistent-disk-0-part3
google-persistent-disk-0-part4
scsi-0Google_PersistentDisk_disk-69e53b13-76b3-4400-4437-633782a5cbb5
scsi-0Google_PersistentDisk_disk-69e53b13-76b3-4400-4437-633782a5cbb5-part1
scsi-0Google_PersistentDisk_persistent-disk-0
scsi-0Google_PersistentDisk_persistent-disk-0-part1
scsi-0Google_PersistentDisk_persistent-disk-0-part2
scsi-0Google_PersistentDisk_persistent-disk-0-part3
scsi-0Google_PersistentDisk_persistent-disk-0-part4
```

## OpenStack:
contents of `persistent_disk_hints.json`
```
{
"05c185c6-e8a3-4216-ab30-1f5cf7d17f0d": {
"ID": "05c185c6-e8a3-4216-ab30-1f5cf7d17f0d",
"DeviceID": "",
"VolumeID": "/dev/sdb",
"Lun": "",
"HostDeviceID": "",
"Path": "/dev/sdb",
"ISCSISettings": {
"InitiatorName": "",
"Username": "",
"Target": "",
"Password": ""
},
"FileSystemType": "",
"MountOptions": null,
"Partitioner": ""
}
}
```

files listed in /dev/disk/by-id
```
scsi-305c185c6e8a34216ab301f5cf7d17f0d
scsi-305c185c6e8a34216ab301f5cf7d17f0d-part1
scsi-36000c295e04c2c9a4b447d59632b887b
scsi-36000c295e04c2c9a4b447d59632b887b-part1
scsi-36000c295e04c2c9a4b447d59632b887b-part2
scsi-36000c295e04c2c9a4b447d59632b887b-part3
wwn-0x05c185c6e8a34216ab301f5cf7d17f0d
wwn-0x05c185c6e8a34216ab301f5cf7d17f0d-part1
wwn-0x6000c295e04c2c9a4b447d59632b887b
wwn-0x6000c295e04c2c9a4b447d59632b887b-part1
wwn-0x6000c295e04c2c9a4b447d59632b887b-part2
wwn-0x6000c295e04c2c9a4b447d59632b887b-part3
```

## Azure:
contents of `persistent_disk_hints.json`
```
{
"caching:None;disk_name:bosh-disk-data-65216cfc-56cf-4c6d-86d8-92db25f7c555;resource_group_name:rg-bosh-lod-29": {
"ID": "caching:None;disk_name:bosh-disk-data-65216cfc-56cf-4c6d-86d8-92db25f7c555;resource_group_name:rg-bosh-lod-29",
"DeviceID": "",
"VolumeID": "",
"Lun": "1",
"HostDeviceID": "{f8b3781b-1e82-4818-a1c3-63d806ec15bb}",
"Path": "",
"ISCSISettings": {
"InitiatorName": "",
"Username": "",
"Target": "",
"Password": ""
},
"FileSystemType": "",
"MountOptions": null,
"Partitioner": ""
}
}
```
files listed in /dev/disk/by-id
```
scsi-3600224802f9637138f32cc2d44e8c34e
scsi-3600224802f9637138f32cc2d44e8c34e-part1
scsi-3600224802f9637138f32cc2d44e8c34e-part2
scsi-3600224803c4aeae9430e9c897b3979d7
scsi-3600224803c4aeae9430e9c897b3979d7-part1
scsi-3600224804c5eb34c6e0c024d5289763d
scsi-3600224804c5eb34c6e0c024d5289763d-part1
wwn-0x600224802f9637138f32cc2d44e8c34e
wwn-0x600224802f9637138f32cc2d44e8c34e-part1
wwn-0x600224802f9637138f32cc2d44e8c34e-part2
wwn-0x600224803c4aeae9430e9c897b3979d7
wwn-0x600224803c4aeae9430e9c897b3979d7-part1
wwn-0x600224804c5eb34c6e0c024d5289763d
wwn-0x600224804c5eb34c6e0c024d5289763d-part1
```

## AliCloud:
contents of `persistent_disk_hints.json`
```
{
"d-gw8ibkvqdrmdqzwpo4rk": {
"ID": "d-gw8ibkvqdrmdqzwpo4rk",
"DeviceID": "",
"VolumeID": "/dev/disk/by-id/virtio-gw8ibkvqdrmdqzwpo4rk",
"Lun": "",
"HostDeviceID": "",
"Path": "/dev/disk/by-id/virtio-gw8ibkvqdrmdqzwpo4rk",
"ISCSISettings": {
"InitiatorName": "",
"Username": "",
"Target": "",
"Password": ""
},
"FileSystemType": "",
"MountOptions": null,
"Partitioner": ""
}
}
```
files listed in /dev/disk/by-id
```
virtio-gw8a1q0dqyqmcjrnetpj
virtio-gw8a1q0dqyqmcjrnetpj-part1
virtio-gw8a1q0dqyqmcjrnetpj-part2
virtio-gw8au7up14j66ge6u4vs
virtio-gw8au7up14j66ge6u4vs-part1
virtio-gw8ibkvqdrmdqzwpo4rk
virtio-gw8ibkvqdrmdqzwpo4rk-part1
```
13 changes: 13 additions & 0 deletions infrastructure/devicepathresolver/id_device_path_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ func (idpr *idDevicePathResolver) GetRealDevicePath(diskSettings boshsettings.Di
}

func (idpr *idDevicePathResolver) stripVolumeIfRequired(diskID string) (string, error) {
fmt.Println("DEBUG: stripVolumeRegex called with diskID:", diskID)
if idpr.stripVolumeRegex == "" {
fmt.Println("DEBUG: stripVolumeRegex is empty, returning diskID as is")
return diskID, nil
}

Expand All @@ -111,5 +113,16 @@ func (idpr *idDevicePathResolver) stripVolumeIfRequired(diskID string) (string,
return "", bosherr.WrapError(err, "Compiling stripVolumeRegex")
}
}

// Ugly ducktape code to strip diskID from all the prefixes so we can later re-add them from agent.json
re := regexp.MustCompile(`^[^-]+-([0-9a-fA-F-]+)$`)
matches := re.FindStringSubmatch(diskID)
fmt.Println("DEBUG: all matches found:", matches)
if len(matches) > 1 {
fmt.Println("DEBUG: matches found:", idpr.stripVolumeRegex+matches[1])
strippedDiskID := matches[1]
return idpr.stripVolumeRegex + strippedDiskID, nil
}
fmt.Println("DEBUG: no matches found, returning diskID as is")
return idpr.stripVolumeCompiled.ReplaceAllLiteralString(diskID, ""), nil
}

0 comments on commit a1c4651

Please sign in to comment.