Skip to content

Commit

Permalink
backup sync: process the default location first
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 7a1e6d1 commit 133dc18
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ func (s *server) runControllers(config *api.Config, defaultBackupLocation *api.B
s.sharedInformerFactory.Ark().V1().BackupStorageLocations(),
s.config.backupSyncPeriod,
s.namespace,
s.config.defaultBackupLocation,
s.pluginRegistry,
s.logger,
s.logLevel,
Expand Down
5 changes: 5 additions & 0 deletions pkg/controller/backup_sync_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type backupSyncController struct {
backupLister listers.BackupLister
backupStorageLocationLister listers.BackupStorageLocationLister
namespace string
defaultBackupLocation string
newPluginManager func(logrus.FieldLogger) plugin.Manager
listCloudBackups func(logrus.FieldLogger, cloudprovider.ObjectStore, string) ([]*arkv1api.Backup, error)
}
Expand All @@ -55,6 +56,7 @@ func NewBackupSyncController(
backupStorageLocationInformer informers.BackupStorageLocationInformer,
syncPeriod time.Duration,
namespace string,
defaultBackupLocation string,
pluginRegistry plugin.Registry,
logger logrus.FieldLogger,
logLevel logrus.Level,
Expand All @@ -68,6 +70,7 @@ func NewBackupSyncController(
genericController: newGenericController("backup-sync", logger),
client: client,
namespace: namespace,
defaultBackupLocation: defaultBackupLocation,
backupLister: backupInformer.Lister(),
backupStorageLocationLister: backupStorageLocationInformer.Lister(),

Expand Down Expand Up @@ -97,6 +100,8 @@ func (c *backupSyncController) run() {
c.logger.WithError(errors.WithStack(err)).Error("Error getting backup storage locations from lister")
return
}
// sync the default location first, if it exists
locations = orderedBackupLocations(locations, c.defaultBackupLocation)

pluginManager := c.newPluginManager(c.logger)

Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/backup_sync_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func TestBackupSyncControllerRun(t *testing.T) {
sharedInformers.Ark().V1().BackupStorageLocations(),
time.Duration(0),
test.namespace,
"",
nil, // pluginRegistry
arktest.NewLogger(),
logrus.DebugLevel,
Expand Down Expand Up @@ -341,6 +342,7 @@ func TestDeleteOrphanedBackups(t *testing.T) {
sharedInformers.Ark().V1().BackupStorageLocations(),
time.Duration(0),
test.namespace,
"",
nil, // pluginRegistry
arktest.NewLogger(),
logrus.InfoLevel,
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/restore_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ func (c *restoreController) fetchFromBackupStorage(backupName string, pluginMana
return backupInfo{}, errors.New("not able to fetch from backup storage")
}

// orderedBackupLocations returns a new slice with the default backup location first (if it exists),
// followed by the rest of the locations in no particular order.
func orderedBackupLocations(locations []*api.BackupStorageLocation, defaultLocationName string) []*api.BackupStorageLocation {
var result []*api.BackupStorageLocation

Expand Down

0 comments on commit 133dc18

Please sign in to comment.