Bug 1371572 - Able to spin off VM on a compute node where nova computer service is disabled
Summary: Able to spin off VM on a compute node where nova computer service is disabled
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: openstack-nova
Version: 9.0 (Mitaka)
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Eoghan Glynn
QA Contact: Prasanth Anbalagan
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-08-30 13:52 UTC by praveen madire
Modified: 2019-09-09 13:49 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-09-02 22:10:30 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description praveen madire 2016-08-30 13:52:32 UTC
Description of problem:

1)Disable nova compute service by executing the following command(rep : nova service-disable hostname of compute node nova-compute

2)Spin off VM using the following command : nova boot --flavor 2 --image=image id --nic net-id=nic id --availability-zone=nova:hostname of compute node VMName

3)Now check the status of the above VM(nova list --fields name,status,host,power_state)

Actual results: VM is in running state

Expected results: VM should be in Error state

Comment 2 melanie witt 2016-09-02 22:10:30 UTC
This is expected behavior when using the --availability-zone ZONE:HOST option (forced_host) as it will bypass all other scheduler filters, including any that check the 'disabled' status of a host. The API is controlled by policy and with the default policy, it's only available to admin users.

One use case for the API is when an admin adds a new compute node to a cluster, they can add it in disabled state to exclude it from scheduling for normal users. As an admin user, they can bypass the disabled state and boot instances on the new compute node to test it before deciding to enable the node to everyone else. 

[1] http://docs.openstack.org/admin-guide/cli-nova-specify-host.html

Comment 3 Audra Cooper 2016-09-20 13:48:57 UTC
(In reply to melanie witt from comment #2)
> This is expected behavior when using the --availability-zone ZONE:HOST
> option (forced_host) as it will bypass all other scheduler filters,
> including any that check the 'disabled' status of a host. The API is
> controlled by policy and with the default policy, it's only available to
> admin users.
> 
> One use case for the API is when an admin adds a new compute node to a
> cluster, they can add it in disabled state to exclude it from scheduling for
> normal users. As an admin user, they can bypass the disabled state and boot
> instances on the new compute node to test it before deciding to enable the
> node to everyone else. 
> 
> [1] http://docs.openstack.org/admin-guide/cli-nova-specify-host.html

Hmmm..  It didn't work this way in OSP8.  Using --availability-zone specifying the "disabled" host would prevent an instance from being created on that host.

Set compute to service Disable “put it in Host Maintenance mode”:
[root@overcloud-controller-0 ~]# nova service-disable overcloud-compute-1.localdomain nova-compute
+---------------------------------+--------------+----------+
| Host                            | Binary       | Status   |
+---------------------------------+--------------+----------+
| overcloud-compute-1.localdomain | nova-compute | disabled |
+---------------------------------+--------------+----------+
 
Verify instances are not created on this host
Via cli:  
[root@overcloud-controller-0 ~]# nova boot --flavor 2 --image=f7b76c84-76c5-4d29-aac2-65ca92f35aff --nic net-id=48952322-d8cb-4b94-8827-1185fb739a4f --availability-zone=nova:overcloud-compute-1.localdomain createinst_hostdisbld
+--------------------------------------+-----------------------------------------------+
| Property                             | Value                                         |
+--------------------------------------+-----------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                        |
| OS-EXT-AZ:availability_zone          | nova                                          |
| OS-EXT-SRV-ATTR:host                 | -                                             |
| OS-EXT-SRV-ATTR:hostname             | createinst-hostdisbld                         |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | -                                             |
| OS-EXT-SRV-ATTR:instance_name        | instance-00000037                             |
| OS-EXT-SRV-ATTR:kernel_id            |                                               |
| OS-EXT-SRV-ATTR:launch_index         | 0                                             |
| OS-EXT-SRV-ATTR:ramdisk_id           |                                               |
| OS-EXT-SRV-ATTR:reservation_id       | r-92v2hkd9                                    |
| OS-EXT-SRV-ATTR:root_device_name     | -                                             |
| OS-EXT-SRV-ATTR:user_data            | -                                             |
| OS-EXT-STS:power_state               | 0                                             |
| OS-EXT-STS:task_state                | scheduling                                    |
| OS-EXT-STS:vm_state                  | building                                      |
| OS-SRV-USG:launched_at               | -                                             |
| OS-SRV-USG:terminated_at             | -                                             |
| accessIPv4                           |                                               |
| accessIPv6                           |                                               |
| adminPass                            | Ymx7bTHD4zLv                                  |
| config_drive                         |                                               |
| created                              | 2016-05-13T13:23:51Z                          |
| flavor                               | m1.small (2)                                  |
| hostId                               |                                               |   -> Note, no host id
| id                                   | f0ee8676-7423-4573-9582-aa6b4354f06d          |
| image                                | cirros (f7b76c84-76c5-4d29-aac2-65ca92f35aff) |
| key_name                             | -                                             |
| locked                               | False                                         |
| metadata                             | {}                                            |
| name                                 | createinst_hostdisbld                         |
| os-extended-volumes:volumes_attached | []                                            |
| progress                             | 0                                             |
| security_groups                      | default                                       |
| status                               | BUILD                                         |
| tenant_id                            | 83e3818b58a8435f930ee6c86c5cc902              |
| updated                              | 2016-05-13T13:23:55Z                          |
| user_id                              | 04e770daf7af4c5eb22d1318daf0da75              |
+--------------------------------------+-----------------------------------------------+

Instance gets created but not running anywhere:
[root@overcloud-controller-0 ~]# nova list --fields name,status,host,power_state
+--------------------------------------+---------------------------+--------+---------------------------------+-------------+
| ID                                   | Name                      | Status | Host                            | Power State |
+--------------------------------------+---------------------------+--------+---------------------------------+-------------+
| f0ee8676-7423-4573-9582-aa6b4354f06d | createinst_hostdisbld     | ERROR  | None                            | NOSTATE     |
| 8a73dfa5-b3b2-469e-8e09-8bd12318e7f8 | test                      | ACTIVE | overcloud-compute-2.localdomain | Running     |
+--------------------------------------+---------------------------+--------+---------------------------------+-------------+

Set compute to service Enable “take it out of Host Maintenance mode”:

[root@overcloud-controller-0 ~]# nova service-enable overcloud-compute-1.localdomain nova-compute
+---------------------------------+--------------+---------+
| Host                            | Binary       | Status  |
+---------------------------------+--------------+---------+
| overcloud-compute-1.localdomain | nova-compute | enabled |
+---------------------------------+--------------+---------+

Verify instances can be created on this host:
Via cli:  
nova boot --flavor 2 --image=f7b76c84-76c5-4d29-aac2-65ca92f35aff --nic net-id=48952322-d8cb-4b94-8827-1185fb739a4f \
--availability-zone=nova:overcloud-compute-1.localdomain createinst_hostenabld

[root@overcloud-controller-0 ~]# nova list --fields name,status,host,power_state
+--------------------------------------+---------------------------+--------+---------------------------------+-------------+
| ID                                   | Name                      | Status | Host                            | Power State |
+--------------------------------------+---------------------------+--------+---------------------------------+-------------+
| 153829e8-bffc-41ab-97e9-cbc5dd13a804 | createinst_hostenabld     | ACTIVE | overcloud-compute-1.localdomain | Running     |
| 8a73dfa5-b3b2-469e-8e09-8bd12318e7f8 | test                      | ACTIVE | overcloud-compute-2.localdomain | Running     |
+--------------------------------------+---------------------------+--------+---------------------------------+-------------+


Note You need to log in before you can comment on or make changes to this bug.