Skip to content

Commit

Permalink
OSSM-2006 Fix multiNamespaceInformer.HasSynced()
Browse files Browse the repository at this point in the history
  • Loading branch information
luksa committed Oct 7, 2022
1 parent 0991538 commit de94737
Show file tree
Hide file tree
Showing 23 changed files with 110 additions and 57 deletions.
4 changes: 2 additions & 2 deletions galley/pkg/config/source/kube/rt/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ func NewProvider(interfaces kube.Interfaces, namespaces string, resyncPeriod tim
}

// SetNamespaces updates the set of namespaces watched by the provider.
func (p *Provider) SetNamespaces(namespaces ...string) {
func (p *Provider) SetNamespaces(namespaces []string) {
p.mu.Lock()
defer p.mu.Unlock()

p.namespaces.SetNamespaces(namespaces...)
p.namespaces.SetNamespaces(namespaces)
}

// GetAdapter returns a type for the group/kind. If the type is a well-known type, then the returned type will have
Expand Down
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.5
// See https://github.com/kubernetes/kubernetes/issues/92867, there is a bug in the library
replace github.com/evanphx/json-patch => github.com/evanphx/json-patch v0.0.0-20190815234213-e83c0a1c26c8

replace maistra.io/api => github.com/luksa/api v0.0.0-20221007121009-79b53814c2ee

replace github.com/maistra/xns-informer => github.com/luksa/xns-informer v0.0.0-20221007113855-42ea70af8076

require (
cloud.google.com/go v0.73.0
contrib.go.opencensus.io/exporter/prometheus v0.2.0
Expand Down Expand Up @@ -59,7 +63,7 @@ require (
github.com/kr/text v0.2.0 // indirect
github.com/kylelemons/godebug v1.1.0
github.com/lestrrat-go/jwx v1.0.6
github.com/maistra/xns-informer v0.0.0-20210707160032-977ec17e2e0e
github.com/maistra/xns-informer v0.0.0-20220920133259-f0b868f688e0
github.com/mattn/go-isatty v0.0.12
github.com/mholt/archiver/v3 v3.5.0
github.com/miekg/dns v1.1.35
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,10 @@ github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc=
github.com/luksa/api v0.0.0-20221007121009-79b53814c2ee h1:b0uAO1oCjnRJ65qPdZSoZlXV60IO9CWKWM+TI1Lxb3M=
github.com/luksa/api v0.0.0-20221007121009-79b53814c2ee/go.mod h1:hHJ34rXaYoQeGS4giOeSdyTRAnmOrswD4j+CqF7dhJY=
github.com/luksa/xns-informer v0.0.0-20221007113855-42ea70af8076 h1:prVeSFqnQj56i9MQJGUW0SNycFgE71yZ05o9nLZTyug=
github.com/luksa/xns-informer v0.0.0-20221007113855-42ea70af8076/go.mod h1:Bwe3VRiuXlSXu8MktDkmbrFcmSDysxuoOra542o0Ljk=
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
Expand All @@ -566,8 +570,6 @@ github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM=
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
github.com/maistra/xns-informer v0.0.0-20210707160032-977ec17e2e0e h1:QqNPrmCUhk8JGyx/Crex7eNWWEFrc07M5v/CQKIwQN0=
github.com/maistra/xns-informer v0.0.0-20210707160032-977ec17e2e0e/go.mod h1:Bwe3VRiuXlSXu8MktDkmbrFcmSDysxuoOra542o0Ljk=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
Expand Down Expand Up @@ -1434,8 +1436,6 @@ k8s.io/utils v0.0.0-20200729134348-d5654de09c73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/
k8s.io/utils v0.0.0-20200912215256-4140de9c8800/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20201110183641-67b214c5f920 h1:CbnUZsM497iRC5QMVkHwyl8s2tB3g7yaSHkYPkpgelw=
k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
maistra.io/api v0.0.0-20211119171546-348bbce3ca27 h1:/a3VKvmPXWB327XFCqIM6cRmdC09xLm4Ks/9YztfjDw=
maistra.io/api v0.0.0-20211119171546-348bbce3ca27/go.mod h1:lr+bFp/3PnYhRC/0IrDhCy7GfnQPhiOTW/CQ8qgTV9U=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
Expand Down
6 changes: 5 additions & 1 deletion pilot/pkg/config/kube/ior/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ func (fk *fakeMemberRollController) Register(listener controller.MemberRollListe
if listener == nil {
return
}

// ensure that listener has no namespaces until the smmrc initializes it with the actual list of namespaces in the member roll
listener.SetNamespaces(nil)

fk.listeners = append(fk.listeners, listener)
}

Expand All @@ -217,7 +221,7 @@ func (fk *fakeMemberRollController) invokeListeners() {
defer fk.lock.Unlock()

for _, l := range fk.listeners {
l.SetNamespaces(fk.namespaces...)
l.SetNamespaces(fk.namespaces)
}
}

Expand Down
6 changes: 5 additions & 1 deletion pilot/pkg/config/kube/ior/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,15 @@ func (r *route) handleEvent(event model.Event, cfg config.Config) error {
}

// Trigerred by SMMR controller when SMMR changes
func (r *route) SetNamespaces(namespaces ...string) {
func (r *route) SetNamespaces(namespaces []string) {
if !r.alive {
return
}

if namespaces == nil {
return
}

IORLog.Debugf("UpdateNamespaces(%v)", namespaces)
r.namespaceLock.Lock()
r.namespaces = namespaces
Expand Down
15 changes: 5 additions & 10 deletions pkg/kube/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,22 +333,19 @@ func newClientInternal(clientFactory util.Factory, revision string) (*client, er
c.kubeInformer = kubeinformer.NewSharedInformerFactoryWithOptions(
c.Interface,
resyncInterval,
kubeinformer.WithNamespaces(), // Maistra needs to start with an empty namespace set.
)

c.metadata, err = metadata.NewForConfig(c.config)
if err != nil {
return nil, err
}
c.metadataInformer = xnsinformers.NewMetadataSharedInformerFactory(c.metadata, resyncInterval)
c.metadataInformer.SetNamespaces() // Maistra needs to start with an empty namespace set.

c.dynamic, err = dynamic.NewForConfig(c.config)
if err != nil {
return nil, err
}
c.dynamicInformer = xnsinformers.NewDynamicSharedInformerFactory(c.dynamic, resyncInterval)
c.dynamicInformer.SetNamespaces() // Maistra needs to start with an empty namespace set.

c.istio, err = istioclient.NewForConfig(c.config)
if err != nil {
Expand All @@ -357,7 +354,6 @@ func newClientInternal(clientFactory util.Factory, revision string) (*client, er
c.istioInformer = istioinformer.NewSharedInformerFactoryWithOptions(
c.istio,
resyncInterval,
istioinformer.WithNamespaces(), // Maistra needs to start with an empty namespace set.
)

c.serviceapis, err = serviceapisclient.NewForConfig(c.config)
Expand All @@ -367,7 +363,6 @@ func newClientInternal(clientFactory util.Factory, revision string) (*client, er
c.serviceapisInformers = serviceapisinformer.NewSharedInformerFactoryWithOptions(
c.serviceapis,
resyncInterval,
serviceapisinformer.WithNamespaces(), // Maistra needs to start with an empty namespace set.
)

ext, err := kubeExtClient.NewForConfig(c.config)
Expand Down Expand Up @@ -446,11 +441,11 @@ func (c *client) SetNamespaces(namespaces ...string) {
return
}

c.kubeInformer.SetNamespaces(namespaces...)
c.istioInformer.SetNamespaces(namespaces...)
c.dynamicInformer.SetNamespaces(namespaces...)
c.metadataInformer.SetNamespaces(namespaces...)
c.serviceapisInformers.SetNamespaces(namespaces...)
c.kubeInformer.SetNamespaces(namespaces)
c.istioInformer.SetNamespaces(namespaces)
c.dynamicInformer.SetNamespaces(namespaces)
c.metadataInformer.SetNamespaces(namespaces)
c.serviceapisInformers.SetNamespaces(namespaces)
}

func (c *client) AddMemberRoll(namespace, memberRollName string) (err error) {
Expand Down
7 changes: 5 additions & 2 deletions pkg/servicemesh/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type serviceMeshMemberRollController struct {
}

type MemberRollListener interface {
SetNamespaces(namespaces ...string)
SetNamespaces(namespaces []string)
}

type MemberRollController interface {
Expand Down Expand Up @@ -97,6 +97,9 @@ func (smmrc *serviceMeshMemberRollController) Start(stopCh <-chan struct{}) {
}

func (smmrc *serviceMeshMemberRollController) Register(listener MemberRollListener, name string) {
// ensure listener has no namespaces until the smmrc initializes it with the actual list of namespaces in the member roll
listener.SetNamespaces(nil)

smmrc.informer.AddEventHandler(smmrc.newServiceMeshMemberRollListener(listener, name))
}

Expand Down Expand Up @@ -196,7 +199,7 @@ func (smmrl *serviceMeshMemberRollListener) updateNamespaces(operation string, m

smmrl.currentNamespaces = namespaces
smmrLog.Debugf("Sending [%s] update to listener %q with %d member(s): %v", operation, smmrl.name, len(namespaces), namespaces)
smmrl.listener.SetNamespaces(smmrl.currentNamespaces...)
smmrl.listener.SetNamespaces(smmrl.currentNamespaces)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/servicemesh/controller/extension/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func NewControllerFromConfigFile(kubeConfig string, namespaces []string, mrc mem
mrc.Register(namespaceSet, "extensions-controller")
} else {
// No MemberRoll configured, set namespaces based on args.
namespaceSet.SetNamespaces(namespaces...)
namespaceSet.SetNamespaces(namespaces)
}

newInformer := func(namespace string) cache.SharedIndexInformer {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit de94737

Please sign in to comment.