mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-05 17:16:59 +02:00
This commit is contained in:
parent
827220fe1d
commit
5c14cd23fd
@ -19,6 +19,7 @@ package source
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -141,6 +142,12 @@ func (ts *f5TransportServerSource) endpointsFromTransportServers(transportServer
|
||||
var endpoints []*endpoint.Endpoint
|
||||
|
||||
for _, transportServer := range transportServers {
|
||||
if !isTransportServerReady(transportServer) {
|
||||
log.Warnf("F5 TransportServer %s/%s is not ready or is missing an IP address, skipping endpoint creation.",
|
||||
transportServer.Namespace, transportServer.Name)
|
||||
continue
|
||||
}
|
||||
|
||||
resource := fmt.Sprintf("f5-transportserver/%s/%s", transportServer.Namespace, transportServer.Name)
|
||||
|
||||
ttl := getTTLFromAnnotations(transportServer.Annotations, resource)
|
||||
@ -205,3 +212,12 @@ func (ts *f5TransportServerSource) filterByAnnotations(transportServers []*f5.Tr
|
||||
|
||||
return filteredList, nil
|
||||
}
|
||||
|
||||
func isTransportServerReady(vs *f5.TransportServer) bool {
|
||||
if strings.ToLower(vs.Status.Status) != "ok" {
|
||||
return false
|
||||
}
|
||||
|
||||
normalizedAddress := strings.ToLower(vs.Status.VSAddress)
|
||||
return normalizedAddress != "none" && normalizedAddress != ""
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ func TestF5TransportServerEndpoints(t *testing.T) {
|
||||
},
|
||||
Status: f5.TransportServerStatus{
|
||||
VSAddress: "192.168.1.200",
|
||||
Status: "OK",
|
||||
},
|
||||
},
|
||||
expected: []*endpoint.Endpoint{
|
||||
@ -97,6 +98,7 @@ func TestF5TransportServerEndpoints(t *testing.T) {
|
||||
},
|
||||
Status: f5.TransportServerStatus{
|
||||
VSAddress: "192.168.1.200",
|
||||
Status: "OK",
|
||||
},
|
||||
},
|
||||
expected: []*endpoint.Endpoint{
|
||||
@ -128,6 +130,7 @@ func TestF5TransportServerEndpoints(t *testing.T) {
|
||||
},
|
||||
Status: f5.TransportServerStatus{
|
||||
VSAddress: "192.168.1.100",
|
||||
Status: "OK",
|
||||
},
|
||||
},
|
||||
expected: []*endpoint.Endpoint{
|
||||
@ -182,6 +185,10 @@ func TestF5TransportServerEndpoints(t *testing.T) {
|
||||
Host: "www.example.com",
|
||||
VirtualServerAddress: "192.168.1.100",
|
||||
},
|
||||
Status: f5.TransportServerStatus{
|
||||
VSAddress: "192.168.1.100",
|
||||
Status: "OK",
|
||||
},
|
||||
},
|
||||
expected: []*endpoint.Endpoint{
|
||||
{
|
||||
@ -214,6 +221,10 @@ func TestF5TransportServerEndpoints(t *testing.T) {
|
||||
Host: "www.example.com",
|
||||
VirtualServerAddress: "192.168.1.100",
|
||||
},
|
||||
Status: f5.TransportServerStatus{
|
||||
VSAddress: "192.168.1.100",
|
||||
Status: "OK",
|
||||
},
|
||||
},
|
||||
expected: nil,
|
||||
},
|
||||
@ -235,6 +246,10 @@ func TestF5TransportServerEndpoints(t *testing.T) {
|
||||
Host: "www.example.com",
|
||||
VirtualServerAddress: "192.168.1.100",
|
||||
},
|
||||
Status: f5.TransportServerStatus{
|
||||
VSAddress: "192.168.1.100",
|
||||
Status: "OK",
|
||||
},
|
||||
},
|
||||
expected: []*endpoint.Endpoint{
|
||||
{
|
||||
@ -248,6 +263,57 @@ func TestF5TransportServerEndpoints(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "F5 TransportServer with error status",
|
||||
transportServer: f5.TransportServer{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: f5TransportServerGVR.GroupVersion().String(),
|
||||
Kind: "TransportServer",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-ts",
|
||||
Namespace: defaultF5TransportServerNamespace,
|
||||
Annotations: map[string]string{
|
||||
"external-dns.alpha.kubernetes.io/ttl": "600",
|
||||
},
|
||||
},
|
||||
Spec: f5.TransportServerSpec{
|
||||
Host: "www.example.com",
|
||||
VirtualServerAddress: "192.168.1.100",
|
||||
},
|
||||
Status: f5.TransportServerStatus{
|
||||
VSAddress: "",
|
||||
Status: "ERROR",
|
||||
Error: "Some error status message",
|
||||
},
|
||||
},
|
||||
expected: nil,
|
||||
},
|
||||
{
|
||||
name: "F5 TransportServer with missing IP address and OK status",
|
||||
transportServer: f5.TransportServer{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: f5TransportServerGVR.GroupVersion().String(),
|
||||
Kind: "TransportServer",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-ts",
|
||||
Namespace: defaultF5TransportServerNamespace,
|
||||
Annotations: map[string]string{
|
||||
"external-dns.alpha.kubernetes.io/ttl": "600",
|
||||
},
|
||||
},
|
||||
Spec: f5.TransportServerSpec{
|
||||
Host: "www.example.com",
|
||||
IPAMLabel: "test",
|
||||
},
|
||||
Status: f5.TransportServerStatus{
|
||||
VSAddress: "None",
|
||||
Status: "OK",
|
||||
},
|
||||
},
|
||||
expected: nil,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
|
Loading…
Reference in New Issue
Block a user