Skip to content

Commit

Permalink
KUBESAW-12: Convert the health-check goroutine into ToolchainCluster …
Browse files Browse the repository at this point in the history
…controller

Signed-off-by: Feny Mehta <fbm3307@gmail.com>
  • Loading branch information
fbm3307 committed Apr 10, 2024
1 parent 5a3ab8e commit 43db02d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
17 changes: 14 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -50,6 +52,8 @@ var (
setupLog = ctrl.Log.WithName("setup")
)

const requeAfter = 10 * time.Second

func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 43db02d

Please sign in to comment.