From 2c1279c5aff48e0b2bef0f64d1f20d7c4869d3a1 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Sat, 24 Oct 2026 17:30:38 +0200 Subject: [PATCH] =?UTF-8?q?f-85:=20config:=20dhcp.backend=20vaut=20two=20p?= =?UTF-8?q?ar=20d=C3=A9faut,=20dnsmasq=20sur=20d=C3=A9claration=20explicit?= =?UTF-8?q?e,=20mise=20=C3=A0=20jour=20depuis=20la=200.1.0=20document?= =?UTF-8?q?=C3=A9e=20#85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: GnomeZworc --- conf/agent/config.exemple.yml | 2 +- docs/demarrage/installation.rst | 6 +++--- docs/exploitation/configuration.rst | 8 +++++--- internal/config/agent/dhcp_test.go | 18 +++++++++--------- internal/config/agent/struct.go | 2 +- release_notes/0.2.0.md | 12 ++++++++---- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/conf/agent/config.exemple.yml b/conf/agent/config.exemple.yml index 077f1d9..3d95b94 100644 --- a/conf/agent/config.exemple.yml +++ b/conf/agent/config.exemple.yml @@ -68,7 +68,7 @@ metadata: # The per-subnet control socket and state file live in /run/two/dhcp, which is # not configurable: the wrapper script hardcodes it too. dhcp: - backend: dnsmasq + backend: two # QEMU runtime paths qemu: diff --git a/docs/demarrage/installation.rst b/docs/demarrage/installation.rst index e4a5b2a..32223e6 100644 --- a/docs/demarrage/installation.rst +++ b/docs/demarrage/installation.rst @@ -80,9 +80,9 @@ démarrage, la racine étant en tmpfs. ``qemu-utils`` est demandé explicitement **masqué** : il prendrait le port 53 en concurrence des instances ``dnsmasq@`` que l'agent lance dans les netns. -``dnsmasq`` reste installé même avec ``dhcp.backend: two`` : le backend intégré ne le remplace que -pour les subnets créés après la bascule, et le paquet est nécessaire tant qu'un hyperviseur peut -revenir en arrière. Voir :doc:`/exploitation/configuration`. +``dnsmasq`` reste installé bien que ``dhcp.backend`` vaille ``two`` par défaut : le paquet sert +aux hyperviseurs qui déclarent ``dhcp.backend: dnsmasq``, et tant qu'un hyperviseur peut revenir +en arrière. Voir :doc:`/exploitation/configuration`. **Noyau** — chargement de ``br_netfilter``, puis ``net.ipv4.ip_forward = 1`` et ``net.bridge.bridge-nf-call-iptables = 1``. Cette dernière clé est **requise** par la DNAT vers diff --git a/docs/exploitation/configuration.rst b/docs/exploitation/configuration.rst index c05aad7..30cb353 100644 --- a/docs/exploitation/configuration.rst +++ b/docs/exploitation/configuration.rst @@ -188,7 +188,7 @@ Backend DHCP .. code-block:: yaml dhcp: - backend: dnsmasq # ou two + backend: two # ou dnsmasq Choisit qui sert le DHCP des subnets **créés par cet agent** : @@ -206,8 +206,10 @@ Choisit qui sert le DHCP des subnets **créés par cet agent** : - le binaire ``dhcp``, piloté par socket Unix - ``dhcp@_`` -Le défaut est ``dnsmasq`` : un fichier de configuration de la 0.1.0, non modifié, se comporte -exactement comme avant. Toute autre valeur que ``dnsmasq`` ou ``two`` fait échouer le démarrage. +Le défaut est ``two``. Un hyperviseur mis à jour depuis la 0.1.0 avec des subnets existants doit +déclarer ``backend: dnsmasq`` avant la mise à jour, ou être vidé puis basculé (voir plus bas) : ses +subnets restent servis par dnsmasq. Toute autre valeur que ``dnsmasq`` ou ``two`` fait échouer le +démarrage. Le répertoire d'exécution du backend ``two`` — ``/run/two/dhcp`` — **n'est pas configurable** : le script d'enrobage le code en dur, une clé que lui ignorerait serait un mensonge. diff --git a/internal/config/agent/dhcp_test.go b/internal/config/agent/dhcp_test.go index 50fed1c..88926de 100644 --- a/internal/config/agent/dhcp_test.go +++ b/internal/config/agent/dhcp_test.go @@ -31,27 +31,27 @@ func TestValidBackend_RejectsAnythingElse(t *testing.T) { } } -func TestLoadConfig_DefaultsToDnsmasq(t *testing.T) { +func TestLoadConfig_DefaultsToTwo(t *testing.T) { path := writeConfig(t, "database:\n path: /tmp/two\n") cfg, err := LoadConfig(path) if err != nil { t.Fatalf("LoadConfig: %v", err) } - if cfg.DHCP.Backend != BackendDnsmasq { - t.Errorf("backend = %q, want %q: a 0.1.0 config must keep behaving as before", cfg.DHCP.Backend, BackendDnsmasq) + if cfg.DHCP.Backend != "two" { + t.Errorf("backend = %q, want two: the built-in server is the default since 0.2.0", cfg.DHCP.Backend) } } -func TestLoadConfig_ReadsTheTwoBackend(t *testing.T) { - path := writeConfig(t, "dhcp:\n backend: two\n") +func TestLoadConfig_ReadsTheDnsmasqBackend(t *testing.T) { + path := writeConfig(t, "dhcp:\n backend: dnsmasq\n") cfg, err := LoadConfig(path) if err != nil { t.Fatalf("LoadConfig: %v", err) } - if cfg.DHCP.Backend != BackendTwo { - t.Errorf("backend = %q, want two", cfg.DHCP.Backend) + if cfg.DHCP.Backend != "dnsmasq" { + t.Errorf("backend = %q, want dnsmasq: an explicit dnsmasq must survive the new default", cfg.DHCP.Backend) } } @@ -76,7 +76,7 @@ func TestLoadConfig_MissingFileStillFallsBackToDefaults(t *testing.T) { if err != nil { t.Fatalf("an absent file remains valid, only an unreadable one is an error: %v", err) } - if cfg.DHCP.Backend != BackendDnsmasq { - t.Errorf("backend = %q, want %q", cfg.DHCP.Backend, BackendDnsmasq) + if cfg.DHCP.Backend != "two" { + t.Errorf("backend = %q, want two", cfg.DHCP.Backend) } } diff --git a/internal/config/agent/struct.go b/internal/config/agent/struct.go index 86a6fd7..1381d2f 100644 --- a/internal/config/agent/struct.go +++ b/internal/config/agent/struct.go @@ -76,7 +76,7 @@ func LoadConfig(path string) (*Config, error) { v.SetDefault("dispatcher.timeout_seconds", 300) v.SetDefault("dispatcher.poll_seconds", 2) v.SetDefault("metadata.run_dir", "/run/two/metadata") - v.SetDefault("dhcp.backend", BackendDnsmasq) + v.SetDefault("dhcp.backend", BackendTwo) v.SetDefault("qemu.ovmf_code_path", "/usr/share/OVMF/OVMF_CODE.fd") v.SetDefault("qemu.ovmf_vars_template", "/usr/share/OVMF/OVMF_VARS.fd") v.SetDefault("qemu.uefi_vars_dir", "/run/two/vms/uefi") diff --git a/release_notes/0.2.0.md b/release_notes/0.2.0.md index 91c55a5..ff32269 100644 --- a/release_notes/0.2.0.md +++ b/release_notes/0.2.0.md @@ -26,8 +26,7 @@ L3VNI, avec une configuration BGP pilotée par l'agent ; documentation du projet **Coexistence avec dnsmasq** - Nouvelle clé `dhcp.backend`, `dnsmasq` ou `two`, qui choisit le serveur des subnets **créés par - cet agent**. Le défaut est `dnsmasq` : un fichier de configuration de la 0.1.0, non modifié, se - comporte exactement comme avant + cet agent**. Le défaut est `two` (#85) ; `dnsmasq` reste disponible jusqu'à son retrait (#49) - La bascule est une **opération manuelle** sur un hyperviseur vide — l'option ne migre rien, un subnet déjà créé reste servi par le serveur qui l'a été. La procédure est documentée - Toute valeur autre que `dnsmasq` ou `two` fait échouer le démarrage de l'agent @@ -199,8 +198,8 @@ curl -O https://git.g3e.fr/syonad/two/raw/branch/main/scripts/deploy.sh bash ./deploy.sh -t 0.2.0 ``` -Sans `dhcp.backend` ni `bgp` dans `/etc/two/agent.yml`, le comportement est celui de la 0.1.0, à -cinq exceptions près ; les quatre premières touchent les appelants de l'API : +Sans `bgp` dans `/etc/two/agent.yml`, le comportement est celui de la 0.1.0, à six exceptions +près ; les quatre premières touchent les appelants de l'API : - **`interface_ip` ne se fournit plus pour un subnet `vxlan`** : il est refusé (400), l'agent le calcule. Le retirer des appels de création, et ne plus placer de VM sur les deux dernières @@ -216,6 +215,11 @@ cinq exceptions près ; les quatre premières touchent les appelants de l'API : l'underlay à 9000, ou poser `network.allow_mtu_underlay_below_9000: true` — sous 1550, il faut aussi abaisser `network.mtu_vm` avec `allow_mtu_vm_below_1500`. Les subnets existants gardent leurs interfaces à 1500 jusqu'à leur recréation +- **le DHCP passe par défaut au serveur intégré** (`dhcp.backend: two`) : sur un hyperviseur qui a + déjà des subnets, ajouter `dhcp.backend: dnsmasq` à `/etc/two/agent.yml` **avant** + `deploy.sh -t 0.2.0`. Sinon ses subnets restent servis par dnsmasq pendant que l'agent s'adresse + au serveur intégré : les VM existantes continuent, les nouvelles n'obtiennent pas d'adresse. + Un hyperviseur vide n'a rien à faire Les subnets `vxlan` existants gardent leur adressage et le modèle précédent (gateway sur le bridge) jusqu'à leur recréation. Les subnets `bridge` existants restent sans le confinement de