mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2026-05-05 14:46:10 +02:00
fix(node): logger test fixed (#5232)
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
This commit is contained in:
parent
67119e0aac
commit
3fa5fc23b7
@ -33,6 +33,8 @@ import (
|
||||
"sigs.k8s.io/external-dns/endpoint"
|
||||
)
|
||||
|
||||
const warningMsg = "The default behavior of exposing internal IPv6 addresses will change in the next minor version. Use --no-expose-internal-ipv6 flag to opt-in to the new behavior."
|
||||
|
||||
type nodeSource struct {
|
||||
client kubernetes.Interface
|
||||
annotationFilter string
|
||||
@ -189,6 +191,7 @@ func (ns *nodeSource) nodeAddresses(node *v1.Node) ([]string, error) {
|
||||
|
||||
if len(addresses[v1.NodeExternalIP]) > 0 {
|
||||
if ns.exposeInternalIPV6 {
|
||||
log.Warn(warningMsg)
|
||||
return append(addresses[v1.NodeExternalIP], internalIpv6Addresses...), nil
|
||||
}
|
||||
return addresses[v1.NodeExternalIP], nil
|
||||
|
||||
@ -17,10 +17,12 @@ limitations under the License.
|
||||
package source
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"sigs.k8s.io/external-dns/internal/testutils"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -501,11 +503,9 @@ func testNodeEndpointsWithIPv6(t *testing.T) {
|
||||
_, err := kubernetes.CoreV1().Nodes().Create(context.Background(), node, metav1.CreateOptions{})
|
||||
require.NoError(t, err)
|
||||
|
||||
var buf *bytes.Buffer
|
||||
if tc.exposeInternalIPv6 {
|
||||
buf := testutils.LogsToBuffer(log.WarnLevel, t)
|
||||
warningMsg := "The default behavior of exposing internal IPv6 addresses will change in the next minor version. Use --no-expose-internal-ipv6 flag to opt-in to the new behavior."
|
||||
log.Warn(warningMsg)
|
||||
assert.Contains(t, buf.String(), warningMsg)
|
||||
buf = testutils.LogsToBuffer(log.WarnLevel, t)
|
||||
}
|
||||
|
||||
// Create our object under test and get the endpoints.
|
||||
@ -524,6 +524,10 @@ func testNodeEndpointsWithIPv6(t *testing.T) {
|
||||
require.Error(t, err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
|
||||
if tc.exposeInternalIPv6 && buf != nil {
|
||||
assert.Contains(t, buf.String(), warningMsg)
|
||||
}
|
||||
}
|
||||
|
||||
// Validate returned endpoints against desired endpoints.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user