Skip to content

Commit 94265b4

Browse files
committed
volumes: treat non-aliased devices as equivalent to aliased ones
The AWS API provides us with some non-sensical device names that might have nothing to do with reality. For some reason there is weird renaming going on from the values that boto3 (the AWS API bindings) returns to us to what we actually configure on the machine. Apparently nowadays some volumes are not properly being mapped from AWS to NixOps. Amazon doesn't appear to give much of a guarantee (or any) in terms of device names. Accepting the "real" device name instead of the mapped device name gets rid of issue #105. In an ideal world Amazon would be providing WWUIDs, device paths or some other attribute that they can define with the block device. Since that doesn't (seem to) exist we must live with this change until someone comes up with a better solution.
1 parent 76f65a2 commit 94265b4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

nixops_aws/backends/ec2.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,10 +1551,12 @@ def create( # noqa: C901
15511551

15521552
# Detect if volumes were manually detached. If so, reattach
15531553
# them.
1554+
mapped_devices = self._get_instance().block_device_mapping.keys()
1555+
15541556
for device_stored, v in self.block_device_mapping.items():
15551557
if (
1556-
device_name_to_boto_expected(device_stored)
1557-
not in self._get_instance().block_device_mapping.keys()
1558+
device_name_to_boto_expected(device_stored) not in mapped_devices
1559+
and device_stored not in mapped_devices
15581560
and not v.get("needsAttach", False)
15591561
and v.get("volumeId", None)
15601562
):
@@ -2041,8 +2043,12 @@ def _check(self, res):
20412043
device_real
20422044
) # boto expects only sd names
20432045

2044-
if device_that_boto_expects not in instance.block_device_mapping.keys() and v.get(
2045-
"volumeId", None
2046+
mapped_devices = instance.block_device_mapping.keys()
2047+
2048+
if (
2049+
device_that_boto_expects not in mapped_devices
2050+
and device_real not in mapped_devices
2051+
and v.get("volumeId", None)
20462052
):
20472053
res.disks_ok = False
20482054
res.messages.append(

0 commit comments

Comments
 (0)