Skip to content

Commit

Permalink
Backport of CNI: use tmpfs location for ipam plugin into release/1.9.x (
Browse files Browse the repository at this point in the history
#24681)

Co-authored-by: Tim Gross <[email protected]>
  • Loading branch information
hc-github-team-nomad-core and tgross authored Dec 16, 2024
1 parent 045cff9 commit 8fe803a
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .changelog/24650.txt
Original file line number Diff line number Diff line change
@@ -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
```
7 changes: 4 additions & 3 deletions client/allocrunner/cni/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
7 changes: 4 additions & 3 deletions client/allocrunner/cni/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
3 changes: 2 additions & 1 deletion client/allocrunner/test_fixtures/bad_input.conflist.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
{
"dst": "0.0.0.0/0"
}
]
],
"dataDir": "/var/run/cni"
}
},
{
Expand Down
3 changes: 2 additions & 1 deletion client/allocrunner/test_fixtures/consul-cni.conflist.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
{
"dst": "0.0.0.0/0"
}
]
],
"dataDir": "/var/run/cni"
}
},
{
Expand Down
3 changes: 2 additions & 1 deletion client/allocrunner/test_fixtures/empty.conflist.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
{
"dst": "0.0.0.0/0"
}
]
],
"dataDir": "/var/run/cni"
}
},
{
Expand Down
3 changes: 2 additions & 1 deletion client/allocrunner/test_fixtures/hairpin.conflist.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
{
"dst": "0.0.0.0/0"
}
]
],
"dataDir": "/var/run/cni"
}
},
{
Expand Down
3 changes: 2 additions & 1 deletion client/allocrunner/test_fixtures/ipv6.conflist.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
{
"dst": "::/0"
}
]
],
"dataDir": "/var/run/cni"
}
},
{
Expand Down

0 comments on commit 8fe803a

Please sign in to comment.