Changed kubectl command to delete rc in magnum.

Currently in magnum to delete a rc, 'stop' command
of kubectl was used. But there is no 'stop' command
in kubectl.
To delete a rc, 'delete' command is used. Hence this
patch changes the command used in magnum.

Closes-bug: 1433428

Change-Id: I9eef1a61cf023a6654eb7833860921edce52129c
This commit is contained in:
Madhuri Kumari 2015-03-19 07:57:20 +00:00
parent 112558dab4
commit 7e4b4f9526
3 changed files with 7 additions and 7 deletions

View File

@ -262,15 +262,15 @@ class KubeClient(object):
return False
return True
def rc_stop(self, master_address, name):
LOG.debug("rc_stop %s" % name)
def rc_delete(self, master_address, name):
LOG.debug("rc_delete %s" % name)
try:
out, err = utils.trycmd('kubectl', 'stop', 'rc', name,
out, err = utils.trycmd('kubectl', 'delete', 'rc', name,
'-s', master_address)
if err:
return False
except Exception as e:
LOG.error(_LE("Couldn't stop rc %(rc)s due to error %(error)s")
LOG.error(_LE("Couldn't delete rc %(rc)s due to error %(error)s")
% {'rc': name, 'error': e})
return False
return True

View File

@ -224,7 +224,7 @@ class Handler(object):
k8s_master_url = _retrieve_k8s_master_url(context, rc)
if _object_has_stack(context, rc):
# trigger a kubectl command
status = self.kube_cli.rc_stop(k8s_master_url, rc.name)
status = self.kube_cli.rc_delete(k8s_master_url, rc.name)
if not status:
return None
# call the rc object to persist in db

View File

@ -313,10 +313,10 @@ class TestKube(base.TestCase):
mock_retrieve_k8s_master_url.return_value = expected_master_url
mock_object_has_stack.return_value = True
with patch.object(self.kube_handler, 'kube_cli') as mock_kube_cli:
mock_kube_cli.rc_stop.return_value = True
mock_kube_cli.rc_delete.return_value = True
self.kube_handler.rc_delete(self.context, mock_rc.uuid)
mock_kube_cli.rc_stop.assert_called_once_with(
mock_kube_cli.rc_delete.assert_called_once_with(
expected_master_url, mock_rc.name)
mock_rc.destroy.assert_called_once_with(self.context)