fix(network): context.Background() für applyAsync + StartLimitIntervalSec=0

applyAsync()-Goroutinen in networks.go und ipaddresses.go nutzten
c.Request.Context() — der wird gecancelt wenn der Handler zurückkehrt,
was zu "query: context canceled" in jedem Apply-Lauf führte.
Fix: context.Background() direkt in der Goroutine.

StartLimitIntervalSec=0 in beiden apply-Services verhindert dass
systemd bei mehrfachen schnellen Triggers (Burst > 5) drosselt.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Debian
2026-05-30 13:41:29 +02:00
parent 0ee754e231
commit 49899e984c
4 changed files with 13 additions and 11 deletions

View File

@@ -1 +1 @@
1.2.17 1.2.18

View File

@@ -30,9 +30,9 @@ func NewIPAddressesHandler(repo *ipaddresses.Repo, a *audit.Repo, nodeID string)
} }
} }
func (h *IPAddressesHandler) applyAsync(ctx context.Context) { func (h *IPAddressesHandler) applyAsync() {
go func() { go func() {
if err := h.Generator.Render(ctx); err != nil { if err := h.Generator.Render(context.Background()); err != nil {
slog.Warn("ip-addresses: apply failed", "error", err) slog.Warn("ip-addresses: apply failed", "error", err)
} }
}() }()
@@ -86,7 +86,7 @@ func (h *IPAddressesHandler) Create(c *gin.Context) {
} }
_ = h.Audit.Log(c.Request.Context(), actorOf(c), "ip_address.create", _ = h.Audit.Log(c.Request.Context(), actorOf(c), "ip_address.create",
req.Address, out, h.NodeID) req.Address, out, h.NodeID)
h.applyAsync(c.Request.Context()) h.applyAsync()
response.Created(c, out) response.Created(c, out)
} }
@@ -111,7 +111,7 @@ func (h *IPAddressesHandler) Update(c *gin.Context) {
} }
_ = h.Audit.Log(c.Request.Context(), actorOf(c), "ip_address.update", _ = h.Audit.Log(c.Request.Context(), actorOf(c), "ip_address.update",
out.Address, out, h.NodeID) out.Address, out, h.NodeID)
h.applyAsync(c.Request.Context()) h.applyAsync()
response.OK(c, out) response.OK(c, out)
} }
@@ -130,6 +130,6 @@ func (h *IPAddressesHandler) Delete(c *gin.Context) {
} }
_ = h.Audit.Log(c.Request.Context(), actorOf(c), "ip_address.delete", _ = h.Audit.Log(c.Request.Context(), actorOf(c), "ip_address.delete",
strconv.FormatInt(id, 10), gin.H{"id": id}, h.NodeID) strconv.FormatInt(id, 10), gin.H{"id": id}, h.NodeID)
h.applyAsync(c.Request.Context()) h.applyAsync()
response.NoContent(c) response.NoContent(c)
} }

View File

@@ -39,9 +39,9 @@ func NewNetworksHandler(
} }
} }
func (h *NetworksHandler) applyAsync(ctx context.Context) { func (h *NetworksHandler) applyAsync() {
go func() { go func() {
if err := h.Generator.Render(ctx); err != nil { if err := h.Generator.Render(context.Background()); err != nil {
slog.Warn("network-interfaces: apply failed", "error", err) slog.Warn("network-interfaces: apply failed", "error", err)
} }
}() }()
@@ -106,7 +106,7 @@ func (h *NetworksHandler) Create(c *gin.Context) {
return return
} }
_ = h.Audit.Log(c.Request.Context(), actorOf(c), "network_interface.create", req.Name, out, h.NodeID) _ = h.Audit.Log(c.Request.Context(), actorOf(c), "network_interface.create", req.Name, out, h.NodeID)
h.applyAsync(c.Request.Context()) h.applyAsync()
response.Created(c, out) response.Created(c, out)
} }
@@ -141,7 +141,7 @@ func (h *NetworksHandler) Update(c *gin.Context) {
return return
} }
_ = h.Audit.Log(c.Request.Context(), actorOf(c), "network_interface.update", out.Name, out, h.NodeID) _ = h.Audit.Log(c.Request.Context(), actorOf(c), "network_interface.update", out.Name, out, h.NodeID)
h.applyAsync(c.Request.Context()) h.applyAsync()
response.OK(c, out) response.OK(c, out)
} }
@@ -160,7 +160,7 @@ func (h *NetworksHandler) Delete(c *gin.Context) {
} }
_ = h.Audit.Log(c.Request.Context(), actorOf(c), "network_interface.delete", _ = h.Audit.Log(c.Request.Context(), actorOf(c), "network_interface.delete",
strconv.FormatInt(id, 10), gin.H{"id": id}, h.NodeID) strconv.FormatInt(id, 10), gin.H{"id": id}, h.NodeID)
h.applyAsync(c.Request.Context()) h.applyAsync()
response.NoContent(c) response.NoContent(c)
} }

View File

@@ -484,6 +484,7 @@ APPLYIFACES
Description=EdgeGuard managed network interfaces apply Description=EdgeGuard managed network interfaces apply
After=network-online.target After=network-online.target
Wants=network-online.target Wants=network-online.target
StartLimitIntervalSec=0
[Service] [Service]
Type=oneshot Type=oneshot
@@ -549,6 +550,7 @@ APPLYIP
Description=EdgeGuard managed IP addresses apply Description=EdgeGuard managed IP addresses apply
After=network-online.target edgeguard-interfaces.service After=network-online.target edgeguard-interfaces.service
Wants=network-online.target Wants=network-online.target
StartLimitIntervalSec=0
[Service] [Service]
Type=oneshot Type=oneshot