cloud/bmaas: implement webug
Webug (pronounced: /wɛbʌɡ/, not /wiːbʌɡ/) is a web debug interface for
BMDB, inspired by the great web debug interfaces of old.
It uses the new BMDB reflection API to access most
machine/tag/work/backoff information, plus sqlc queries to access
session information.
Change-Id: If0e65b6fc33ad92baef9c6d98333f90a02efa1b3
Reviewed-on: https://review.monogon.dev/c/monogon/+/1132
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
Tested-by: Jenkins CI
diff --git a/cloud/bmaas/bmdb/connection.go b/cloud/bmaas/bmdb/connection.go
index c07bf15..acf226f 100644
--- a/cloud/bmaas/bmdb/connection.go
+++ b/cloud/bmaas/bmdb/connection.go
@@ -5,6 +5,7 @@
"database/sql"
"fmt"
+ "github.com/google/uuid"
"k8s.io/klog/v2"
"source.monogon.dev/cloud/bmaas/bmdb/model"
@@ -78,3 +79,16 @@
func (c *Connection) Reflect(ctx context.Context) (*reflection.Schema, error) {
return reflection.Reflect(ctx, c.db)
}
+
+// ListHistoryOf retrieves a full audit history of a machine, sorted
+// chronologically. It can be read without a session / transaction for debugging
+// purposes.
+func (c *Connection) ListHistoryOf(ctx context.Context, machine uuid.UUID) ([]model.WorkHistory, error) {
+ return model.New(c.db).ListHistoryOf(ctx, machine)
+}
+
+// GetSession retrieves all information about a session. It can be read without a
+// session/transaction for debugging purposes.
+func (c *Connection) GetSession(ctx context.Context, session uuid.UUID) ([]model.Session, error) {
+ return model.New(c.db).GetSession(ctx, session)
+}