From f980be51b5cf116d73aae65959cb6bca589922cf Mon Sep 17 00:00:00 2001 From: Oleg Basov Date: Wed, 24 Mar 2021 20:25:05 +0000 Subject: [PATCH] Add serviceaccount_delay to namespace context Update namespace context by adding 'serviceaccount_delay' property (integer) to wait for every service account creation. Otherwise, tests which have 'with_serviceaccount=True' fail with 'No API token found for service account "c-rally-xxx-xxx"', if there's some time passes after async request for account creation --- xrally_kubernetes/tasks/contexts/namespaces.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/xrally_kubernetes/tasks/contexts/namespaces.py b/xrally_kubernetes/tasks/contexts/namespaces.py index 80de102..b8160e3 100644 --- a/xrally_kubernetes/tasks/contexts/namespaces.py +++ b/xrally_kubernetes/tasks/contexts/namespaces.py @@ -13,6 +13,7 @@ # under the License. from rally.task import context +from rally.common import utils as commonutils from xrally_kubernetes.tasks import context as common_context @@ -34,6 +35,10 @@ class NamespaceContext(common_context.BaseKubernetesContext): }, "namespace_choice_method": { "enum": ["random", "round_robin"] + }, + "serviceaccount_delay": { + "type": "integer", + "minimum": 0 } } } @@ -43,7 +48,8 @@ class NamespaceContext(common_context.BaseKubernetesContext): def setup(self): self.context["kubernetes"].update({ "namespace_choice_method": self.config["namespace_choice_method"], - "serviceaccounts": self.config.get("with_serviceaccount") or False + "serviceaccounts": self.config.get("with_serviceaccount") or False, + "serviceaccount_delay": self.config.get("serviceaccount_delay") or 0 }) self.context["kubernetes"].setdefault("namespaces", []) @@ -53,6 +59,9 @@ def setup(self): if self.config.get("with_serviceaccount"): self.client.create_serviceaccount(name, namespace=name) self.client.create_secret(name, namespace=name) + commonutils.interruptable_sleep( + self.context["kubernetes"]["serviceaccount_delay"] + ) def cleanup(self): for name in self.context["kubernetes"].get("namespaces"):