From 303eb99f490dd1e2c167f8284e01fc12feee2ba3 Mon Sep 17 00:00:00 2001 From: benbierens Date: Fri, 2 Jun 2023 11:10:16 +0200 Subject: [PATCH] Removes application-level managed namespaces. Use GUIDs instead. --- KubernetesWorkflow/ApplicationLifecycle.cs | 34 ---------------------- KubernetesWorkflow/WorkflowCreator.cs | 2 +- 2 files changed, 1 insertion(+), 35 deletions(-) delete mode 100644 KubernetesWorkflow/ApplicationLifecycle.cs diff --git a/KubernetesWorkflow/ApplicationLifecycle.cs b/KubernetesWorkflow/ApplicationLifecycle.cs deleted file mode 100644 index b14fe52..0000000 --- a/KubernetesWorkflow/ApplicationLifecycle.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Utils; - -namespace KubernetesWorkflow -{ - public class ApplicationLifecycle - { - private static object instanceLock = new object(); - private static ApplicationLifecycle? instance; - private readonly NumberSource namespaceNumberSource = new NumberSource(0); - - private ApplicationLifecycle() - { - } - - public static ApplicationLifecycle Instance - { - // I know singletons are quite evil. But we need to be sure this object is created only once - // and persists for the entire application lifecycle. - get - { - lock (instanceLock) - { - if (instance == null) instance = new ApplicationLifecycle(); - return instance; - } - } - } - - public string GetTestNamespace() - { - return namespaceNumberSource.GetNextNumber().ToString("D5"); - } - } -} diff --git a/KubernetesWorkflow/WorkflowCreator.cs b/KubernetesWorkflow/WorkflowCreator.cs index 3a707cc..d03dca7 100644 --- a/KubernetesWorkflow/WorkflowCreator.cs +++ b/KubernetesWorkflow/WorkflowCreator.cs @@ -16,7 +16,7 @@ namespace KubernetesWorkflow { cluster = new K8sCluster(configuration); this.log = log; - testNamespace = ApplicationLifecycle.Instance.GetTestNamespace(); + testNamespace = Guid.NewGuid().ToString().ToLowerInvariant(); } public StartupWorkflow CreateWorkflow()