From 0b304f5109367c15694c8ea97baacfa92fb55c0e Mon Sep 17 00:00:00 2001 From: Feny Mehta Date: Wed, 10 Apr 2024 17:06:24 +0530 Subject: [PATCH 1/7] KUBESAW-12: Convert the health-check goroutine into ToolchainCluster controller Signed-off-by: Feny Mehta --- go.mod | 2 ++ go.sum | 4 ++-- main.go | 16 +++++++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 27d23f8f3..5c5c54e8f 100644 --- a/go.mod +++ b/go.mod @@ -114,3 +114,5 @@ require ( ) go 1.20 + +replace github.com/codeready-toolchain/toolchain-common => github.com/fbm3307/toolchain-common v0.0.0-20240410113120-59122ba04a2f diff --git a/go.sum b/go.sum index 4e421d324..12ebc5250 100644 --- a/go.sum +++ b/go.sum @@ -138,8 +138,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= @@ -193,6 +191,8 @@ github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+ne 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 08056db72..c9494331e 100644 --- a/main.go +++ b/main.go @@ -34,6 +34,7 @@ import ( "github.com/codeready-toolchain/host-operator/pkg/templates/usertiers" "github.com/codeready-toolchain/host-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" commoncluster "github.com/codeready-toolchain/toolchain-common/pkg/cluster" commonconfig "github.com/codeready-toolchain/toolchain-common/pkg/configuration" @@ -63,6 +64,7 @@ var ( ) const memberClientTimeout = 3 * time.Second +const requeAfter = 10 * time.Second func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) @@ -223,6 +225,17 @@ func main() { // nolint:gocyclo setupLog.Error(err, "unable to create controller", "controller", "ToolchainClusterCache") os.Exit(1) } + + if err := toolchainclusterhealth.NewReconciler( + mgr, + namespace, + memberClientTimeout, + requeAfter, + ).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "ToolchainClusterHealth") + os.Exit(1) + } + if err := (&deactivation.Reconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), @@ -381,9 +394,6 @@ func main() { // nolint:gocyclo os.Exit(1) } - setupLog.Info("Starting ToolchainCluster health checks.") - toolchainclustercache.StartHealthChecks(ctx, mgr, namespace, 10*time.Second) - // create or update Toolchain status during the operator deployment setupLog.Info("Creating/updating the ToolchainStatus resource") if err := toolchainstatus.CreateOrUpdateResources(ctx, mgr.GetClient(), namespace, toolchainconfig.ToolchainStatusName); err != nil { From 1fa5803aa938cbe78010474ee1b32a4aaf546952 Mon Sep 17 00:00:00 2001 From: Feny Mehta Date: Wed, 17 Apr 2024 14:33:45 +0530 Subject: [PATCH 2/7] Updating changes in tc Signed-off-by: Feny Mehta --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5c5c54e8f..8d558d498 100644 --- a/go.mod +++ b/go.mod @@ -115,4 +115,4 @@ require ( go 1.20 -replace github.com/codeready-toolchain/toolchain-common => github.com/fbm3307/toolchain-common v0.0.0-20240410113120-59122ba04a2f +replace github.com/codeready-toolchain/toolchain-common => github.com/fbm3307/toolchain-common v0.0.0-20240417083716-70fbeef8e9da diff --git a/go.sum b/go.sum index 12ebc5250..71c2fb1c7 100644 --- a/go.sum +++ b/go.sum @@ -191,8 +191,8 @@ github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+ne 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/fbm3307/toolchain-common v0.0.0-20240417083716-70fbeef8e9da h1:w/hWA2MqlUM6eiGivlSSbVrr3/wCdHEE318FEzUcbL0= +github.com/fbm3307/toolchain-common v0.0.0-20240417083716-70fbeef8e9da/go.mod h1:Iat3N+zBZcVgm/HWxa/ltSEoelM/YCXQUvbL9C8OSTw= 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= From f060c0cb0cc0754862d1a50f81641ff236a68d85 Mon Sep 17 00:00:00 2001 From: Feny Mehta Date: Wed, 17 Apr 2024 19:00:04 +0530 Subject: [PATCH 3/7] Updating the main.go for controller Signed-off-by: Feny Mehta --- go.mod | 2 +- go.sum | 4 ++-- main.go | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 8d558d498..505ddc557 100644 --- a/go.mod +++ b/go.mod @@ -115,4 +115,4 @@ require ( go 1.20 -replace github.com/codeready-toolchain/toolchain-common => github.com/fbm3307/toolchain-common v0.0.0-20240417083716-70fbeef8e9da +replace github.com/codeready-toolchain/toolchain-common => github.com/fbm3307/toolchain-common v0.0.0-20240417132014-762118cab090 diff --git a/go.sum b/go.sum index 71c2fb1c7..d23811b45 100644 --- a/go.sum +++ b/go.sum @@ -191,8 +191,8 @@ github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+ne 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-20240417083716-70fbeef8e9da h1:w/hWA2MqlUM6eiGivlSSbVrr3/wCdHEE318FEzUcbL0= -github.com/fbm3307/toolchain-common v0.0.0-20240417083716-70fbeef8e9da/go.mod h1:Iat3N+zBZcVgm/HWxa/ltSEoelM/YCXQUvbL9C8OSTw= +github.com/fbm3307/toolchain-common v0.0.0-20240417132014-762118cab090 h1:9LAFPZ05Aeyt+cBpHmeJwilACol0L7QZaUPx/bcTpsw= +github.com/fbm3307/toolchain-common v0.0.0-20240417132014-762118cab090/go.mod h1:Iat3N+zBZcVgm/HWxa/ltSEoelM/YCXQUvbL9C8OSTw= 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 c9494331e..ba29d2144 100644 --- a/main.go +++ b/main.go @@ -228,8 +228,6 @@ func main() { // nolint:gocyclo if err := toolchainclusterhealth.NewReconciler( mgr, - namespace, - memberClientTimeout, requeAfter, ).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "ToolchainClusterHealth") From 68c0a798699a225fe41463707d01ae23e9427367 Mon Sep 17 00:00:00 2001 From: Feny Mehta Date: Wed, 17 Apr 2024 19:20:15 +0530 Subject: [PATCH 4/7] Fix error of package Signer-off-by: Feny Mehta --- main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/main.go b/main.go index df45b771b..23e4235f9 100644 --- a/main.go +++ b/main.go @@ -36,6 +36,7 @@ import ( "github.com/codeready-toolchain/host-operator/version" "github.com/codeready-toolchain/toolchain-common/controllers/toolchainclustercache" "github.com/codeready-toolchain/toolchain-common/controllers/toolchainclusterhealth" + "github.com/codeready-toolchain/toolchain-common/controllers/toolchainclusterresources" commonclient "github.com/codeready-toolchain/toolchain-common/pkg/client" commoncluster "github.com/codeready-toolchain/toolchain-common/pkg/cluster" commonconfig "github.com/codeready-toolchain/toolchain-common/pkg/configuration" From 71aae0a505ed3410865b43b4dd55e6ad2eca107d Mon Sep 17 00:00:00 2001 From: Feny Mehta Date: Thu, 18 Apr 2024 21:41:28 +0530 Subject: [PATCH 5/7] Review Comments1 Signed-off-by: Feny Mehta --- go.mod | 4 ++-- go.sum | 4 ++-- main.go | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index e4a54ec55..3afb53fc3 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,7 @@ module github.com/codeready-toolchain/host-operator +replace github.com/codeready-toolchain/toolchain-common => github.com/fbm3307/toolchain-common v0.0.0-20240418155341-5d6888b6a711 + require ( github.com/codeready-toolchain/api v0.0.0-20240322110702-5ab3840476e9 github.com/codeready-toolchain/toolchain-common v0.0.0-20240417084737-d3c148491687 @@ -113,5 +115,3 @@ require ( ) go 1.20 - -replace github.com/codeready-toolchain/toolchain-common => github.com/fbm3307/toolchain-common v0.0.0-20240417132014-762118cab090 diff --git a/go.sum b/go.sum index d23811b45..5e70f1e7e 100644 --- a/go.sum +++ b/go.sum @@ -191,8 +191,8 @@ github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+ne 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-20240417132014-762118cab090 h1:9LAFPZ05Aeyt+cBpHmeJwilACol0L7QZaUPx/bcTpsw= -github.com/fbm3307/toolchain-common v0.0.0-20240417132014-762118cab090/go.mod h1:Iat3N+zBZcVgm/HWxa/ltSEoelM/YCXQUvbL9C8OSTw= +github.com/fbm3307/toolchain-common v0.0.0-20240418155341-5d6888b6a711 h1:hIvauPX5atq21jmwcLvKobp80rVDe+V8IPLk8nRWy2A= +github.com/fbm3307/toolchain-common v0.0.0-20240418155341-5d6888b6a711/go.mod h1:Iat3N+zBZcVgm/HWxa/ltSEoelM/YCXQUvbL9C8OSTw= 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 23e4235f9..3f368278c 100644 --- a/main.go +++ b/main.go @@ -34,8 +34,8 @@ import ( "github.com/codeready-toolchain/host-operator/pkg/templates/nstemplatetiers" "github.com/codeready-toolchain/host-operator/pkg/templates/usertiers" "github.com/codeready-toolchain/host-operator/version" + "github.com/codeready-toolchain/toolchain-common/controllers/toolchaincluster" "github.com/codeready-toolchain/toolchain-common/controllers/toolchainclustercache" - "github.com/codeready-toolchain/toolchain-common/controllers/toolchainclusterhealth" "github.com/codeready-toolchain/toolchain-common/controllers/toolchainclusterresources" commonclient "github.com/codeready-toolchain/toolchain-common/pkg/client" commoncluster "github.com/codeready-toolchain/toolchain-common/pkg/cluster" @@ -66,7 +66,6 @@ var ( ) const memberClientTimeout = 3 * time.Second -const requeAfter = 10 * time.Second func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) @@ -226,10 +225,11 @@ func main() { // nolint:gocyclo os.Exit(1) } - if err := toolchainclusterhealth.NewReconciler( - mgr, - requeAfter, - ).SetupWithManager(mgr); err != nil { + if err := (&toolchaincluster.Reconciler{ + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + RequeAfter: 10 * time.Second, + }).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "ToolchainClusterHealth") os.Exit(1) } From f2c8937928476f860c819f43410eaf61f4c60cb3 Mon Sep 17 00:00:00 2001 From: Feny Mehta Date: Fri, 19 Apr 2024 14:51:09 +0530 Subject: [PATCH 6/7] .rc-2 Signed-off-by: Feny Mehta --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 3f368278c..84c9b9423 100644 --- a/main.go +++ b/main.go @@ -230,7 +230,7 @@ func main() { // nolint:gocyclo Scheme: mgr.GetScheme(), RequeAfter: 10 * time.Second, }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "ToolchainClusterHealth") + setupLog.Error(err, "unable to create controller", "controller", "ToolchainCluster") os.Exit(1) } From e835a91508c4eb77834a621b479da2741b60ac3b Mon Sep 17 00:00:00 2001 From: Feny Mehta Date: Mon, 22 Apr 2024 14:25:27 +0530 Subject: [PATCH 7/7] Updatig toolchaincommon latest Signed-off-by: Feny Mehta --- go.mod | 4 +--- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 26be1f4c4..2358d81ec 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,8 @@ module github.com/codeready-toolchain/host-operator -replace github.com/codeready-toolchain/toolchain-common => github.com/fbm3307/toolchain-common v0.0.0-20240418155341-5d6888b6a711 - require ( github.com/codeready-toolchain/api v0.0.0-20240322110702-5ab3840476e9 - github.com/codeready-toolchain/toolchain-common v0.0.0-20240417084737-d3c148491687 + github.com/codeready-toolchain/toolchain-common v0.0.0-20240422084400-e6d41ea74313 github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-bindata/go-bindata v3.1.2+incompatible github.com/go-logr/logr v1.2.3 diff --git a/go.sum b/go.sum index 4fbfebb78..adf87b39e 100644 --- a/go.sum +++ b/go.sum @@ -138,6 +138,8 @@ 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-20240422084400-e6d41ea74313 h1:UuLjLbn8Rh1QX8jyLipAtaZ3o25Ard33B2+DCcmJLsQ= +github.com/codeready-toolchain/toolchain-common v0.0.0-20240422084400-e6d41ea74313/go.mod h1:rfVQhC9ctteNi2vbg300fgD0zgTfk/h3qjW9nsCayFs= 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= @@ -191,8 +193,6 @@ github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+ne 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-20240418155341-5d6888b6a711 h1:hIvauPX5atq21jmwcLvKobp80rVDe+V8IPLk8nRWy2A= -github.com/fbm3307/toolchain-common v0.0.0-20240418155341-5d6888b6a711/go.mod h1:Iat3N+zBZcVgm/HWxa/ltSEoelM/YCXQUvbL9C8OSTw= 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=