Add maglev_backend_info variable that correlates backend/address/healthcheck/source_tag

This commit is contained in:
2026-05-01 15:19:00 +02:00
parent fb61e72e06
commit 86b265c2a9
3 changed files with 28 additions and 7 deletions
+8 -1
View File
@@ -123,6 +123,7 @@ type TCPParams struct {
type Backend struct {
Address net.IP
HealthCheck string // name reference into Config.HealthChecks; "" = no probing, assume healthy
SourceTag string // nginx source tag; defaults to the backend name if omitted from config
Enabled bool // default true; false = exclude from serving entirely
}
@@ -218,7 +219,8 @@ type rawParams struct {
type rawBackend struct {
Address string `yaml:"address"`
HealthCheck string `yaml:"healthcheck"`
Enabled *bool `yaml:"enabled"` // nil → default true
SourceTag string `yaml:"source-tag"` // defaults to backend name if omitted
Enabled *bool `yaml:"enabled"` // nil → default true
}
type rawPoolBackend struct {
@@ -588,9 +590,14 @@ func convertBackend(name string, r *rawBackend, hcs map[string]HealthCheck) (Bac
return Backend{}, fmt.Errorf("invalid address %q", r.Address)
}
sourceTag := r.SourceTag
if sourceTag == "" {
sourceTag = name
}
b := Backend{
Address: ip,
HealthCheck: r.HealthCheck,
SourceTag: sourceTag,
Enabled: boolDefault(r.Enabled, true),
}