Skip to content

Commit 3bc8aca

Browse files
committed
feat: support conditional start of IPv6 dns servers
This PR does those things: - [x] Refactored `DNSResolveCacheController`. Most of the logic moved to `dns` package types. Simplify and streamline logic. - [x] Replace most of the goroutine orchestration with suture package. - [x] Support per-item reaction to the dns listeners/servers failing to start. This allows us to ignore IPv6 errors if it's disabled. - [x] Support per-item reaction to the dns listeners/servers failing to stop. - [ ] Raise IPv6 listener on link-local address for dns (both TCP and UDP). - [ ] Update kubelet's `resolv.conf` IPv4/IPv6 endpoints. Closes siderolabs#9384 Signed-off-by: Dmitriy Matrenichev <[email protected]>
1 parent 1800f81 commit 3bc8aca

File tree

20 files changed

+1556
-1079
lines changed

20 files changed

+1556
-1079
lines changed

api/resource/definitions/network/network.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ message HostDNSConfigSpec {
114114
repeated common.NetIPPort listen_addresses = 2;
115115
common.NetIP service_host_dns_address = 3;
116116
bool resolve_member_names = 4;
117+
common.NetIP service_host_dns_address_v6 = 5;
117118
}
118119

119120
// HostnameSpecSpec describes node hostname.

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ require (
171171
github.com/spf13/cobra v1.8.1
172172
github.com/spf13/pflag v1.0.5
173173
github.com/stretchr/testify v1.9.0
174+
github.com/thejerf/suture/v4 v4.0.5
174175
github.com/u-root/u-root v0.14.0
175176
github.com/ulikunitz/xz v0.5.12
176177
github.com/vmware/vmw-guestinfo v0.0.0-20220317130741-510905f0efa3

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
732732
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
733733
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI=
734734
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
735+
github.com/thejerf/suture/v4 v4.0.5 h1:F1E/4FZwXWqvlWDKEUo6/ndLtxGAUzMmNqkrMknZbAA=
736+
github.com/thejerf/suture/v4 v4.0.5/go.mod h1:gu9Y4dXNUWFrByqRt30Rm9/UZ0wzRSt9AJS6xu/ZGxU=
735737
github.com/u-root/u-root v0.14.0 h1:Ka4T10EEML7dQ5XDvO9c3MBN8z4nuSnGjcd1jmU2ivg=
736738
github.com/u-root/u-root v0.14.0/go.mod h1:hAyZorapJe4qzbLWlAkmSVCJGbfoU9Pu4jpJ1WMluqE=
737739
github.com/u-root/uio v0.0.0-20240224005618-d2acac8f3701 h1:pyC9PaHYZFgEKFdlp3G8RaCKgVpHZnecvArXvPXcFkM=

internal/app/machined/pkg/controllers/network/address_spec_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"golang.org/x/sys/unix"
2929

3030
netctrl "github.com/siderolabs/talos/internal/app/machined/pkg/controllers/network"
31+
"github.com/siderolabs/talos/pkg/machinery/constants"
3132
"github.com/siderolabs/talos/pkg/machinery/nethelpers"
3233
"github.com/siderolabs/talos/pkg/machinery/resources/network"
3334
)
@@ -170,6 +171,47 @@ func (suite *AddressSpecSuite) TestLoopback() {
170171
suite.Require().NoError(suite.state.Destroy(suite.ctx, loopback.Metadata()))
171172
}
172173

174+
func (suite *AddressSpecSuite) TestIPV6ULA() {
175+
loopback := network.NewAddressSpec(network.NamespaceName, "lo/"+constants.HostDNSAddressV6+"/128")
176+
*loopback.TypedSpec() = network.AddressSpecSpec{
177+
Address: netip.MustParsePrefix(constants.HostDNSAddressV6 + "/128"),
178+
LinkName: "lo",
179+
Family: nethelpers.FamilyInet6,
180+
Scope: nethelpers.ScopeGlobal,
181+
ConfigLayer: network.ConfigDefault,
182+
Flags: nethelpers.AddressFlags(nethelpers.AddressPermanent),
183+
}
184+
185+
for _, res := range []resource.Resource{loopback} {
186+
suite.Require().NoError(suite.state.Create(suite.ctx, res), "%v", res.Spec())
187+
}
188+
189+
suite.Assert().NoError(
190+
retry.Constant(3*time.Second, retry.WithUnits(100*time.Millisecond)).Retry(
191+
func() error {
192+
return suite.assertLinkAddress("lo", constants.HostDNSAddressV6+"/128")
193+
},
194+
),
195+
)
196+
197+
// teardown the address
198+
for {
199+
ready, err := suite.state.Teardown(suite.ctx, loopback.Metadata())
200+
suite.Require().NoError(err)
201+
202+
if ready {
203+
break
204+
}
205+
206+
time.Sleep(100 * time.Millisecond)
207+
}
208+
209+
// torn down address should be removed immediately
210+
suite.Assert().NoError(suite.assertNoLinkAddress("lo", constants.HostDNSAddressV6+"/128"))
211+
212+
suite.Require().NoError(suite.state.Destroy(suite.ctx, loopback.Metadata()))
213+
}
214+
173215
func (suite *AddressSpecSuite) TestDummy() {
174216
dummyInterface := suite.uniqueDummyInterface()
175217

0 commit comments

Comments
 (0)