Skip to content

Commit 6553723

Browse files
authored
start go routines after cs controller manager setup (#2333)
* Revert "suspend go routines until operator cache is ready (#2327)" This reverts commit 7cdb53c. * start go routines after cs controller manager setup Signed-off-by: Daniel Fan <[email protected]> --------- Signed-off-by: Daniel Fan <[email protected]>
1 parent 7cdb53c commit 6553723

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

controllers/goroutines/cleanup_resources.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ func CleanupMongodbPreloadCm(bs *bootstrap.Bootstrap) {
137137
}
138138
}
139139

140-
func CleanupResources(ch chan *bootstrap.Bootstrap) {
141-
bs := <-ch
140+
func CleanupResources(bs *bootstrap.Bootstrap) {
142141
go CleanupKeycloakCert(bs)
143142
go CleanupMongodbPreloadCm(bs)
144143
}

controllers/goroutines/operator_status.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ import (
3535
var ctx = context.Background()
3636

3737
// UpdateCsCrStatus will update cs cr status according to each bedrock operator
38-
func UpdateCsCrStatus(ch chan *bootstrap.Bootstrap) {
38+
func UpdateCsCrStatus(bs *bootstrap.Bootstrap) {
3939
for {
40-
bs := <-ch
4140
instance := &apiv3.CommonService{}
4241
if err := bs.Reader.Get(ctx, types.NamespacedName{Name: "common-service", Namespace: bs.CSData.OperatorNs}, instance); err != nil {
4342
if !errors.IsNotFound(err) {

controllers/goroutines/waitToCreateCsCR.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ import (
2828
)
2929

3030
// WaitToCreateCsCR waits for the creation of the CommonService CR in the operator namespace.
31-
func WaitToCreateCsCR(ch chan *bootstrap.Bootstrap) {
31+
func WaitToCreateCsCR(bs *bootstrap.Bootstrap) {
3232
for {
33-
bs := <-ch
3433
klog.Infof("Start to Create CommonService CR in the namespace %s", bs.CSData.OperatorNs)
3534
if err := bs.CreateCsCR(); err != nil {
3635
if strings.Contains(fmt.Sprint(err), "failed to call webhook") {

main.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,6 @@ func main() {
155155
os.Exit(1)
156156
}
157157

158-
// Setup a channel to suspend go routines
159-
ch := make(chan *bootstrap.Bootstrap)
160-
// Update CS CR Status, wait for signal from channel
161-
go goroutines.UpdateCsCrStatus(ch)
162-
// Create CS CR
163-
go goroutines.WaitToCreateCsCR(ch)
164-
// Delete Keycloak Cert
165-
go goroutines.CleanupResources(ch)
166-
167158
klog.Infof("Setup commonservice manager")
168159
if err = (&controllers.CommonServiceReconciler{
169160
Bootstrap: bs,
@@ -174,9 +165,13 @@ func main() {
174165
os.Exit(1)
175166
}
176167

177-
// start go routines
178168
klog.Infof("Start go routines")
179-
ch <- bs
169+
// Update CS CR Status
170+
go goroutines.UpdateCsCrStatus(bs)
171+
// Create CS CR
172+
go goroutines.WaitToCreateCsCR(bs)
173+
// Delete Keycloak Cert
174+
go goroutines.CleanupResources(bs)
180175

181176
// check if cert-manager CRD does not exist, then skip cert-manager related controllers initialization
182177
exist, err := bs.CheckCRD(constant.CertManagerAPIGroupVersionV1, "Certificate")
@@ -188,7 +183,6 @@ func main() {
188183
klog.Infof("cert-manager CRD does not exist, skip cert-manager related controllers initialization")
189184
} else if exist && err == nil {
190185

191-
klog.Infof("Set up certmanager Manager")
192186
if err = (&certmanagerv1controllers.CertificateRefreshReconciler{
193187
Client: mgr.GetClient(),
194188
Scheme: mgr.GetScheme(),

0 commit comments

Comments
 (0)