From 43db02d553b7c50f44df6c7a3a81a18a6d7235a0 Mon Sep 17 00:00:00 2001 From: Feny Mehta Date: Wed, 10 Apr 2024 17:20:31 +0530 Subject: [PATCH] KUBESAW-12: Convert the health-check goroutine into ToolchainCluster controller Signed-off-by: Feny Mehta --- go.mod | 2 ++ go.sum | 4 ++-- main.go | 17 ++++++++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 49bcdab4..c68e9d82 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,7 @@ module github.com/codeready-toolchain/member-operator +replace github.com/codeready-toolchain/toolchain-common => github.com/fbm3307/toolchain-common v0.0.0-20240410113120-59122ba04a2f + require ( github.com/codeready-toolchain/api v0.0.0-20240322110702-5ab3840476e9 github.com/codeready-toolchain/toolchain-common v0.0.0-20240404090512-046d250d7d78 diff --git a/go.sum b/go.sum index fc3ee5fd..792ec8a8 100644 --- a/go.sum +++ b/go.sum @@ -136,8 +136,6 @@ github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoC github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= github.com/codeready-toolchain/api v0.0.0-20240322110702-5ab3840476e9 h1:Lm7bFLrzfJzrUiRGVqtsSaZMpj+akLiR/fvAFjjE9gM= github.com/codeready-toolchain/api v0.0.0-20240322110702-5ab3840476e9/go.mod h1:cfNN6YPX4TORvhhZXMSjSPesqAHlB3nD/WAfGe4WLKQ= -github.com/codeready-toolchain/toolchain-common v0.0.0-20240404090512-046d250d7d78 h1:4jFHu6xN/T+hml9egbiZyJmptrMO0azWfF94liICmrM= -github.com/codeready-toolchain/toolchain-common v0.0.0-20240404090512-046d250d7d78/go.mod h1:OJ3L9aaTRMGjxr2WeH/9l6m5OjExwEK3Bp/+P+efoGg= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= @@ -185,6 +183,8 @@ github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZM github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/set v0.2.1/go.mod h1:+RKtMCH+favT2+3YecHGxcc0b4KyVWA1QWWJUs4E0CI= +github.com/fbm3307/toolchain-common v0.0.0-20240410113120-59122ba04a2f h1:HtAHkX+50e8StAIvXxb5DypSzbgRDbs5y+tVUmf8MeI= +github.com/fbm3307/toolchain-common v0.0.0-20240410113120-59122ba04a2f/go.mod h1:OJ3L9aaTRMGjxr2WeH/9l6m5OjExwEK3Bp/+P+efoGg= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= diff --git a/main.go b/main.go index a688c965..b1042e5f 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "fmt" "os" goruntime "runtime" + "time" "github.com/codeready-toolchain/member-operator/controllers/idler" membercfgctrl "github.com/codeready-toolchain/member-operator/controllers/memberoperatorconfig" @@ -16,6 +17,7 @@ import ( "github.com/codeready-toolchain/member-operator/pkg/metrics" "github.com/codeready-toolchain/member-operator/version" "github.com/codeready-toolchain/toolchain-common/controllers/toolchainclustercache" + "github.com/codeready-toolchain/toolchain-common/controllers/toolchainclusterhealth" commonclient "github.com/codeready-toolchain/toolchain-common/pkg/client" "github.com/codeready-toolchain/toolchain-common/pkg/cluster" commonconfig "github.com/codeready-toolchain/toolchain-common/pkg/configuration" @@ -50,6 +52,8 @@ var ( setupLog = ctrl.Log.WithName("setup") ) +const requeAfter = 10 * time.Second + func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) @@ -212,6 +216,16 @@ func main() { setupLog.Error(err, "unable to create controller", "controller", "ToolchainClusterCache") os.Exit(1) } + + if err := toolchainclusterhealth.NewReconciler( + mgr, + namespace, + crtConfig.ToolchainCluster().HealthCheckTimeout(), + requeAfter, + ).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "ToolchainClusterHealth") + os.Exit(1) + } if err := (&idler.Reconciler{ Scheme: mgr.GetScheme(), AllNamespacesClient: allNamespacesClient, @@ -269,9 +283,6 @@ func main() { os.Exit(1) } - setupLog.Info("Starting ToolchainCluster health checks.") - toolchainclustercache.StartHealthChecks(stopChannel, mgr, namespace, crtConfig.ToolchainCluster().HealthCheckPeriod()) - // create or update Member status during the operator deployment setupLog.Info("Creating/updating the MemberStatus resource") memberStatusName := memberstatus.MemberStatusName