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

Commit

Permalink
Re-add health check components
Browse files Browse the repository at this point in the history
Re-add health check monitor and queue, as well as reconciler to policy
controller. These components were removed accidentally as part of the
separation of controllers
  • Loading branch information
sergioifg94 committed Dec 4, 2023
1 parent f93bb55 commit 60a4c75
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
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

0 comments on commit 60a4c75

Please sign in to comment.