cloud/shepherd/equinix: update provider extra data
This adds a new sub-component to the Equinix Shepherd, the Updater.
The Updater periodically scans all machines backed by the Equinix
provider in the BMDB and queries the Equinix API for their status. The
status then populates the new 'Provided' row data.
Change-Id: I99657545aabfb13d71e165d36ce549c852feaf49
Reviewed-on: https://review.monogon.dev/c/monogon/+/1578
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/cloud/bmaas/bmdb/model/queries_tags.sql b/cloud/bmaas/bmdb/model/queries_tags.sql
index a781509..ddb6f19 100644
--- a/cloud/bmaas/bmdb/model/queries_tags.sql
+++ b/cloud/bmaas/bmdb/model/queries_tags.sql
@@ -60,3 +60,13 @@
-- name: MachineDeleteAgentHeartbeat :exec
DELETE FROM machine_agent_heartbeat
WHERE machine_id = $1;
+
+-- name: MachineUpdateProviderStatus :exec
+UPDATE machine_provided
+SET
+ provider_reservation_id = COALESCE($3, provider_reservation_id),
+ provider_ip_address = COALESCE($4, provider_ip_address),
+ provider_location = COALESCE($5, provider_location),
+ provider_status = COALESCE($6, provider_status)
+WHERE provider_id = $1
+AND provider = $2;
\ No newline at end of file
diff --git a/cloud/bmaas/bmdb/reflection/reflection.go b/cloud/bmaas/bmdb/reflection/reflection.go
index ebebed1..3f1b69a 100644
--- a/cloud/bmaas/bmdb/reflection/reflection.go
+++ b/cloud/bmaas/bmdb/reflection/reflection.go
@@ -409,7 +409,7 @@
}
case "USER-DEFINED":
switch r.Type.NativeUDTName {
- case "provider":
+ case "provider", "provider_status":
src2, ok := src.([]byte)
if !ok {
return fmt.Errorf("SQL type %q, but got %+v", r.Type.NativeType, src)