cloud/bmaas/bmdb/scruffy: initialize, implement BMDB metrics
This creates a new BMaaS component, Scruffy the Janitor.
Scruffy will run a bunch of housekeeping jobs that aren't tied to a
particular provider or even region. Currently Scruffy just collects BMDB
metrics by periodically polling the BMDB SQL database.
Change-Id: Icafa714811757eaaf31fed43184ded8512bde067
Reviewed-on: https://review.monogon.dev/c/monogon/+/1819
Tested-by: Jenkins CI
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
diff --git a/cloud/bmaas/scruffy/BUILD.bazel b/cloud/bmaas/scruffy/BUILD.bazel
new file mode 100644
index 0000000..4934ad2
--- /dev/null
+++ b/cloud/bmaas/scruffy/BUILD.bazel
@@ -0,0 +1,48 @@
+load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+
+go_library(
+ name = "scruffy",
+ srcs = [
+ "bmdb_stats.go",
+ "hw_stats.go",
+ "labels.go",
+ "server.go",
+ ],
+ importpath = "source.monogon.dev/cloud/bmaas/scruffy",
+ visibility = ["//visibility:public"],
+ deps = [
+ "//cloud/bmaas/bmdb",
+ "//cloud/bmaas/bmdb/metrics",
+ "//cloud/bmaas/bmdb/model",
+ "//cloud/bmaas/bmdb/webug",
+ "//cloud/bmaas/server/api",
+ "//cloud/lib/component",
+ "//go/algorithm/cartesian",
+ "@com_github_cenkalti_backoff_v4//:backoff",
+ "@com_github_google_uuid//:uuid",
+ "@com_github_prometheus_client_golang//prometheus",
+ "@io_k8s_klog_v2//:klog",
+ "@org_golang_google_protobuf//proto",
+ ],
+)
+
+go_test(
+ name = "scruffy_test",
+ srcs = [
+ "bmdb_stats_test.go",
+ "hw_stats_test.go",
+ ],
+ data = [
+ "@cockroach",
+ ],
+ embed = [":scruffy"],
+ deps = [
+ "//cloud/agent/api",
+ "//cloud/bmaas/bmdb",
+ "//cloud/bmaas/bmdb/model",
+ "//cloud/bmaas/server/api",
+ "//cloud/lib/component",
+ "@com_github_prometheus_client_golang//prometheus",
+ "@org_golang_google_protobuf//proto",
+ ],
+)