From d0288041176ca8c80c59fff2430ba87b0f90107b Mon Sep 17 00:00:00 2001 From: Hongbin Lu Date: Mon, 20 Nov 2017 03:04:13 +0000 Subject: [PATCH] Allow duplicated container name by default In before, the default config disallow duplicated name within tenant. This is a bad default because zun auto-generate container name if it is not specified. It is possible that the same name is generated twice which causes failure. This makes our API unpredictable which is not a good practice. Therefore, we changed the default to allow duplicated name. Change-Id: Ic0f4d1279c0822aceac9e1983dc500afe9834a59 --- zun/conf/compute.py | 2 +- zun/tests/unit/db/test_container.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/zun/conf/compute.py b/zun/conf/compute.py index 03e7f5397..e0ae8fce3 100644 --- a/zun/conf/compute.py +++ b/zun/conf/compute.py @@ -25,7 +25,7 @@ service_opts = [ db_opts = [ cfg.StrOpt( 'unique_container_name_scope', - default='project', + default='', choices=['', 'project', 'global'], help=""" Sets the scope of the check for unique container names. diff --git a/zun/tests/unit/db/test_container.py b/zun/tests/unit/db/test_container.py index 35f318346..5862dcb5f 100644 --- a/zun/tests/unit/db/test_container.py +++ b/zun/tests/unit/db/test_container.py @@ -200,6 +200,8 @@ class DbContainerTestCase(base.DbTestCase): self.assertEqual(new_image, res.image) def test_update_container_with_the_same_name(self): + CONF.set_override("unique_container_name_scope", "project", + group="compute") container1 = utils.create_test_container( name='container-one', uuid=uuidutils.generate_uuid(), @@ -412,6 +414,8 @@ class EtcdDbContainerTestCase(base.DbTestCase): @mock.patch.object(etcd_client, 'update') def test_update_container_with_the_same_name(self, mock_update, mock_write, mock_read): + CONF.set_override("unique_container_name_scope", "project", + group="compute") mock_read.side_effect = etcd.EtcdKeyNotFound container1 = utils.create_test_container( name='container-one',