backup sync: process the default location first

Signed-off-by: Steve Kriss <steve@heptio.com>
pull/799/head
Steve Kriss 2018-08-24 11:07:01 -07:00
parent 7a1e6d16cc
commit 133dc185ca
4 changed files with 10 additions and 0 deletions

View File

@ -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,

View File

@ -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)
}
@ -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,
@ -68,6 +70,7 @@ func NewBackupSyncController(
genericController: newGenericController("backup-sync", logger),
client: client,
namespace: namespace,
defaultBackupLocation: defaultBackupLocation,
backupLister: backupInformer.Lister(),
backupStorageLocationLister: backupStorageLocationInformer.Lister(),
@ -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)

View File

@ -176,6 +176,7 @@ func TestBackupSyncControllerRun(t *testing.T) {
sharedInformers.Ark().V1().BackupStorageLocations(),
time.Duration(0),
test.namespace,
"",
nil, // pluginRegistry
arktest.NewLogger(),
logrus.DebugLevel,
@ -341,6 +342,7 @@ func TestDeleteOrphanedBackups(t *testing.T) {
sharedInformers.Ark().V1().BackupStorageLocations(),
time.Duration(0),
test.namespace,
"",
nil, // pluginRegistry
arktest.NewLogger(),
logrus.InfoLevel,

View File

@ -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