client-go: allow adding indexes after informer starts

Kubernetes-commit: d96a9858d396d7f418d24ea47bdc92ef8429f707
This commit is contained in:
John Howard
2023-03-31 15:57:18 -07:00
committed by Kubernetes Publisher
parent 84a6fe7e40
commit 785e19661f
4 changed files with 146 additions and 47 deletions

View File

@@ -540,8 +540,8 @@ func (s *sharedIndexInformer) AddIndexers(indexers Indexers) error {
s.startedLock.Lock()
defer s.startedLock.Unlock()
if s.started {
return fmt.Errorf("informer has already started")
if s.stopped {
return fmt.Errorf("indexer was not added because it has stopped already")
}
return s.indexer.AddIndexers(indexers)