We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ca6312f commit c045481Copy full SHA for c045481
exporter/metrics.go
@@ -24,6 +24,7 @@ import (
24
"sync"
25
"time"
26
27
+ "github.com/percona/mongodb_exporter/internal/util"
28
"github.com/pkg/errors"
29
"github.com/prometheus/client_golang/prometheus"
30
"go.mongodb.org/mongo-driver/bson"
@@ -213,6 +214,9 @@ func allReservedNames(client *mongo.Client) ([]string, error) {
213
214
reservedNames := []string{}
215
dbs, err := client.ListDatabaseNames(ctx, struct{}{})
216
if err != nil {
217
+ if cmdErr, ok := err.(mongo.CommandError); ok && cmdErr.Code == util.ErrNotPrimaryOrSecondary {
218
+ return []string{}, nil
219
+ }
220
return reservedNames, errors.Wrap(err, "ListDatabaseNames failed")
221
}
222
0 commit comments