diff --git a/acto/kubernetes_engine/kind.py b/acto/kubernetes_engine/kind.py index 09dac36752..1b6ee9aa1c 100644 --- a/acto/kubernetes_engine/kind.py +++ b/acto/kubernetes_engine/kind.py @@ -3,6 +3,7 @@ import subprocess import time from typing import Any, Dict, List +from filelock import FileLock import kubernetes import yaml @@ -16,6 +17,8 @@ class Kind(base.KubernetesEngine): """Kind engine for provisioning Kubernetes""" + lock = FileLock("file_lock.txt.lock") + def __init__( self, acto_namespace: int, @@ -92,6 +95,7 @@ def create_cluster(self, name: str, kubeconfig: str): config: path of the config file for cluster version: k8s version """ + self.lock.acquire() print_event("Creating a Kind cluster...") cmd = ["kind", "create", "cluster"] @@ -140,6 +144,8 @@ def create_cluster(self, name: str, kubeconfig: str): if self._posthooks: for posthook in self._posthooks: posthook(apiclient=apiclient) + + self.lock.release() def load_images(self, images_archive_path: str, name: str): logging.info("Loading preload images")