Skip to content

Commit 57b03a4

Browse files
committedAug 15, 2019
feat(configmap-server): tolerate load errors
Tolerate load errors and use EmptyQuery when table loading fails.
1 parent 35b4959 commit 57b03a4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed
 

‎cmd/configmap-server/main.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/operator-framework/operator-registry/pkg/api"
1818
health "github.com/operator-framework/operator-registry/pkg/api/grpc_health_v1"
1919
"github.com/operator-framework/operator-registry/pkg/lib/log"
20+
"github.com/operator-framework/operator-registry/pkg/registry"
2021
"github.com/operator-framework/operator-registry/pkg/server"
2122
"github.com/operator-framework/operator-registry/pkg/sqlite"
2223
)
@@ -109,18 +110,22 @@ func runCmdFunc(cmd *cobra.Command, args []string) error {
109110
logger.WithError(err).Warn("permissive mode enabled")
110111
}
111112

112-
store, err := sqlite.NewSQLLiteQuerier(dbName)
113+
var store registry.Query
114+
store, err = sqlite.NewSQLLiteQuerier(dbName)
113115
if err != nil {
114-
logger.Fatalf("failed to load db: %s", err)
116+
logger.WithError(err).Warnf("failed to load db")
117+
}
118+
if store == nil {
119+
store = registry.NewEmptyQuerier()
115120
}
116121

117122
// sanity check that the db is available
118123
tables, err := store.ListTables(context.TODO())
119124
if err != nil {
120-
logger.Fatalf("couldn't list tables in db, incorrect config: %s", err)
125+
logger.WithError(err).Warnf("couldn't list tables in db")
121126
}
122127
if len(tables) == 0 {
123-
logger.Fatal("no tables found in db")
128+
logger.Warn("no tables found in db")
124129
}
125130

126131
lis, err := net.Listen("tcp", ":"+port)

0 commit comments

Comments
 (0)
Please sign in to comment.