#272 do not sync dhcp if empty IP

This commit is contained in:
bakito
2024-01-14 14:03:04 +01:00
parent 4c1e56ccce
commit 15c651ca96
2 changed files with 17 additions and 7 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ func (c *DhcpStatus) HasConfig() bool {
}
func (j DhcpConfigV4) isValid() bool {
return j.GatewayIp != nil && j.SubnetMask != nil && j.RangeStart != nil && j.RangeEnd != nil
return j.GatewayIp != nil && *j.GatewayIp != "" && j.SubnetMask != nil && j.RangeStart != nil && j.RangeEnd != nil
}
func (j DhcpConfigV6) isValid() bool {
+16 -6
View File
@@ -514,12 +514,14 @@ var _ = Describe("Sync", func() {
Context("actionDHCPServerConfig", func() {
var rsc *model.DhcpStatus
BeforeEach(func() {
ac.origin.dhcpServerConfig = &model.DhcpStatus{V4: &model.DhcpConfigV4{
GatewayIp: utils.Ptr("1.2.3.4"),
RangeStart: utils.Ptr("1.2.3.5"),
RangeEnd: utils.Ptr("1.2.3.6"),
SubnetMask: utils.Ptr("255.255.255.0"),
}}
ac.origin.dhcpServerConfig = &model.DhcpStatus{
V4: &model.DhcpConfigV4{
GatewayIp: utils.Ptr("1.2.3.4"),
RangeStart: utils.Ptr("1.2.3.5"),
RangeEnd: utils.Ptr("1.2.3.6"),
SubnetMask: utils.Ptr("255.255.255.0"),
},
}
rsc = &model.DhcpStatus{}
w.cfg.Features.DHCP.StaticLeases = false
})
@@ -554,6 +556,14 @@ var _ = Describe("Sync", func() {
err := actionDHCPServerConfig(ac)
Ω(err).ShouldNot(HaveOccurred())
})
It("should not sync empty IPv4", func() {
ac.replica.DHCPServerEnabled = utils.Ptr(false)
ac.origin.dhcpServerConfig.V4 = &model.DhcpConfigV4{
GatewayIp: utils.Ptr(""),
}
err := actionDHCPServerConfig(ac)
Ω(err).ShouldNot(HaveOccurred())
})
})
Context("sync", func() {