-
Notifications
You must be signed in to change notification settings - Fork 6
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
Disabled field in compute host #97
Disabled field in compute host #97
Conversation
This can be used by admins to specify that a host is disabled for maintainance and that marks that blazar monitor should not touch or alter this host's health while it is disabled (True). THis helps admins to create a lease on the host while it is non reservable and host monitor not changing the status back to reservble - True
…en host is non reservable When disabled key is present in extra capabilities handle it by setting it or unsetting it based on the value for the key When disabled field is set to True for a host, the host also changes its reservable status to False. Disabled key can only be set by an admin An admin can create a lease on a host that is non reservable
Fix tests that call matching hosts as users, so is_admin should return False New tests for updating disabled field new test for setting reservable True by monitor when disabled is True / False
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.
This change is great! Just a few minor comments. Did you test this via CLI? How exactly is that being used? I think right now the way the cli works you'd need --extra disabled=true/false
op.alter_column('devices', 'device_driver', | ||
existing_type=mysql.ENUM('zun', 'k3s'), | ||
nullable=False) | ||
op.drop_column('network_reservations', 'vfc_resources') |
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 think this got autogenerated for some reason? Can you remove it?
# only admin can set/unset 'disabled' flag | ||
if self._is_admin(): | ||
host_details = self.get_computehost(host_id) | ||
new_disabled_flag = False if value is None else True |
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.
Should this not be False if value is None else value
?
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.
The value
is parsed as a string. As there is no schema or exact string the user can use (they can use 'true', 'True', 'T', or any string for that matter). The only thing matters is set
or unset
while the set needs a keykey-value pair, but unset needs only the key with value of None
. So as long as set
is called with some value this will work.
I am not sure about the proper way this can be documented.
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.
Can you share the commands you were using?
LOG.warn('%s recovered.', | ||
recovered_hosts[0]['hypervisor_hostname']) | ||
|
||
return reservation_flags | ||
|
||
def set_reservable(self, resource, is_reservable): | ||
if resource.get('disabled', False): | ||
LOG.warn(f"{resource['hypervisor_hostname']} is disabled - cannot set reservable") |
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 would set this to LOG.debug
, as it will print every time the monitor runs in most cases.
addressing PR comments change log warn to log debug if a host is disabled and admin is trying to set host reservable
This reverts commit 55d79b4.
This reverts commit 55d79b4.
* Add disabled field in ComputeHost model This can be used by admins to specify that a host is disabled for maintainance and that marks that blazar monitor should not touch or alter this host's health while it is disabled (True). THis helps admins to create a lease on the host while it is non reservable and host monitor not changing the status back to reservble - True * 'disabled' field to use in host plugin and admins can create lease when host is non reservable When disabled key is present in extra capabilities handle it by setting it or unsetting it based on the value for the key When disabled field is set to True for a host, the host also changes its reservable status to False. Disabled key can only be set by an admin An admin can create a lease on a host that is non reservable * Add disabled flag alembic migration file * Use the policy.enforce to check if the blazar context is a an admin from keystone * notification callback to use set_reservable method Fix tests that call matching hosts as users, so is_admin should return False New tests for updating disabled field new test for setting reservable True by monitor when disabled is True / False * Remove line in migration auto generated by alembic addressing PR comments change log warn to log debug if a host is disabled and admin is trying to set host reservable
…#100) * Revert "Disabled field in compute host (#97)" This reverts commit 55d79b4. * Disabled field in compute host (#97) * Add disabled field in ComputeHost model This can be used by admins to specify that a host is disabled for maintainance and that marks that blazar monitor should not touch or alter this host's health while it is disabled (True). THis helps admins to create a lease on the host while it is non reservable and host monitor not changing the status back to reservble - True * 'disabled' field to use in host plugin and admins can create lease when host is non reservable When disabled key is present in extra capabilities handle it by setting it or unsetting it based on the value for the key When disabled field is set to True for a host, the host also changes its reservable status to False. Disabled key can only be set by an admin An admin can create a lease on a host that is non reservable * Add disabled flag alembic migration file * Use the policy.enforce to check if the blazar context is a an admin from keystone * notification callback to use set_reservable method Fix tests that call matching hosts as users, so is_admin should return False New tests for updating disabled field new test for setting reservable True by monitor when disabled is True / False * Remove line in migration auto generated by alembic addressing PR comments change log warn to log debug if a host is disabled and admin is trying to set host reservable * Fix the error when monitor calls _is_admin with context not available Catch the runtime error and return False as the monitor will not have a context and it needs to relocate the host which is reservable - so return false
* Add disabled field in ComputeHost model This can be used by admins to specify that a host is disabled for maintainance and that marks that blazar monitor should not touch or alter this host's health while it is disabled (True). THis helps admins to create a lease on the host while it is non reservable and host monitor not changing the status back to reservble - True * 'disabled' field to use in host plugin and admins can create lease when host is non reservable When disabled key is present in extra capabilities handle it by setting it or unsetting it based on the value for the key When disabled field is set to True for a host, the host also changes its reservable status to False. Disabled key can only be set by an admin An admin can create a lease on a host that is non reservable * Add disabled flag alembic migration file * Use the policy.enforce to check if the blazar context is a an admin from keystone * notification callback to use set_reservable method Fix tests that call matching hosts as users, so is_admin should return False New tests for updating disabled field new test for setting reservable True by monitor when disabled is True / False * Remove line in migration auto generated by alembic addressing PR comments change log warn to log debug if a host is disabled and admin is trying to set host reservable
* Add disabled field in ComputeHost model This can be used by admins to specify that a host is disabled for maintainance and that marks that blazar monitor should not touch or alter this host's health while it is disabled (True). THis helps admins to create a lease on the host while it is non reservable and host monitor not changing the status back to reservble - True * 'disabled' field to use in host plugin and admins can create lease when host is non reservable When disabled key is present in extra capabilities handle it by setting it or unsetting it based on the value for the key When disabled field is set to True for a host, the host also changes its reservable status to False. Disabled key can only be set by an admin An admin can create a lease on a host that is non reservable * Add disabled flag alembic migration file * Use the policy.enforce to check if the blazar context is a an admin from keystone * notification callback to use set_reservable method Fix tests that call matching hosts as users, so is_admin should return False New tests for updating disabled field new test for setting reservable True by monitor when disabled is True / False * Remove line in migration auto generated by alembic addressing PR comments change log warn to log debug if a host is disabled and admin is trying to set host reservable
openstack reservation host set <host id/name> --extra disabled=true
openstack reservation host unset <host id/name> --extra disabled