Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D2CEF200ACA for ; Wed, 18 May 2016 16:01:14 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D15B31609B0; Wed, 18 May 2016 14:01:14 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id F3F8D160A00 for ; Wed, 18 May 2016 16:01:13 +0200 (CEST) Received: (qmail 53421 invoked by uid 500); 18 May 2016 14:01:13 -0000 Mailing-List: contact issues-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list issues@cloudstack.apache.org Received: (qmail 53279 invoked by uid 500); 18 May 2016 14:01:13 -0000 Delivered-To: apmail-incubator-cloudstack-issues@incubator.apache.org Received: (qmail 53246 invoked by uid 99); 18 May 2016 14:01:13 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 May 2016 14:01:13 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 07A032C1F5D for ; Wed, 18 May 2016 14:01:13 +0000 (UTC) Date: Wed, 18 May 2016 14:01:13 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: cloudstack-issues@incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CLOUDSTACK-9366) Disable a host also disables storage pool capacity MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 18 May 2016 14:01:15 -0000 [ https://issues.apache.org/jira/browse/CLOUDSTACK-9366?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15289004#comment-15289004 ] ASF GitHub Bot commented on CLOUDSTACK-9366: -------------------------------------------- Github user swill commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1516#discussion_r63707528 --- Diff: test/integration/component/maint/test_capacity_host_delete.py --- @@ -0,0 +1,195 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Test from the Marvin - Testing in Python wiki + +# All tests inherit from cloudstackTestCase +from marvin.cloudstackTestCase import cloudstackTestCase, unittest + +# Import Integration Libraries + +# base - contains all resources as entities and defines create, delete, +# list operations on them +from marvin.lib.base import Host, Cluster, Zone, Pod + +# utils - utility classes for common cleanup, external library wrappers etc +from marvin.lib.utils import cleanup_resources + +# common - commonly used methods for all tests are listed here +from marvin.lib.common import get_zone, get_domain, list_hosts, get_pod + +from nose.plugins.attrib import attr + +import time +import logging +# These tests need to be run separately and not in parallel with other tests. +# Because it disables the host +# host_id column of op_host_capacity refers to host_id or a storage pool id +# +# This test is to make sure that Disable host only disables the capacities of type +# CPU and MEMORY +# +# TEST: +# 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 not disabled +# + +def update_host(apiclient, state, host_id): + """ + Function to Enable/Disable Host + """ + host_status = Host.update( + apiclient, + id=host_id, + allocationstate=state + ) + return host_status.resourcestate + + +def check_db(self, host_state): + """ + Function to check capacity_state in op_host_capacity table + """ + capacity_state = self.dbclient.execute( + "select capacity_state from op_host_capacity where host_id='%s' and capacity_type in (0,1) order by capacity_type asc;" % + self.host_db_id[0][0]) + self.assertEqual( + capacity_state[0][0], + host_state + + "d", + "Invalid db query response for capacity_state %s" % + capacity_state[0][0]) + self.assertEqual( + capacity_state[1][0], + host_state + + "d", + "Invalid db query response for capacity_state %s" % + capacity_state[1][0]) + + capacity_state = self.dbclient.execute( + "select capacity_state from op_host_capacity where host_id='%s' and capacity_type = 3 order by capacity_type asc;" % + self.host_db_id[0][0]) + self.assertNotEqual( + capacity_state[0][0], + host_state + + "d", + "Invalid db query response for capacity_state %s" % + capacity_state[0][0]) + return capacity_state[0][0] + + +class TestHosts(cloudstackTestCase): + + """ + Testing Hosts + """ + @classmethod + def setUpClass(cls): + cls.testClient = super(TestHosts, cls).getClsTestClient() + cls.testdata = cls.testClient.getParsedTestDataConfig() + cls.apiclient = cls.testClient.getApiClient() + cls.dbclient = cls.testClient.getDbConnection() + cls._cleanup = [] + + # get zone, domain etc + cls.zone = Zone(get_zone(cls.apiclient, cls.testClient.getZoneForTests()).__dict__) + cls.domain = get_domain(cls.apiclient) + cls.pod = get_pod(cls.apiclient, cls.zone.id) + + cls.logger = logging.getLogger('TestHosts') + cls.stream_handler = logging.StreamHandler() + cls.logger.setLevel(logging.DEBUG) + cls.logger.addHandler(cls.stream_handler) + + # list hosts + hosts = list_hosts(cls.apiclient, type="Routing") + i = 0 + while (i < len(hosts)): + host_id = hosts[i].id + cls.logger.debug("Trying host id : %s" % host_id) + host_db_id = cls.dbclient.execute( + "select id from host where uuid='%s';" % + host_id) + + if host_db_id: --- End diff -- This applies to all similar situations. > 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)