Skip to content

Commit

Permalink
vai: log errors on add (#120)
Browse files Browse the repository at this point in the history
* vai: log errors on add

client-go unfortunately "swallows" them

Signed-off-by: Silvio Moioli <silvio@moioli.net>

* vai: log errors on delete

Signed-off-by: Silvio Moioli <silvio@moioli.net>

* Apply suggestions from code review

Co-authored-by: Tom Lebreux <me@tomlebreux.com>

* Update pkg/cache/sql/store/store.go

Co-authored-by: Tom Lebreux <me@tomlebreux.com>

---------

Signed-off-by: Silvio Moioli <silvio@moioli.net>
Co-authored-by: Tom Lebreux <me@tomlebreux.com>
  • Loading branch information
moio and tomleb authored Jan 9, 2025
1 parent 04649f3 commit 00757ee
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/cache/sql/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/rancher/lasso/pkg/cache/sql/db"
"github.com/rancher/lasso/pkg/cache/sql/db/transaction"
"github.com/rancher/lasso/pkg/log"
"k8s.io/client-go/tools/cache"
_ "modernc.org/sqlite"
)
Expand Down Expand Up @@ -180,7 +181,11 @@ func (s *Store) Add(obj any) error {
}

err = s.upsert(key, obj)
return err
if err != nil {
log.Errorf("Error in Store.Add for type %v: %v", s.name, err)
return err
}
return nil
}

// Update saves an obj, or updates it if it exists in this Store
Expand All @@ -194,7 +199,12 @@ func (s *Store) Delete(obj any) error {
if err != nil {
return err
}
return s.deleteByKey(key)
err = s.deleteByKey(key)
if err != nil {
log.Errorf("Error in Store.Delete for type %v: %v", s.name, err)
return err
}
return nil
}

// List returns a list of all the currently known objects
Expand Down

0 comments on commit 00757ee

Please sign in to comment.