Skip to content

Commit

Permalink
PWX-30712: Initializing shared informer cache for all stork Pods (#1390
Browse files Browse the repository at this point in the history
…) (#1391)

* PWX-30712: Initializing shared informer cache for all stork Pods



* Creating CRD outside the flag as cache apis are not guarded by the flag



---------

Signed-off-by: Priyanshu Pandey <[email protected]>
  • Loading branch information
pp511 authored May 3, 2023
1 parent 8fbc161 commit 6fb3064
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
21 changes: 13 additions & 8 deletions cmd/stork/stork.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,19 @@ func run(c *cli.Context) {
if err := apis.AddToScheme(mgr.GetScheme()); err != nil {
log.Fatalf("Setup scheme failed for stork resources: %v", err)
}
// Registering application registration CRDs explicitly to use
// shared informer cache for caching application-controller CRs
if err := applicationmanager.CreateCRD(); err != nil {
log.Fatalf("Error creating CRDs for application manager: %v", err)
}

// Setup stork cache. We setup this cache for all the stork pods instead of just the leader pod.
// In this way, even the stork extender code can use this cache, since the extender filter/process
// requests can land on any stork pod.
if err := cache.CreateSharedInformerCache(mgr); err != nil {
log.Fatalf("failed to setup shared informer cache: %v", err)
}
log.Infof("shared informer cache has been intialized")

var d volume.Driver
if driverName != "" {
Expand Down Expand Up @@ -582,14 +595,6 @@ func runStork(mgr manager.Manager, ctx context.Context, d volume.Driver, recorde
}
}

// Setup stork cache. We setup this cache for all the stork pods instead of just the leader pod.
// In this way, even the stork extender code can use this cache, since the extender filter/process
// requests can land on any stork pod.
if err := cache.CreateSharedInformerCache(mgr); err != nil {
log.Fatalf("failed to setup shared informer cache: %v", err)
}
log.Infof("shared informer cache has been intialized")

go func() {
for {
<-signalChan
Expand Down
5 changes: 1 addition & 4 deletions pkg/applicationmanager/applicationmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ type ApplicationManager struct {

// Init Initializes the ApplicationManager and any children controller
func (a *ApplicationManager) Init(mgr manager.Manager, adminNamespace string, stopChannel chan os.Signal) error {
if err := a.createCRD(); err != nil {
return err
}
backupController := controllers.NewApplicationBackup(mgr, a.Recorder, a.ResourceCollector)
if err := backupController.Init(mgr, adminNamespace, a.RsyncTime); err != nil {
return err
Expand Down Expand Up @@ -70,7 +67,7 @@ func (a *ApplicationManager) Init(mgr manager.Manager, adminNamespace string, st
return nil
}

func (a *ApplicationManager) createCRD() error {
func CreateCRD() error {
resource := apiextensions.CustomResource{
Name: stork_api.BackupLocationResourceName,
Plural: stork_api.BackupLocationResourcePlural,
Expand Down

0 comments on commit 6fb3064

Please sign in to comment.