Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

#703: Re-add health check components #706

Merged
merged 1 commit into from
Dec 4, 2023
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
25 changes: 25 additions & 0 deletions cmd/policy_controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main
import (
"flag"
"os"
"time"

certmanv1 "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
clusterv1 "open-cluster-management.io/api/cluster/v1"
Expand All @@ -37,11 +38,13 @@ import (
"github.com/kuadrant/kuadrant-operator/pkg/reconcilers"

"github.com/Kuadrant/multicluster-gateway-controller/pkg/apis/v1alpha1"
"github.com/Kuadrant/multicluster-gateway-controller/pkg/controllers/dnshealthcheckprobe"
"github.com/Kuadrant/multicluster-gateway-controller/pkg/controllers/dnspolicy"
"github.com/Kuadrant/multicluster-gateway-controller/pkg/controllers/dnsrecord"
"github.com/Kuadrant/multicluster-gateway-controller/pkg/controllers/managedzone"
"github.com/Kuadrant/multicluster-gateway-controller/pkg/controllers/tlspolicy"
"github.com/Kuadrant/multicluster-gateway-controller/pkg/dns/dnsprovider"
"github.com/Kuadrant/multicluster-gateway-controller/pkg/health"
)

var (
Expand Down Expand Up @@ -94,6 +97,19 @@ func main() {
}
provider := dnsprovider.NewProvider(mgr.GetClient())

healthMonitor := health.NewMonitor()
healthCheckQueue := health.NewRequestQueue(time.Second * 5)

if err := mgr.Add(healthMonitor); err != nil {
setupLog.Error(err, "unable to start health monitor")
os.Exit(1)
}

if err := mgr.Add(healthCheckQueue); err != nil {
setupLog.Error(err, "unable to start health check queue")
os.Exit(1)
}

if err = (&dnsrecord.DNSRecordReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Expand All @@ -118,6 +134,15 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "DNSPolicy")
os.Exit(1)
}

if err = (&dnshealthcheckprobe.DNSHealthCheckProbeReconciler{
Client: mgr.GetClient(),
HealthMonitor: healthMonitor,
Queue: healthCheckQueue,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "DNSHealthCheckProbe")
os.Exit(1)
}
//+kubebuilder:scaffold:builder

tlsPolicyBaseReconciler := reconcilers.NewBaseReconciler(
Expand Down
1 change: 1 addition & 0 deletions pkg/health/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func NewMonitor() *Monitor {

func (m *Monitor) Start(ctx context.Context) error {
logger := log.FromContext(ctx)
logger.V(3).Info("Starting health check monitor")

<-ctx.Done()
m.mux.Lock()
Expand Down
2 changes: 2 additions & 0 deletions pkg/health/probeQueuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ func (p *ProbeQueuer) Start() {
p.cancel = cancel
p.logger = log.FromContext(ctx)

p.logger.V(3).Info("Starting probe queuer", "id", p.ID)

go func() {
for {
select {
Expand Down
3 changes: 3 additions & 0 deletions pkg/health/queuedProbeWorker.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (q *QueuedProbeWorker) EnqueueCheck(req HealthRequest) {
q.mux.Lock()
defer q.mux.Unlock()

q.logger.V(3).Info("enqueueing health check", "request", req)
q.requests = append(q.requests, req)
}

Expand Down Expand Up @@ -90,6 +91,7 @@ func (q *QueuedProbeWorker) dequeue(ctx context.Context) (HealthRequest, bool) {

func (q *QueuedProbeWorker) Start(ctx context.Context) error {
q.logger = log.FromContext(ctx)
q.logger.V(3).Info("Starting health check queue")
defer q.logger.Info("Stopping health check queue")

for {
Expand All @@ -100,6 +102,7 @@ func (q *QueuedProbeWorker) Start(ctx context.Context) error {
}
return nil
case <-time.After(q.Throttle):
q.logger.V(3).Info("dequeing health check")
req, ok := q.dequeue(ctx)
if !ok {
return nil
Expand Down
Loading