VR reports a load balancer change as applied when haproxy.cfg cannot be replaced

Offen Anfängerfreundlich
#14,633 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
78/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python
Bereich
backend, networking

Rechercherichtung

Beginne mit CsLoadBalancer.process() in systemvm/debian/opt/cloud/bin/cs/CsLoadBalancer.py und verfolge, wie das Ergebnis von CsHelper.copy() behandelt wird, nachdem haproxy.cfg.new mit haproxy -c validiert wurde. Prüfe, wie eine fehlgeschlagene Installation an den Konfigurationslauf gemeldet wird, und vergleiche dies anschließend mit dem bestehenden Pfad für fehlgeschlagene Validierungen. Erledigt ist die Aufgabe, wenn ein Installationsfehler dazu führt, dass das Anwenden fehlschlägt, sodass der Management Server ein Rollback durchführen kann.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

problem

When a virtual router can't replace /etc/haproxy/haproxy.cfg, it still reports a load balancer config change as applied.

CsLoadBalancer.process() (systemvm/debian/opt/cloud/bin/cs/CsLoadBalancer.py) writes the new config to haproxy.cfg.new, checks it with haproxy -c, and then installs it with CsHelper.copy(). CsHelper.copy() catches the IOError, logs Could not copy /etc/haproxy/haproxy.cfg.new to /etc/haproxy/haproxy.cfg, and returns. The router then reloads HAProxy, which reads the old file, and the config run ends successfully.

The management server therefore gets a successful answer, records the change as applied, and doesn't roll it back, while the router keeps serving the old configuration. A config that fails haproxy -c already makes the apply fail, so only this path is silent.

versions

4.22 (the code is the same on main).

The steps to reproduce the bug
  1. Create a load balancer rule on an isolated network or VPC served by a virtual router.
  2. On the router, make the config file unwritable, for example chattr +i /etc/haproxy/haproxy.cfg.
  3. Change the rule, for example updateLoadBalancerRule algorithm=leastconn, or add a rule.
  4. The API call succeeds and listLoadBalancerRules shows the new values. The router's /var/log/cloud.log has Could not copy /etc/haproxy/haproxy.cfg.new to /etc/haproxy/haproxy.cfg, and /etc/haproxy/haproxy.cfg still has the old config.
What to do about it?

Fail the apply when the new config can't be installed, the same way as when it fails haproxy -c, so that the management server sees the failure and rolls back.

Vorherrschende Sprache
Java
Sterne
3.1k
Forks
1.4k
Ø Merge
6 T. 20 Std.
Gemergte PRs (30 T.)
17

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus apache/cloudstack

Alle Issues in apache/cloudstack

Ähnliche Issues

Weitere Issues zu Java

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.