New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a check function for the EBS resource. #877
Conversation
nixops/resources/ebs_volume.py
Outdated
def check(self): | ||
volume = nixops.ec2_utils.get_volume_by_id(self.connect(self.region), self.volume_id) | ||
if volume is None: | ||
self.state = self.MISSING |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably need a warning that the volume is no longer available here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the disks check doesn't include notes like the machine one. But after updating the volume state, the check table show it as missing
Machines state:
+---------+--------+-----+-----------+----------+----------------+----------------------------------------+------------------------------------------------------------+
| Name | Exists | Up | Reachable | Disks OK | Load avg. | Units | Notes |
+---------+--------+-----+-----------+----------+----------------+----------------------------------------+------------------------------------------------------------+
| machine | Yes | Yes | Yes | No | 0.00 0.00 0.00 | proc-sys-fs-binfmt_misc.mount [failed] | volume ‘vol-096cbe0647ee88eae’ not attached to ‘/dev/xvdf’ |
| | | | | | | | volume ‘vol-096cbe0647ee88eae’ no longer exists |
+---------+--------+-----+-----------+----------+----------------+----------------------------------------+------------------------------------------------------------+
Non machines resources state:
+--------------------+--------+
| Name | Exists |
+--------------------+--------+
| data_volume | No |
| my-key-pair | Yes |
| ssh-security-group | Yes |
+--------------------+--------+
The only thing that I can add is a message like this
data_volume.......> Volume VOLUME_ID is missing!
Before the check tables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, yeah seems the existent warnings are fine already.
nixops/resources/ebs_volume.py
Outdated
@@ -141,6 +141,10 @@ def create(self, defn, check, allow_reboot, allow_recreate): | |||
states=['available', 'in-use']) | |||
self.state = self.UP | |||
|
|||
def check(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm isn't the method name _check ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nevermind, checked again, this should work as well.
nixops/backends/ec2.py
Outdated
@@ -506,6 +506,8 @@ def create_after(self, resources, defn): | |||
|
|||
def attach_volume(self, device, volume_id): | |||
volume = nixops.ec2_utils.get_volume_by_id(self.connect(), volume_id) | |||
if not volume: | |||
raise Exception("volume {0} doesn't exist".format(volume_id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can suggest running nixops check
here to reconcile the state with the real-world state.
Ping @rbvermaa |
If missing the volume will be marked as such, after a check
operation. Also show more meaningful error message when a volume
disappear. This fix #876.