[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-9366?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15254292#comment-15254292
 ] 

ASF GitHub Bot commented on CLOUDSTACK-9366:
--------------------------------------------

GitHub user sudhansu7 opened a pull request:

    https://github.com/apache/cloudstack/pull/1516

    CLOUDSTACK-9366: Capacity of one zone-wide primary storage ignored

    Disable and Remove Host operation disables the primary storage capacity.
    
    Steps to replicate:
    Base Condition: There exists a host and storage pool with same id
    Steps:
    1. Find a host and storage pool having same id
    2. Disable the host
    3. verify that the CPU(1) and MEMORY(0) capacity in op_host_capacity for 
above host is disabled
    4. verify that the STORAGE(3) capacity in op_host_capacity for storage pool 
with id same as above host is also disabled
    
    RCA:
    'host_id' column in 'op_host_capacity' table used for storing both storage 
pool id (for STORAGE capacity) and host id (MEMORY and CPU). While removing a 
HOST we also disable the capacity associated with host.
    
    Ideally while disabling capacity we should only disable MEMORY and CPU 
capacity, but we are not doing so.
    
    Code Path:
    ResourceManagerImpl.doDeleteHost() -> 
ResourceManagerImpl.resourceStateTransitTo() -> 
CapacityDaoImpl.updateCapacityState(null, null, null, host.getId(), 
capacityState.toString())
    
    updateCapacityState is updating disabling all entries which matches the 
host_id. This will also disable a entry having storage pool id same as that of 
host id.
    
    Changes:
    introduced new capacityType parameter in updateCapacityState method and 
necessary changes to add capacity_type clause in sql
    also fixed incorrect sql builder logic (unused code path for which it is 
never surfaced )
    Added marvin test to  check host and storagepool capacity when host is 
disabled
    
    Test Result:
    ```
    mysql> select ohc.host_id, ohc.`capacity_state`,  case capacity_type  when 
0 then  'MEMORY'  when 1 then  'CPU'  ELSE  'STORAGE'  END as 'capacity_type' , 
 total_capacity, case capacity_type  when 0 then  'HOST'  when 1 then  'HOST' 
ELSE  'STORAGE POOL' END as 'HOST/STORAGE POOL'  from op_host_capacity ohc 
where host_id=3;
    
+---------+----------------+---------------+----------------+-------------------+
    | host_id | capacity_state | capacity_type | total_capacity | HOST/STORAGE 
POOL |
    
+---------+----------------+---------------+----------------+-------------------+
    |       3 | Enabled        | MEMORY        |     8589934592 | HOST          
    |
    |       3 | Enabled        | CPU           |          32000 | HOST          
    |
    |       3 | Enabled        | STORAGE       |  2199023255552 | STORAGE POOL  
    |
    
+---------+----------------+---------------+----------------+-------------------+
    
    9 rows in set (0.00 sec)
    
    Disable Host 3 from UI.
    
    mysql> select ohc.host_id, ohc.`capacity_state`,  case capacity_type  when 
0 then  'MEMORY'  when 1 then  'CPU'  ELSE  'STORAGE'  END as 'capacity_type' , 
 total_capacity, case capacity_type  when 0 then  'HOST'  when 1 then  'HOST' 
ELSE  'STORAGE POOL' END as 'HOST/STORAGE POOL'  from op_host_capacity ohc 
where host_id=3;
    
+---------+----------------+---------------+----------------+-------------------+
    | host_id | capacity_state | capacity_type | total_capacity | HOST/STORAGE 
POOL |
    
+---------+----------------+---------------+----------------+-------------------+
    |       3 | Disabled       | MEMORY        |     8589934592 | HOST          
    |
    |       3 | Disabled       | CPU           |          32000 | HOST          
    |
    |       3 | Disabled       | STORAGE       |  2199023255552 | STORAGE POOL  
    |
    
+---------+----------------+---------------+----------------+-------------------+
    
    After Fix:
    
    mysql> select ohc.host_id, ohc.`capacity_state`,  case capacity_type  when 
0 then  'MEMORY'  when 1 then  'CPU'  ELSE  'STORAGE'  END as 'capacity_type' , 
 total_capacity, case capacity_type  when 0 then  'HOST'  when 1 then  'HOST' 
ELSE  'STORAGE POOL' END as 'HOST/STORAGE POOL'  from op_host_capacity ohc 
where host_id=3;
    
+---------+----------------+---------------+----------------+-------------------+
    | host_id | capacity_state | capacity_type | total_capacity | HOST/STORAGE 
POOL |
    
+---------+----------------+---------------+----------------+-------------------+
    |       3 | Enabled        | MEMORY        |     8589934592 | HOST          
    |
    |       3 | Enabled        | CPU           |          32000 | HOST          
    |
    |       3 | Enabled        | STORAGE       |  2199023255552 | STORAGE POOL  
    |
    
+---------+----------------+---------------+----------------+-------------------+
    3 rows in set (0.01 sec)
    
    Disable Host 3 from UI.
    
    mysql> select ohc.host_id, ohc.`capacity_state`,  case capacity_type  when 
0 then  'MEMORY'  when 1 then  'CPU'  ELSE  'STORAGE'  END as 'capacity_type' , 
 total_capacity, case capacity_type  when 0 then  'HOST'  when 1 then  'HOST' 
ELSE  'STORAGE POOL' END as 'HOST/STORAGE POOL'  from op_host_capacity ohc 
where host_id=3;
    
+---------+----------------+---------------+----------------+-------------------+
    | host_id | capacity_state | capacity_type | total_capacity | HOST/STORAGE 
POOL |
    
+---------+----------------+---------------+----------------+-------------------+
    |       3 | Disabled       | MEMORY        |     8589934592 | HOST          
    |
    |       3 | Disabled       | CPU           |          32000 | HOST          
    |
    |       3 | Enabled        | STORAGE       |  2199023255552 | STORAGE POOL  
    |
    
+---------+----------------+---------------+----------------+-------------------+
    3 rows in set (0.00 sec)
    
    
    Sudhansus-MAC:cloudstack sudhansu$  nosetests-2.7 --with-marvin 
--marvin-config=setup/dev/advanced.cfg 
test/integration/component/maint/test_capacity_host_delete.py 
    
    ==== Marvin Init Started ====
    
    === Marvin Parse Config Successful ===
    
    === Marvin Setting TestData Successful===
    
    ==== Log Folder Path: /tmp//MarvinLogs//Apr_22_2016_22_42_27_X4VBWD. All 
logs will be available here ====
    
    === Marvin Init Logging Successful===
    
    ==== Marvin Init Successful ====
    ===final results are now copied to: 
/tmp//MarvinLogs/test_capacity_host_delete_9RHSNB===
    Sudhansus-MAC:cloudstack sudhansu$ cat 
/tmp//MarvinLogs/test_capacity_host_delete_9RHSNB/results.txt 
    test_01_op_host_capacity_disable_host 
(integration.component.maint.test_capacity_host_delete.TestHosts) ... === 
TestName: test_01_op_host_capacity_disable_host | Status : SUCCESS ===
    ok
    
    ----------------------------------------------------------------------
    Ran 1 test in 0.168s
    
    OK
    ```


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/sudhansu7/cloudstack CLOUDSTACK-9366

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cloudstack/pull/1516.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1516
    
----
commit ebeb26a351dc95f2bef877fe469a05952821b97a
Author: Sudhansu <[email protected]>
Date:   2016-04-22T10:06:51Z

    CLOUDSTACK-9366: Capacity of one zone-wide primary storage ignored
    
    introduced new capacityType parameter in updateCapacityState method and 
necessary changes to add capacity_type clause in sql
    also fixed incorrect sql builder logic (unused code path for which it is 
never surfaced )
    Added marvin test to  check host and storagepool capacity when host is 
disabled

----


> Disable a host also disables storage pool capacity
> --------------------------------------------------
>
>                 Key: CLOUDSTACK-9366
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9366
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>          Components: Management Server
>    Affects Versions: 4.8.0
>            Reporter: Sudhansu Sahu
>            Assignee: Sudhansu Sahu
>
> Disable and Remove Host operation disables the primary storage capacity.
> Steps to replicate:
> Base Condition: There exists a host and storage pool with same id
> Steps:
> 1. Find a host and storage pool having same id
> 2. Disable the host
> 3. verify that the CPU(1) and MEMORY(0) capacity in op_host_capacity for 
> above host is disabled
> 4. verify that the STORAGE(3) capacity in op_host_capacity for storage pool 
> with id same as above host is also disabled
> RCA:
> 'host_id' column in 'op_host_capacity' table used for storing both storage 
> pool id (for STORAGE capacity) and host id (MEMORY and CPU). While removing a 
> HOST we also disable the capacity associated with host.
> Ideally while disabling capacity we should only disable MEMORY and CPU 
> capacity, but we are not doing so.
> Code Path:
> ResourceManagerImpl.doDeleteHost() -> 
> ResourceManagerImpl.resourceStateTransitTo() -> 
> CapacityDaoImpl.updateCapacityState(null, null, null, host.getId(), 
> capacityState.toString())
> updateCapacityState is updating disabling all entries which matches the 
> host_id. This will also disable a entry having storage pool id same as that 
> of host id.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to