@@ -179,6 +179,43 @@ def run(args):
179179 result = health ._docker_network_headroom (run , network_policy_values (), docker_ok = True )
180180 self .assertEqual (result ["legacy" ], 1 )
181181
182+ def test_builtin_null_ipam_keeps_transactional_health_below_failure (self ) -> None :
183+ networks = {
184+ "bridge" : [{"IPAM" : {"Config" : [{"Subnet" : "198.51.100.0/28" }]}}],
185+ "ci-fleet_default" : [{"IPAM" : {"Config" : [{"Subnet" : "172.18.0.0/16" }]}}],
186+ "host" : [{"IPAM" : {"Config" : None }}],
187+ "none" : [{"IPAM" : {"Config" : None }}],
188+ }
189+
190+ def run (args ):
191+ if args [:3 ] == ["docker" , "network" , "ls" ]:
192+ return health .subprocess .CompletedProcess (args , 0 , "bridge\n ci-fleet_default\n host\n none\n " , "" )
193+ return health .subprocess .CompletedProcess (args , 0 , json .dumps (networks [args [- 1 ]]), "" )
194+
195+ network = health ._docker_network_headroom (run , network_policy_values (), docker_ok = True )
196+ self .assertEqual (
197+ network ,
198+ {"configured" : 16 , "used" : 1 , "free" : 15 , "reserve" : 1 , "legacy" : 1 , "state" : "warning" },
199+ )
200+ report = health .evaluate ({** healthy_snapshot (), "docker_network_headroom" : network }, health .Thresholds ())
201+ self .assertEqual ((report ["status" ], report ["exit_code" ]), ("warning" , 1 ))
202+ self .assertNotIn ("docker_network_inspection" , {check ["id" ] for check in report ["checks" ]})
203+
204+ def test_custom_null_ipam_still_fails_closed (self ) -> None :
205+ def run (args ):
206+ if args [:3 ] == ["docker" , "network" , "ls" ]:
207+ return health .subprocess .CompletedProcess (args , 0 , "custom\n " , "" )
208+ return health .subprocess .CompletedProcess (
209+ args ,
210+ 0 ,
211+ json .dumps ([{"IPAM" : {"Config" : None }}]),
212+ "" ,
213+ )
214+
215+ self .assert_unavailable_network (
216+ health ._docker_network_headroom (run , network_policy_values (), docker_ok = True )
217+ )
218+
182219 def test_overlapping_builtin_bridge_consumes_allocation_without_legacy_warning (self ) -> None :
183220 def run (args ):
184221 if args [:3 ] == ["docker" , "network" , "ls" ]:
0 commit comments