mirror of
https://github.com/siderolabs/talos.git
synced 2025-11-05 19:01:14 +01:00
This PR adds a new controller - `DNSServerController` that starts tcp and udp dns servers locally. Just like `EtcFileController` it monitors `ResolverStatusType` and updates the list of destinations from there. Most of the caching logic is in our "lobotomized" "`CoreDNS` fork. We need this fork because default `CoreDNS` carries full Caddy server and various other modules that we don't need in Talos. On our side we implement random selection of the actual dns and request forwarding. Closes #7693 Signed-off-by: Dmitriy Matrenichev <dmitry.matrenichev@siderolabs.com>
34 lines
794 B
Go
34 lines
794 B
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package ctxutil_test
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/siderolabs/talos/internal/pkg/ctxutil"
|
|
)
|
|
|
|
func TestStartFn(t *testing.T) {
|
|
ctx := ctxutil.MonitorFn(context.Background(), func() error { return nil })
|
|
|
|
<-ctx.Done()
|
|
|
|
require.Equal(t, context.Canceled, ctx.Err())
|
|
require.Nil(t, ctxutil.Cause(ctx))
|
|
|
|
myErr := errors.New("my error")
|
|
|
|
ctx = ctxutil.MonitorFn(context.Background(), func() error { return myErr })
|
|
|
|
<-ctx.Done()
|
|
|
|
require.Equal(t, context.Canceled, ctx.Err())
|
|
require.Equal(t, myErr, ctxutil.Cause(ctx))
|
|
}
|