fix: Resolved some data out of sync after live-reload. (#5422)

refactor: Data not synchronized due to using singleton mode after live-reload.

Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io>

Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io>
This commit is contained in:
hongzhouzi
2022-12-21 10:49:53 +08:00
committed by GitHub
parent fddaca8ee2
commit efcd4c5512
5 changed files with 9 additions and 14 deletions

View File

@@ -52,7 +52,7 @@ type openpitrixHandler struct {
openpitrix openpitrix.Interface
}
func NewOpenpitrixClient(ksInformers informers.InformerFactory, ksClient versioned.Interface, option *openpitrixoptions.Options, cc clusterclient.ClusterClients, stopCh <-chan struct{}) openpitrix.Interface {
func NewOpenpitrixClient(ksInformers informers.InformerFactory, ksClient versioned.Interface, option *openpitrixoptions.Options, cc clusterclient.ClusterClients) openpitrix.Interface {
var s3Client s3.Interface
if option != nil && option.S3Options != nil && len(option.S3Options.Endpoint) != 0 {
var err error
@@ -62,7 +62,7 @@ func NewOpenpitrixClient(ksInformers informers.InformerFactory, ksClient version
}
}
return openpitrix.NewOpenpitrixOperator(ksInformers, ksClient, s3Client, cc, stopCh)
return openpitrix.NewOpenpitrixOperator(ksInformers, ksClient, s3Client, cc)
}
func (h *openpitrixHandler) CreateRepo(req *restful.Request, resp *restful.Response) {

View File

@@ -46,7 +46,7 @@ type openpitrixOperator struct {
CategoryInterface
}
func NewOpenpitrixOperator(ksInformers ks_informers.InformerFactory, ksClient versioned.Interface, s3Client s3.Interface, cc clusterclient.ClusterClients, stopCh <-chan struct{}) Interface {
func NewOpenpitrixOperator(ksInformers ks_informers.InformerFactory, ksClient versioned.Interface, s3Client s3.Interface, cc clusterclient.ClusterClients) Interface {
klog.Infof("start helm repo informer")
cachedReposData := reposcache.NewReposCache()
helmReposInformer := ksInformers.KubeSphereSharedInformerFactory().Application().V1alpha1().HelmRepos().Informer()

View File

@@ -20,7 +20,6 @@ import (
"fmt"
"sort"
"strings"
"sync"
"time"
"github.com/go-ldap/ldap"
@@ -59,8 +58,6 @@ type ldapInterfaceImpl struct {
groupSearchBase string
managerDN string
managerPassword string
once sync.Once
}
var _ Interface = &ldapInterfaceImpl{}
@@ -91,7 +88,6 @@ func NewLdapClient(options *Options, stopCh <-chan struct{}) (Interface, error)
groupSearchBase: options.GroupSearchBase,
managerDN: options.ManagerDN,
managerPassword: options.ManagerPassword,
once: sync.Once{},
}
go func() {
@@ -99,9 +95,7 @@ func NewLdapClient(options *Options, stopCh <-chan struct{}) (Interface, error)
client.close()
}()
client.once.Do(func() {
_ = client.createSearchBase()
})
_ = client.createSearchBase()
return client, nil
}