From a4874f494de45c0edaa4d4023d0f3abc2a903b1e Mon Sep 17 00:00:00 2001 From: siyual-park Date: Sun, 17 Nov 2024 19:56:39 +0900 Subject: [PATCH] fix: failure tolerance when first load --- cmd/pkg/cli/start.go | 8 ++------ pkg/chart/loader.go | 4 ---- pkg/runtime/runtime.go | 9 +++++---- pkg/symbol/loader.go | 7 ------- 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/cmd/pkg/cli/start.go b/cmd/pkg/cli/start.go index 6535753d..d09dba5a 100644 --- a/cmd/pkg/cli/start.go +++ b/cmd/pkg/cli/start.go @@ -135,9 +135,7 @@ func runStartCommand(config StartConfig) func(cmd *cobra.Command, args []string) if err := r.Watch(ctx); err != nil { return err } - if err := r.Load(ctx); err != nil { - return err - } + r.Load(ctx) go r.Reconcile(ctx) return d.Run() } @@ -150,9 +148,7 @@ func runStartCommand(config StartConfig) func(cmd *cobra.Command, args []string) if err := r.Watch(ctx); err != nil { return err } - if err := r.Load(ctx); err != nil { - return err - } + r.Load(ctx) return r.Reconcile(ctx) } } diff --git a/pkg/chart/loader.go b/pkg/chart/loader.go index 15214996..32212114 100644 --- a/pkg/chart/loader.go +++ b/pkg/chart/loader.go @@ -75,10 +75,6 @@ func (l *Loader) Load(ctx context.Context, charts ...*Chart) error { } } - if len(errs) > 0 { - loaded = nil - } - for _, id := range l.table.Keys() { chrt := l.table.Lookup(id) if chrt != nil && len(resource.Match(chrt, examples...)) > 0 { diff --git a/pkg/runtime/runtime.go b/pkg/runtime/runtime.go index a28ada65..0ac1db1f 100644 --- a/pkg/runtime/runtime.go +++ b/pkg/runtime/runtime.go @@ -2,6 +2,7 @@ package runtime import ( "context" + "errors" "sync" "github.com/gofrs/uuid" @@ -114,10 +115,10 @@ func New(config Config) *Runtime { // Load loads symbols from the spec store into the symbol table. func (r *Runtime) Load(ctx context.Context) error { - if err := r.chartLoader.Load(ctx, &chart.Chart{Namespace: r.namespace}); err != nil { - return err - } - return r.symbolLoader.Load(ctx, &spec.Meta{Namespace: r.namespace}) + var errs []error + errs = append(errs, r.chartLoader.Load(ctx, &chart.Chart{Namespace: r.namespace})) + errs = append(errs, r.symbolLoader.Load(ctx, &spec.Meta{Namespace: r.namespace})) + return errors.Join(errs...) } // Watch sets up watchers for specification and secret changes. diff --git a/pkg/symbol/loader.go b/pkg/symbol/loader.go index 92db6932..3fb6b6c6 100644 --- a/pkg/symbol/loader.go +++ b/pkg/symbol/loader.go @@ -110,13 +110,6 @@ func (l *Loader) Load(ctx context.Context, specs ...spec.Spec) error { symbols = append(symbols, sb) } - if len(errs) > 0 { - for _, sb := range symbols { - sb.Close() - } - symbols = nil - } - for _, id := range l.table.Keys() { sb := l.table.Lookup(id) if sb != nil && len(resource.Match(sb.Spec, examples...)) > 0 {