diff --git a/magnum/conductor/handlers/common/kube_utils.py b/magnum/conductor/handlers/common/kube_utils.py index 47cf882deb..eaf9626b3f 100644 --- a/magnum/conductor/handlers/common/kube_utils.py +++ b/magnum/conductor/handlers/common/kube_utils.py @@ -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 diff --git a/magnum/tests/conductor/handlers/common/test_kube_utils.py b/magnum/tests/conductor/handlers/common/test_kube_utils.py index 9df09d6cf6..e3622a29df 100644 --- a/magnum/tests/conductor/handlers/common/test_kube_utils.py +++ b/magnum/tests/conductor/handlers/common/test_kube_utils.py @@ -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)