diff --git a/.changelog/24650.txt b/.changelog/24650.txt new file mode 100644 index 00000000000..5efb4f2330e --- /dev/null +++ b/.changelog/24650.txt @@ -0,0 +1,3 @@ +```release-note:bug +networking: use a tmpfs location for the state of CNI IPAM plugin used by bridge mode, to fix a bug where allocations would fail to restore after host reboot +``` diff --git a/client/allocrunner/cni/bridge.go b/client/allocrunner/cni/bridge.go index 91b438b8e59..5889c2f510d 100644 --- a/client/allocrunner/cni/bridge.go +++ b/client/allocrunner/cni/bridge.go @@ -58,9 +58,10 @@ func NewNomadBridgeConflist(conf NomadBridgeConfig) Conflist { ForceAddress: true, HairpinMode: conf.HairpinMode, Ipam: IPAM{ - Type: "host-local", - Ranges: ipRanges, - Routes: ipRoutes, + Type: "host-local", + Ranges: ipRanges, + Routes: ipRoutes, + DataDir: "/var/run/cni", }, }, Firewall{ diff --git a/client/allocrunner/cni/plugins.go b/client/allocrunner/cni/plugins.go index 091208ca3ba..f31ff9dd605 100644 --- a/client/allocrunner/cni/plugins.go +++ b/client/allocrunner/cni/plugins.go @@ -20,9 +20,10 @@ type Bridge struct { Ipam IPAM `json:"ipam"` } type IPAM struct { - Type string `json:"type"` - Ranges [][]Range `json:"ranges"` - Routes []Route `json:"routes"` + Type string `json:"type"` + Ranges [][]Range `json:"ranges"` + Routes []Route `json:"routes"` + DataDir string `json:"dataDir"` } type Range struct { Subnet string `json:"subnet"` diff --git a/client/allocrunner/test_fixtures/bad_input.conflist.json b/client/allocrunner/test_fixtures/bad_input.conflist.json index f9c9be906ce..9b2bb2fc990 100644 --- a/client/allocrunner/test_fixtures/bad_input.conflist.json +++ b/client/allocrunner/test_fixtures/bad_input.conflist.json @@ -25,7 +25,8 @@ { "dst": "0.0.0.0/0" } - ] + ], + "dataDir": "/var/run/cni" } }, { diff --git a/client/allocrunner/test_fixtures/consul-cni.conflist.json b/client/allocrunner/test_fixtures/consul-cni.conflist.json index 3fe7b270edb..95b7a9c0058 100644 --- a/client/allocrunner/test_fixtures/consul-cni.conflist.json +++ b/client/allocrunner/test_fixtures/consul-cni.conflist.json @@ -25,7 +25,8 @@ { "dst": "0.0.0.0/0" } - ] + ], + "dataDir": "/var/run/cni" } }, { diff --git a/client/allocrunner/test_fixtures/empty.conflist.json b/client/allocrunner/test_fixtures/empty.conflist.json index 484feb44674..7ac34cdf404 100644 --- a/client/allocrunner/test_fixtures/empty.conflist.json +++ b/client/allocrunner/test_fixtures/empty.conflist.json @@ -25,7 +25,8 @@ { "dst": "0.0.0.0/0" } - ] + ], + "dataDir": "/var/run/cni" } }, { diff --git a/client/allocrunner/test_fixtures/hairpin.conflist.json b/client/allocrunner/test_fixtures/hairpin.conflist.json index 1e584c6c115..ba6f276472c 100644 --- a/client/allocrunner/test_fixtures/hairpin.conflist.json +++ b/client/allocrunner/test_fixtures/hairpin.conflist.json @@ -25,7 +25,8 @@ { "dst": "0.0.0.0/0" } - ] + ], + "dataDir": "/var/run/cni" } }, { diff --git a/client/allocrunner/test_fixtures/ipv6.conflist.json b/client/allocrunner/test_fixtures/ipv6.conflist.json index e71afdbe5a7..eb15ada4b12 100644 --- a/client/allocrunner/test_fixtures/ipv6.conflist.json +++ b/client/allocrunner/test_fixtures/ipv6.conflist.json @@ -33,7 +33,8 @@ { "dst": "::/0" } - ] + ], + "dataDir": "/var/run/cni" } }, {