Skip to content

Commit

Permalink
Fix demoted user cannot execute metal-db health check. (#543)
Browse files Browse the repository at this point in the history
* Fix demoted user cannot execute metal-db health check.

* Use ctx.
  • Loading branch information
Gerrit91 authored Jul 3, 2024
1 parent 6028f51 commit 1bf4e40
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/datastore/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (rs *RethinkStore) Check(ctx context.Context) (rest.HealthResult, error) {
return returnStatus(err)
}

cursor, err := r.DB("rethinkdb").Table("server_status").Field("process").Field("version").Run(rs.session)
cursor, err := r.DB("rethinkdb").Table("server_status").Field("process").Field("version").Run(rs.session, r.RunOpts{Context: ctx})
if err != nil {
return returnStatus(err)
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/metal-api/internal/datastore/rethinkdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ func (rs *RethinkStore) initializeTables(opts r.TableCreateOpts) error {
if err != nil {
return err
}
_, err = r.DB("rethinkdb").Grant(DemotedUser, map[string]interface{}{"read": true}).RunWrite(rs.session)
if err != nil {
return err
}

// integer pools
err = rs.GetVRFPool().initIntegerPool(rs.log)
Expand Down

0 comments on commit 1bf4e40

Please sign in to comment.