Skip to content

Commit

Permalink
Add requeue + better formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Carlisia <carlisia@vmware.com>
  • Loading branch information
Carlisia committed Aug 24, 2020
1 parent 6040c3e commit 096c520
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
46 changes: 23 additions & 23 deletions pkg/cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -847,34 +847,34 @@ func (s *server) runControllers(defaultVolumeSnapshotLocations map[string]string
s.logger.WithField("informer", informer).Info("Informer cache synced")
}

storageLocationInfo := velero.StorageLocation{
Client: s.mgr.GetClient(),
Ctx: s.ctx,
DefaultStorageLocation: s.config.defaultBackupLocation,
DefaultStoreValidationFrequency: s.config.storeValidationFrequency,
NewPluginManager: newPluginManager,
NewBackupStore: persistence.NewObjectBackupStore,
}
if err := (&controller.BackupStorageLocationReconciler{
Scheme: s.mgr.GetScheme(),
StorageLocation: storageLocationInfo,
Log: s.logger,
}).SetupWithManager(s.mgr); err != nil {
bslr := controller.BackupStorageLocationReconciler{
Scheme: s.mgr.GetScheme(),
StorageLocation: velero.StorageLocation{
Client: s.mgr.GetClient(),
Ctx: s.ctx,
DefaultStorageLocation: s.config.defaultBackupLocation,
DefaultStoreValidationFrequency: s.config.storeValidationFrequency,
NewPluginManager: newPluginManager,
NewBackupStore: persistence.NewObjectBackupStore,
},
Log: s.logger,
}
if err := bslr.SetupWithManager(s.mgr); err != nil {
s.logger.Fatal(err, "unable to create controller", "controller", "backup-storage-location")
}

if _, ok := enabledRuntimeControllers[ServerStatusRequestControllerKey]; ok {
serverStatusInfo := velero.ServerStatus{
PluginRegistry: s.pluginRegistry,
Clock: clock.RealClock{},
r := controller.ServerStatusRequestReconciler{
Scheme: s.mgr.GetScheme(),
Client: s.mgr.GetClient(),
Ctx: s.ctx,
ServerStatus: velero.ServerStatus{
PluginRegistry: s.pluginRegistry,
Clock: clock.RealClock{},
},
Log: s.logger,
}
if err := (&controller.ServerStatusRequestReconciler{
Scheme: s.mgr.GetScheme(),
Client: s.mgr.GetClient(),
Ctx: s.ctx,
ServerStatus: serverStatusInfo,
Log: s.logger,
}).SetupWithManager(s.mgr); err != nil {
if err := r.SetupWithManager(s.mgr); err != nil {
s.logger.Fatal(err, "unable to create controller", "controller", ServerStatusRequestControllerKey)
}
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/controller/server_status_request_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ func (r *ServerStatusRequestReconciler) Reconcile(req ctrl.Request) (ctrl.Result
return ctrl.Result{}, errors.New("unexpected ServerStatusRequest phase")
}

return ctrl.Result{}, nil
// Requeue is mostly to handle deleting any expired status requests that were not
// deleted as part of the normal client flow for whatever reason.
return ctrl.Result{RequeueAfter: statusRequestResyncPeriod}, nil
}

func (r *ServerStatusRequestReconciler) SetupWithManager(mgr ctrl.Manager) error {
Expand Down

0 comments on commit 096c520

Please sign in to comment.