From ffa760e7a39e90c3152d9cd22d404cc8f37e8c5a Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Date: Thu, 27 Jan 2022 17:01:32 +0100 Subject: [PATCH] Safely shutdown MicroShift if kustomization fails Depends-On: #575 Signed-off-by: Miguel Angel Ajo --- pkg/kustomize/apply.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/kustomize/apply.go b/pkg/kustomize/apply.go index 9a50fab0d6..e00b60cd9d 100644 --- a/pkg/kustomize/apply.go +++ b/pkg/kustomize/apply.go @@ -42,13 +42,14 @@ func (s *Kustomizer) Dependencies() []string { return []string{"kube-apiserver"} func (s *Kustomizer) Run(ctx context.Context, ready chan<- struct{}, stopped chan<- struct{}) error { defer close(stopped) - defer close(ready) kustomization := filepath.Join(s.path, "kustomization.yaml") if _, err := os.Stat(kustomization); !errors.Is(err, os.ErrNotExist) { klog.Infof("Applying kustomization at %v ", kustomization) if err := ApplyKustomizationWithRetries(s.path, s.kubeconfig); err != nil { klog.Warningf("Applying kustomization failed: %s. Giving up.", err) + // Make the service manager safely shut down everything + return err } else { klog.Warningf("Kustomization applied successfully.") } @@ -56,6 +57,7 @@ func (s *Kustomizer) Run(ctx context.Context, ready chan<- struct{}, stopped cha klog.Infof("No kustomization found at " + kustomization) } + close(ready) return ctx.Err() }