-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(f5-virtualserver): skip endpoint creation when VirtualServer is not ready #4996
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ import ( | |
"context" | ||
"fmt" | ||
"sort" | ||
"strings" | ||
|
||
"github.com/pkg/errors" | ||
log "github.com/sirupsen/logrus" | ||
|
@@ -147,6 +148,12 @@ func (vs *f5VirtualServerSource) endpointsFromVirtualServers(virtualServers []*f | |
var endpoints []*endpoint.Endpoint | ||
|
||
for _, virtualServer := range virtualServers { | ||
if !isVirtualServerReady(virtualServer) { | ||
log.Warnf("F5 VirtualServer %s/%s is not ready or is missing an IP address, skipping endpoint creation.", | ||
virtualServer.Namespace, virtualServer.Name) | ||
continue | ||
} | ||
|
||
resource := fmt.Sprintf("f5-virtualserver/%s/%s", virtualServer.Namespace, virtualServer.Name) | ||
|
||
ttl := getTTLFromAnnotations(virtualServer.Annotations, resource) | ||
|
@@ -155,6 +162,7 @@ func (vs *f5VirtualServerSource) endpointsFromVirtualServers(virtualServers []*f | |
if len(targets) == 0 && virtualServer.Spec.VirtualServerAddress != "" { | ||
targets = append(targets, virtualServer.Spec.VirtualServerAddress) | ||
} | ||
|
||
if len(targets) == 0 && virtualServer.Status.VSAddress != "" { | ||
targets = append(targets, virtualServer.Status.VSAddress) | ||
} | ||
|
@@ -211,3 +219,10 @@ func (vs *f5VirtualServerSource) filterByAnnotations(virtualServers []*f5.Virtua | |
|
||
return filteredList, nil | ||
} | ||
|
||
func isVirtualServerReady(vs *f5.VirtualServer) bool { | ||
normalizedStatus := strings.ToLower(vs.Status.Status) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. potential null pointer as The null check will help to avoid external-dns crashlooping. Ideally the null check should be added in method
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch but AFAICT the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi Looks like missed that piece ;-) If server is empty and created like that, then you right.
If the virtual server created like the one above, is there is is a chance to throw a null pointer panic in helper function
Am I correct or missing something? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for all the review comments, super helpful! 🙏🏻 The |
||
normalizedAddress := strings.ToLower(vs.Status.VSAddress) | ||
|
||
return normalizedStatus == "ok" && (normalizedAddress != "none" && normalizedAddress != "") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a suggestion to use early return, example
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, changed here: a70d5d0 |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a suggestion
^ This will crash if virtualServer is null))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally understand this but we would need to embed the
f5.VirtualServer
struct in our own data type and then add a method to that, in this context it feels a bit overkill? A helperfunc
(as used now) that operates on a*f5.VirtualServer
feels like a good middle ground.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was simply a style suggestion, nice one.