Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion controllers/bootstrap/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -1180,8 +1180,19 @@ func (b *Bootstrap) DeployCertManagerCR() error {
// NamespaceScope resources include common-service, nss-managedby-odlm, nss-odlm-scope, and odlm-scope-managedby-odlm
func (b *Bootstrap) CleanNamespaceScopeResources() error {

// get namespace-scope ConfigMap in operatorNamespace
nssCmNs, err := util.GetNssCmNs(b.Reader, b.CSData.OperatorNs)
if err != nil {
klog.Errorf("Failed to get %s configmap: %v", constant.NamespaceScopeConfigmapName, err)
return err
} else if nssCmNs == nil {
klog.Infof("The %s configmap is not found in the %s namespace, skip cleaning the NamespaceScope resources", constant.NamespaceScopeConfigmapName, b.CSData.OperatorNs)
return nil
}

// If the topology is (NOT ALL NS Mode) and (NOT Simple) , return
if b.CSData.WatchNamespaces != "" && len(strings.Split(b.CSData.WatchNamespaces, ",")) > 1 {
if b.CSData.WatchNamespaces != "" && len(nssCmNs) > 1 {
klog.Infof("The topology is not All Namespaces Mode or Simple Topology, skip cleaning the NamespaceScope resources")
return nil
}

Expand Down
26 changes: 12 additions & 14 deletions controllers/common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,9 @@ func GetRequestNs(r client.Reader) (requestNs []string) {
func GetNssCmNs(r client.Reader, cpfsNamespace string) ([]string, error) {
nssConfigMap, err := GetCmOfNss(r, cpfsNamespace)
if err != nil {
if errors.IsNotFound(err) {
return nil, nil
}
return nil, err
}
nssNsMems, ok := nssConfigMap.Data["namespaces"]
Expand All @@ -744,22 +747,17 @@ func GetCmOfNss(r client.Reader, operatorNs string) (*corev1.ConfigMap, error) {
cmNs := operatorNs
nssConfigmap := &corev1.ConfigMap{}

for {
if err := utilwait.PollImmediate(time.Second*10, time.Second*60, func() (done bool, err error) {
err = r.Get(context.TODO(), types.NamespacedName{Name: cmName, Namespace: cmNs}, nssConfigmap)
if err != nil {
if errors.IsNotFound(err) {
klog.Infof("waiting for configmap %v/%v", operatorNs, constant.NamespaceScopeConfigmapName)
}
return false, err
if err := utilwait.PollImmediate(time.Second*5, time.Second*30, func() (done bool, err error) {
err = r.Get(context.TODO(), types.NamespacedName{Name: cmName, Namespace: cmNs}, nssConfigmap)
if err != nil {
if errors.IsNotFound(err) {
klog.Infof("waiting for configmap %v/%v", operatorNs, constant.NamespaceScopeConfigmapName)
}
return true, nil
}); err == nil {
break
} else {
klog.Errorf("Failed to get configmap %v/%v: %v", operatorNs, constant.NamespaceScopeConfigmapName, err)
return nil, err
return false, err
}
return true, nil
}); err != nil {
return nil, err
}

return nssConfigmap, nil
Expand Down
2 changes: 1 addition & 1 deletion controllers/webhooks/commonservice/validatingwebhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (

// +kubebuilder:webhook:path=/validate-operator-ibm-com-v3-commonservice,mutating=false,failurePolicy=fail,sideEffects=None,groups=operator.ibm.com,resources=commonservices,verbs=create;update,versions=v3,name=vcommonservice.kb.io,admissionReviewVersions=v1

// CommonServiceDefaulter points to correct ServiceNamespace
// CommonServiceDefaulter points to correct ServicesNamespace
type Defaulter struct {
Reader client.Reader
Client client.Client
Expand Down