fix: bug in traefik presence check
Reordering the checks, and adding one fixes the mishandling of case A
@@ -166,24 +166,21 @@ func (k Traefik) Deploy(ctx context.Context, c *kubernetes.Cluster, ui *termui.U
// c | no | yes | Something has claimed the namespace | Error
// d | no | no | Namespace is free for use | Deploy
- // Bug: The current order of checking (namespace first, then
- // service), and associated actions, mishandles case A (Error
- // instead of nothing).
+ log.Info("check presence, local service")
- log.Info("check presence, namespace")
-
- _, err = c.Kubectl.CoreV1().Namespaces().Get(
+ _, err = c.Kubectl.CoreV1().Services(TraefikDeploymentID).Get(
ctx,
- TraefikDeploymentID,
+ "traefik",
metav1.GetOptions{},
)
if err == nil {
- log.Info("namespace present")
+ log.Info("service present")
- return errors.New("Namespace " + TraefikDeploymentID + " present already")
+ ui.Exclamation().Msg("Traefik Ingress already installed, skipping")
+ return nil
}
- log.Info("check presence, service")
+ log.Info("check presence, system service")
_, err = c.Kubectl.CoreV1().Services("kube-system").Get(
ctx,
@@ -193,13 +190,27 @@ func (k Traefik) Deploy(ctx context.Context, c *kubernetes.Cluster, ui *termui.U
if err == nil {
log.Info("service present")
- ui.Exclamation().Msg("Traefik Ingress already installed, skipping")
-
+ ui.Exclamation().Msg("System Ingress present, skipping")
return nil
}
+ log.Info("check presence, traefik namespace")
+
+ _, err = c.Kubectl.CoreV1().Namespaces().Get(
+ ctx,
+ TraefikDeploymentID,
+ metav1.GetOptions{},
+ )
+ if err == nil {
+ log.Info("namespace present")
+
+ return errors.New("Namespace " + TraefikDeploymentID + " present already")
+ }
+
ui.Note().KeeplineUnder(1).Msg("Deploying Traefik Ingress...")
+ log.Info("deploying traefik")
+
return k.apply(ctx, c, ui, options, false)
}
