1
0
Fork 0

Merge branch v3.5 into master

This commit is contained in:
romain 2025-10-23 11:37:09 +02:00
commit d1f46cb02b
21 changed files with 400 additions and 239 deletions

View file

@ -41,9 +41,6 @@ func (h *otelLoggerHook) Run(e *zerolog.Event, level zerolog.Level, message stri
return
}
// Discard the event to avoid double logging.
e.Discard()
var record otellog.Record
record.SetTimestamp(time.Now().UTC())
record.SetSeverity(otelLogSeverity(level))

View file

@ -11,6 +11,7 @@ import (
"net/url"
"os"
"reflect"
"slices"
"sort"
"strconv"
"strings"
@ -656,9 +657,8 @@ func (p *Provider) resolveDefaultCertificate(ctx context.Context, domains []stri
p.resolvingDomainsMutex.Lock()
sortedDomains := make([]string, len(domains))
copy(sortedDomains, domains)
sort.Strings(sortedDomains)
sortedDomains := slices.Clone(domains)
slices.Sort(sortedDomains)
domainKey := strings.Join(sortedDomains, ",")

View file

@ -53,12 +53,18 @@ func TestShutdownUDPConn(t *testing.T) {
// Start sending packets, to create a "session" with the server.
requireEcho(t, "TEST", conn, time.Second)
shutdownStartedChan := make(chan struct{})
doneChan := make(chan struct{})
go func() {
close(shutdownStartedChan)
entryPoint.Shutdown(t.Context())
close(doneChan)
}()
// Wait until shutdown has started, and hopefully after 100 ms the listener has stopped accepting new sessions.
<-shutdownStartedChan
time.Sleep(100 * time.Millisecond)
// Make sure that our session is still live even after the shutdown.
requireEcho(t, "TEST2", conn, time.Second)

View file

@ -53,7 +53,7 @@ func (K8sAttributesDetector) Detect(ctx context.Context) (*resource.Resource, er
podNamespace := string(podNamespaceBytes)
pod, err := client.CoreV1().Pods(podNamespace).Get(ctx, podName, metav1.GetOptions{})
if err != nil && kerror.IsForbidden(err) {
if err != nil && (kerror.IsForbidden(err) || kerror.IsNotFound(err)) {
log.Error().Err(err).Msg("Unable to build K8s resource attributes for Traefik pod")
return resource.Empty(), nil
}

View file

@ -1,11 +1,9 @@
package udp
import (
"crypto/rand"
"errors"
"io"
"net"
"runtime"
"testing"
"time"
@ -303,58 +301,6 @@ func TestShutdown(t *testing.T) {
}
}
func TestReadLoopMaxDataSize(t *testing.T) {
if runtime.GOOS == "darwin" {
// sudo sysctl -w net.inet.udp.maxdgram=65507
t.Skip("Skip test on darwin as the maximum dgram size is set to 9216 bytes by default")
}
// Theoretical maximum size of data in a UDP datagram.
// 65535 8 (UDP header) 20 (IP header).
dataSize := 65507
doneCh := make(chan struct{})
l, err := Listen(net.ListenConfig{}, "udp", ":0", 3*time.Second)
require.NoError(t, err)
defer func() {
err := l.Close()
require.NoError(t, err)
}()
go func() {
defer close(doneCh)
conn, err := l.Accept()
require.NoError(t, err)
buffer := make([]byte, dataSize)
n, err := conn.Read(buffer)
require.NoError(t, err)
assert.Equal(t, dataSize, n)
}()
c, err := net.Dial("udp", l.Addr().String())
require.NoError(t, err)
data := make([]byte, dataSize)
_, err = rand.Read(data)
require.NoError(t, err)
_, err = c.Write(data)
require.NoError(t, err)
select {
case <-doneCh:
case <-time.Tick(5 * time.Second):
t.Fatal("Timeout waiting for datagram read")
}
}
// requireEcho tests that the conn session is live and functional,
// by writing data through it, and expecting the same data as a response when reading on it.
// It fatals if the read blocks longer than timeout,