Skip to content

Commit

Permalink
fix: failure tolerance when first load
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park committed Nov 17, 2024
1 parent ef8a617 commit a4874f4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
8 changes: 2 additions & 6 deletions cmd/pkg/cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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)
}
}
4 changes: 0 additions & 4 deletions pkg/chart/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 5 additions & 4 deletions pkg/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package runtime

import (
"context"
"errors"
"sync"

"github.com/gofrs/uuid"
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 0 additions & 7 deletions pkg/symbol/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a4874f4

Please sign in to comment.