Skip to content
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

Compute health of applications only once #1777

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions controllers/dnsupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,9 @@ func (r *GslbReconciler) gslbDNSEndpoint(gslb *k8gbv1beta1.Gslb) (*externaldns.D
var gslbHosts []*externaldns.Endpoint
var ttl = externaldns.TTL(gslb.Spec.Strategy.DNSTtlSeconds)

serviceHealth, err := r.getServiceHealthStatus(gslb)
if err != nil {
return nil, err
}

localTargets := gslb.Status.LoadBalancer.ExposedIPs

for host, health := range serviceHealth {
for host, health := range gslb.Status.ServiceHealth {
var finalTargets = assistant.NewTargets()

if !strings.Contains(host, r.Config.EdgeDNSZone) {
Expand Down Expand Up @@ -149,7 +144,7 @@ func (r *GslbReconciler) gslbDNSEndpoint(gslb *k8gbv1beta1.Gslb) (*externaldns.D
Spec: dnsEndpointSpec,
}

err = controllerutil.SetControllerReference(gslb, dnsEndpoint, r.Scheme)
err := controllerutil.SetControllerReference(gslb, dnsEndpoint, r.Scheme)
if err != nil {
return nil, err
}
Expand Down
8 changes: 8 additions & 0 deletions controllers/gslb_controller_reconciliation.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@ func (r *GslbReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
Str("gslb", gslb.Name).
Msg("Resolved LoadBalancer and Server configuration referenced by Ingress")

// == health status of applications ==
serviceHealth, err := r.getServiceHealthStatus(gslb)
if err != nil {
m.IncrementError(gslb)
return result.RequeueError(err)
}
gslb.Status.ServiceHealth = serviceHealth

// == external-dns dnsendpoints CRs ==
dnsEndpoint, err := r.gslbDNSEndpoint(gslb)
if err != nil {
Expand Down
7 changes: 1 addition & 6 deletions controllers/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,10 @@ import (
)

func (r *GslbReconciler) updateGslbStatus(gslb *k8gbv1beta1.Gslb, ep *externaldns.DNSEndpoint) error {
var err error

gslb.Status.ServiceHealth, err = r.getServiceHealthStatus(gslb)
if err != nil {
return err
}

m.UpdateIngressHostsPerStatusMetric(gslb, gslb.Status.ServiceHealth)

var err error
gslb.Status.HealthyRecords, err = r.getHealthyRecords(gslb)
if err != nil {
return err
Expand Down
Loading