File tree Expand file tree Collapse file tree 4 files changed +32
-20
lines changed Expand file tree Collapse file tree 4 files changed +32
-20
lines changed Original file line number Diff line number Diff line change @@ -145,8 +145,8 @@ func (ts *f5TransportServerSource) endpointsFromTransportServers(transportServer
145145 var endpoints []* endpoint.Endpoint
146146
147147 for _ , transportServer := range transportServers {
148- if ! isTransportServerReady (transportServer ) {
149- log .Warnf ("F5 TransportServer %s/%s is not ready or is missing an IP address, skipping endpoint creation." ,
148+ if ! hasValidTransportServerIP (transportServer ) {
149+ log .Warnf ("F5 TransportServer %s/%s is missing a valid IP address, skipping endpoint creation." ,
150150 transportServer .Namespace , transportServer .Name )
151151 continue
152152 }
@@ -213,11 +213,7 @@ func (ts *f5TransportServerSource) filterByAnnotations(transportServers []*f5.Tr
213213 return filteredList , nil
214214}
215215
216- func isTransportServerReady (vs * f5.TransportServer ) bool {
217- if strings .ToLower (vs .Status .Status ) != "ok" {
218- return false
219- }
220-
216+ func hasValidTransportServerIP (vs * f5.TransportServer ) bool {
221217 normalizedAddress := strings .ToLower (vs .Status .VSAddress )
222218 return normalizedAddress != "none" && normalizedAddress != ""
223219}
Original file line number Diff line number Diff line change @@ -265,7 +265,7 @@ func TestF5TransportServerEndpoints(t *testing.T) {
265265 },
266266 },
267267 {
268- name : "F5 TransportServer with error status" ,
268+ name : "F5 TransportServer with error status but valid IP " ,
269269 transportServer : f5.TransportServer {
270270 TypeMeta : metav1.TypeMeta {
271271 APIVersion : f5TransportServerGVR .GroupVersion ().String (),
@@ -283,12 +283,22 @@ func TestF5TransportServerEndpoints(t *testing.T) {
283283 VirtualServerAddress : "192.168.1.100" ,
284284 },
285285 Status : f5.CustomResourceStatus {
286- VSAddress : "" ,
286+ VSAddress : "192.168.1.100 " ,
287287 Status : "ERROR" ,
288288 Error : "Some error status message" ,
289289 },
290290 },
291- expected : nil ,
291+ expected : []* endpoint.Endpoint {
292+ {
293+ DNSName : "www.example.com" ,
294+ Targets : []string {"192.168.1.100" },
295+ RecordType : endpoint .RecordTypeA ,
296+ RecordTTL : 600 ,
297+ Labels : endpoint.Labels {
298+ "resource" : "f5-transportserver/transportserver/test-ts" ,
299+ },
300+ },
301+ },
292302 },
293303 {
294304 name : "F5 TransportServer with missing IP address and OK status" ,
Original file line number Diff line number Diff line change @@ -150,8 +150,8 @@ func (vs *f5VirtualServerSource) endpointsFromVirtualServers(virtualServers []*f
150150 var endpoints []* endpoint.Endpoint
151151
152152 for _ , virtualServer := range virtualServers {
153- if ! isVirtualServerReady (virtualServer ) {
154- log .Warnf ("F5 VirtualServer %s/%s is not ready or is missing an IP address, skipping endpoint creation." ,
153+ if ! hasValidVirtualServerIP (virtualServer ) {
154+ log .Warnf ("F5 VirtualServer %s/%s is missing a valid IP address, skipping endpoint creation." ,
155155 virtualServer .Namespace , virtualServer .Name )
156156 continue
157157 }
@@ -219,11 +219,7 @@ func (vs *f5VirtualServerSource) filterByAnnotations(virtualServers []*f5.Virtua
219219 return filteredList , nil
220220}
221221
222- func isVirtualServerReady (vs * f5.VirtualServer ) bool {
223- if strings .ToLower (vs .Status .Status ) != "ok" {
224- return false
225- }
226-
222+ func hasValidVirtualServerIP (vs * f5.VirtualServer ) bool {
227223 normalizedAddress := strings .ToLower (vs .Status .VSAddress )
228224 return normalizedAddress != "none" && normalizedAddress != ""
229225}
Original file line number Diff line number Diff line change @@ -265,7 +265,7 @@ func TestF5VirtualServerEndpoints(t *testing.T) {
265265 },
266266 },
267267 {
268- name : "F5 VirtualServer with error status" ,
268+ name : "F5 VirtualServer with error status but valid IP " ,
269269 virtualServer : f5.VirtualServer {
270270 TypeMeta : metav1.TypeMeta {
271271 APIVersion : f5VirtualServerGVR .GroupVersion ().String (),
@@ -283,12 +283,22 @@ func TestF5VirtualServerEndpoints(t *testing.T) {
283283 VirtualServerAddress : "192.168.1.100" ,
284284 },
285285 Status : f5.CustomResourceStatus {
286- VSAddress : "" ,
286+ VSAddress : "192.168.1.100 " ,
287287 Status : "ERROR" ,
288288 Error : "Some error status message" ,
289289 },
290290 },
291- expected : nil ,
291+ expected : []* endpoint.Endpoint {
292+ {
293+ DNSName : "www.example.com" ,
294+ Targets : []string {"192.168.1.100" },
295+ RecordType : endpoint .RecordTypeA ,
296+ RecordTTL : 600 ,
297+ Labels : endpoint.Labels {
298+ "resource" : "f5-virtualserver/virtualserver/test-vs" ,
299+ },
300+ },
301+ },
292302 },
293303 {
294304 name : "F5 VirtualServer with missing IP address and OK status" ,
You can’t perform that action at this time.
0 commit comments