Update pod_delete call for new log message

The latest kubernetes has changed the log message when a pod
is not found, from "pod 'x' not found" to "pods 'x' not found".
To handle this, and maintain compatibility, this removes the
check for 'pod ' and just checks the log message for
"'x' not found".

Change-Id: Id3a847a576beed383bb0e382afa545828047648b
Closes-Bug: #1435575
This commit is contained in:
Andrew Melton 2015-03-23 15:06:21 -07:00
parent d915e4e063
commit 375f7c272c
2 changed files with 17 additions and 2 deletions

View File

@ -204,7 +204,7 @@ class KubeClient(object):
return False
if err:
if ('pod "%s" not found' % name) in err:
if ('"%s" not found' % name) in err:
raise exception.PodNotFound(pod=name)
else:
return False

View File

@ -196,7 +196,7 @@ class KubeClientTestCase(base.TestCase):
mock_trycmd.assert_called_once_with(*expected_command)
@patch('magnum.openstack.common.utils.trycmd')
def test_pod_delete_not_found(self, mock_trycmd):
def test_pod_delete_not_found_old(self, mock_trycmd):
expected_master_address = 'master-address'
expected_pod_name = 'test-pod'
expected_command = [
@ -209,3 +209,18 @@ class KubeClientTestCase(base.TestCase):
expected_master_address, expected_pod_name)
mock_trycmd.assert_called_once_with(*expected_command)
@patch('magnum.openstack.common.utils.trycmd')
def test_pod_delete_not_found_new(self, mock_trycmd):
expected_master_address = 'master-address'
expected_pod_name = 'test-pod'
expected_command = [
'kubectl', 'delete', 'pod', expected_pod_name,
'-s', expected_master_address
]
mock_trycmd.return_value = ("", 'pods "test-pod" not found')
self.assertRaises(exception.PodNotFound, self.kube_client.pod_delete,
expected_master_address, expected_pod_name)
mock_trycmd.assert_called_once_with(*expected_command)