@@ -19,9 +19,11 @@ package goroutines
19
19
import (
20
20
"context"
21
21
"reflect"
22
+ "strings"
22
23
"time"
23
24
24
25
gset "github.com/deckarep/golang-set"
26
+ corev1 "k8s.io/api/core/v1"
25
27
"k8s.io/apimachinery/pkg/api/errors"
26
28
"k8s.io/apimachinery/pkg/types"
27
29
utilwait "k8s.io/apimachinery/pkg/util/wait"
@@ -105,21 +107,70 @@ func SyncUpNSSCR(bs *bootstrap.Bootstrap) {
105
107
106
108
secretshare := & ssv1.SecretShare {}
107
109
secretshareKey := types.NamespacedName {Name : SecretShareCppName , Namespace : bs .CSData .MasterNs }
110
+ nssConfigmap := & corev1.ConfigMap {}
111
+ cppConfigmap := & corev1.ConfigMap {}
112
+ var targertnsList []string
108
113
nsList := []ssv1.TargetNamespace {}
109
- scopeCR := & nssv1. NamespaceScope {}
110
- odlmNsScopeKey := types. NamespacedName { Name : "odlm-scope-managedby-odlm" , Namespace : bs . CSData . MasterNs }
111
- if err := bs .Reader .Get (ctx , odlmNsScopeKey , scopeCR ); err != nil {
114
+
115
+ //check if need to deploy cert manager operand
116
+ if err := bs .Reader .Get (ctx , types. NamespacedName { Name : "ibm-cpp-config" , Namespace : bs . CSData . MasterNs }, cppConfigmap ); err != nil {
112
117
if errors .IsNotFound (err ) {
113
- klog .Warningf ( "Not found NSS resource %s : %v, retry in 1 minute" , targetNsScopeKey . String () , err )
114
- time .Sleep (1 * time .Minute )
118
+ klog .Infof ( "waiting for configmap ibm-cpp-config : %v, retry in 10 seconds" , err )
119
+ time .Sleep (10 * time .Second )
115
120
continue
116
121
}
117
- klog .Errorf ("Failed to get NSS resource %s: %v, retry again" , targetNsScopeKey .String (), err )
118
- continue
122
+ } else {
123
+
124
+ if cppConfigmap .Data ["deployCSCertManagerOperands" ] == "false" {
125
+ klog .Info ("cert-manager operand deployment is turned off in ibm-cpp-configmap" )
126
+
127
+ //get ConfigMap of odlm-scope
128
+ namespaceScopeKey := types.NamespacedName {Name : "odlm-scope" , Namespace : bs .CSData .MasterNs }
129
+ if err := bs .Reader .Get (ctx , namespaceScopeKey , nssConfigmap ); err != nil {
130
+ if errors .IsNotFound (err ) {
131
+ klog .Infof ("waiting for configmap %s: %v, retry in 10 seconds" , namespaceScopeKey .String (), err )
132
+ time .Sleep (10 * time .Second )
133
+ continue
134
+ }
135
+ klog .Errorf ("Failed to get configmap %s: %v, retry in 10 seconds" , namespaceScopeKey .String (), err )
136
+ time .Sleep (10 * time .Second )
137
+ continue
138
+ } else {
139
+ //get namespaces from ConfigMap
140
+ nssnsmems , ok := nssConfigmap .Data ["namespaces" ]
141
+ if ! ok {
142
+ klog .Infof ("There is no namespace in configmap %v" , namespaceScopeKey .String ())
143
+ }
144
+ targertnsList = strings .Split (nssnsmems , "," )
145
+ }
146
+ } else {
147
+ //get ConfigMap of namespace-scope
148
+ namespaceScopeKey := types.NamespacedName {Name : "namespace-scope" , Namespace : bs .CSData .MasterNs }
149
+ if err := bs .Reader .Get (ctx , namespaceScopeKey , nssConfigmap ); err != nil {
150
+ if errors .IsNotFound (err ) {
151
+ klog .Infof ("waiting for configmap %s: %v, retry in 10 seconds" , namespaceScopeKey .String (), err )
152
+ time .Sleep (10 * time .Second )
153
+ continue
154
+ }
155
+ klog .Errorf ("Failed to get configmap %s: %v, retry in 10 seconds" , namespaceScopeKey .String (), err )
156
+ time .Sleep (10 * time .Second )
157
+ continue
158
+ } else {
159
+ //get namespaces from ConfigMap
160
+ nssNsMems , ok := nssConfigmap .Data ["namespaces" ]
161
+ if ! ok {
162
+ klog .Infof ("There is no namespace in configmap %v" , namespaceScopeKey .String ())
163
+ }
164
+ targertnsList = strings .Split (nssNsMems , "," )
165
+ }
166
+ }
119
167
}
120
- for _ , ns := range scopeCR .Status .ValidatedMembers {
168
+
169
+ for _ , ns := range targertnsList {
121
170
nsList = append (nsList , ssv1.TargetNamespace {Namespace : ns })
122
171
}
172
+
173
+ //create/update secretshare to share the ibm-cpp-config configmap in cp namespaces
123
174
if err := bs .Reader .Get (ctx , secretshareKey , secretshare ); err != nil && ! errors .IsNotFound (err ) {
124
175
klog .Errorf ("Failed to get SecretShare CR %s: %v, retry again" , secretshareKey .String (), err )
125
176
continue
0 commit comments