Skip to content

Commit

Permalink
download request: fix setting of log level for plugin manager
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Kriss <[email protected]>
  • Loading branch information
skriss committed Aug 28, 2018
1 parent 3234124 commit cf7c858
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions pkg/cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ func (s *server) runControllers(config *api.Config) error {
s.sharedInformerFactory.Ark().V1().Backups(),
s.pluginRegistry,
s.logger,
s.logLevel,
)
wg.Add(1)
go func() {
Expand Down
14 changes: 8 additions & 6 deletions pkg/controller/download_request_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ type downloadRequestController struct {
createSignedURL cloudprovider.CreateSignedURLFunc
backupLocationLister listers.BackupStorageLocationLister
backupLister listers.BackupLister
pluginRegistry plugin.Registry
newPluginManager func(logger logrus.FieldLogger, logLevel logrus.Level, pluginRegistry plugin.Registry) plugin.Manager
newPluginManager func(logrus.FieldLogger) plugin.Manager
}

// NewDownloadRequestController creates a new DownloadRequestController.
Expand All @@ -63,6 +62,7 @@ func NewDownloadRequestController(
backupInformer informers.BackupInformer,
pluginRegistry plugin.Registry,
logger logrus.FieldLogger,
logLevel logrus.Level,
) Interface {
c := &downloadRequestController{
genericController: newGenericController("downloadrequest", logger),
Expand All @@ -74,8 +74,10 @@ func NewDownloadRequestController(

// use variables to refer to these functions so they can be
// replaced with fakes for testing.
createSignedURL: cloudprovider.CreateSignedURL,
newPluginManager: plugin.NewManager,
createSignedURL: cloudprovider.CreateSignedURL,
newPluginManager: func(logger logrus.FieldLogger) plugin.Manager {
return plugin.NewManager(logger, logLevel, pluginRegistry)
},

clock: &clock.RealClock{},
}
Expand Down Expand Up @@ -143,7 +145,7 @@ const signedURLTTL = 10 * time.Minute

// generatePreSignedURL generates a pre-signed URL for downloadRequest, changes the phase to
// Processed, and persists the changes to storage.
func (c *downloadRequestController) generatePreSignedURL(downloadRequest *v1.DownloadRequest, log *logrus.Entry) error {
func (c *downloadRequestController) generatePreSignedURL(downloadRequest *v1.DownloadRequest, log logrus.FieldLogger) error {
update := downloadRequest.DeepCopy()

var (
Expand Down Expand Up @@ -173,7 +175,7 @@ func (c *downloadRequestController) generatePreSignedURL(downloadRequest *v1.Dow
return errors.WithStack(err)
}

pluginManager := c.newPluginManager(log, log.Level, c.pluginRegistry)
pluginManager := c.newPluginManager(log)
defer pluginManager.CleanupClients()

objectStore, err := getObjectStoreForLocation(backupLocation, pluginManager)
Expand Down
5 changes: 2 additions & 3 deletions pkg/controller/download_request_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func newDownloadRequestTestHarness(t *testing.T) *downloadRequestTestHarness {
informerFactory.Ark().V1().Backups(),
nil,
arktest.NewLogger(),
logrus.InfoLevel,
).(*downloadRequestController)
)

Expand All @@ -69,9 +70,7 @@ func newDownloadRequestTestHarness(t *testing.T) *downloadRequestTestHarness {

controller.clock = clock.NewFakeClock(clockTime)

controller.newPluginManager = func(_ logrus.FieldLogger, _ logrus.Level, _ plugin.Registry) plugin.Manager {
return pluginManager
}
controller.newPluginManager = func(_ logrus.FieldLogger) plugin.Manager { return pluginManager }

pluginManager.On("CleanupClients").Return()
objectStore.On("Init", mock.Anything).Return(nil)
Expand Down

0 comments on commit cf7c858

Please sign in to comment.