memwatch: publish to the box's placement region, not host.env's AWS_REGION — the module's alarm lives where the box is
1 file changed,
+11
−1
internal/host/memwatch.go+11 −1
CI passed — run details
diff --git a/internal/host/memwatch.go b/internal/host/memwatch.go| index 54781fad8..0a74e14f6 100644 |
| --- a/internal/host/memwatch.go |
| +++ b/internal/host/memwatch.go |
| @@ -93,6 +93,16 @@ func memwatchLoop() { |
| log.Printf("agent: memwatch disabled: load aws config: %v", err) |
| return |
| } |
| + // The metric goes to the box's OWN region, not host.env's AWS_REGION: |
| + // the flagship sets AWS_REGION=eu-west-1 fleet-wide (it names the |
| + // deployment bucket's region), and on the first roll all four boxes |
| + // dutifully published into Ireland — while the region-host module |
| + // creates each box's alarm in the box's region, so three alarms would |
| + // have watched an empty namespace forever. IMDS placement wins; "" (not |
| + // on EC2) keeps the chain's answer. |
| + if r := readPlacementRegion(); r != "" { |
| + cfg.Region = r |
| + } |
| id, err := imdsInstanceID() |
| if err != nil { |
| log.Printf("agent: memwatch disabled: instance id: %v", err) |
| @@ -105,7 +115,7 @@ func memwatchLoop() { |
| pressure: readPressureFile, |
| logf: log.Printf, |
| } |
| - log.Printf("agent: memwatch armed (%s, every %s, instance %s)", memwatchNamespace, memwatchPeriod, id) |
| + log.Printf("agent: memwatch armed (%s in %s, every %s, instance %s)", memwatchNamespace, cfg.Region, memwatchPeriod, id) |
| for now := range time.Tick(memwatchPeriod) { |
| w.tick(ctx, now) |
| } |