@@ -68,17 +68,18 @@ var nonRestorableResources = []string{
68
68
type restoreController struct {
69
69
* genericController
70
70
71
- namespace string
72
- restoreClient arkv1client.RestoresGetter
73
- backupClient arkv1client.BackupsGetter
74
- restorer restore.Restorer
75
- pvProviderExists bool
76
- backupLister listers.BackupLister
77
- restoreLister listers.RestoreLister
78
- backupLocationLister listers.BackupStorageLocationLister
79
- restoreLogLevel logrus.Level
80
- defaultBackupLocation string
81
- metrics * metrics.ServerMetrics
71
+ namespace string
72
+ restoreClient arkv1client.RestoresGetter
73
+ backupClient arkv1client.BackupsGetter
74
+ restorer restore.Restorer
75
+ pvProviderExists bool
76
+ backupLister listers.BackupLister
77
+ restoreLister listers.RestoreLister
78
+ backupLocationLister listers.BackupStorageLocationLister
79
+ snapshotLocationLister listers.VolumeSnapshotLocationLister
80
+ restoreLogLevel logrus.Level
81
+ defaultBackupLocation string
82
+ metrics * metrics.ServerMetrics
82
83
83
84
newPluginManager func (logger logrus.FieldLogger ) plugin.Manager
84
85
newBackupStore func (* api.BackupStorageLocation , persistence.ObjectStoreGetter , logrus.FieldLogger ) (persistence.BackupStore , error )
@@ -92,6 +93,7 @@ func NewRestoreController(
92
93
restorer restore.Restorer ,
93
94
backupInformer informers.BackupInformer ,
94
95
backupLocationInformer informers.BackupStorageLocationInformer ,
96
+ snapshotLocationInformer informers.VolumeSnapshotLocationInformer ,
95
97
pvProviderExists bool ,
96
98
logger logrus.FieldLogger ,
97
99
restoreLogLevel logrus.Level ,
@@ -100,18 +102,19 @@ func NewRestoreController(
100
102
metrics * metrics.ServerMetrics ,
101
103
) Interface {
102
104
c := & restoreController {
103
- genericController : newGenericController ("restore" , logger ),
104
- namespace : namespace ,
105
- restoreClient : restoreClient ,
106
- backupClient : backupClient ,
107
- restorer : restorer ,
108
- pvProviderExists : pvProviderExists ,
109
- backupLister : backupInformer .Lister (),
110
- restoreLister : restoreInformer .Lister (),
111
- backupLocationLister : backupLocationInformer .Lister (),
112
- restoreLogLevel : restoreLogLevel ,
113
- defaultBackupLocation : defaultBackupLocation ,
114
- metrics : metrics ,
105
+ genericController : newGenericController ("restore" , logger ),
106
+ namespace : namespace ,
107
+ restoreClient : restoreClient ,
108
+ backupClient : backupClient ,
109
+ restorer : restorer ,
110
+ pvProviderExists : pvProviderExists ,
111
+ backupLister : backupInformer .Lister (),
112
+ restoreLister : restoreInformer .Lister (),
113
+ backupLocationLister : backupLocationInformer .Lister (),
114
+ snapshotLocationLister : snapshotLocationInformer .Lister (),
115
+ restoreLogLevel : restoreLogLevel ,
116
+ defaultBackupLocation : defaultBackupLocation ,
117
+ metrics : metrics ,
115
118
116
119
// use variables to refer to these functions so they can be
117
120
// replaced with fakes for testing.
@@ -124,6 +127,7 @@ func NewRestoreController(
124
127
backupInformer .Informer ().HasSynced ,
125
128
restoreInformer .Informer ().HasSynced ,
126
129
backupLocationInformer .Informer ().HasSynced ,
130
+ snapshotLocationInformer .Informer ().HasSynced ,
127
131
)
128
132
129
133
restoreInformer .Informer ().AddEventHandler (
@@ -233,6 +237,7 @@ func (c *restoreController) processRestore(key string) error {
233
237
restore ,
234
238
actions ,
235
239
info ,
240
+ pluginManager ,
236
241
)
237
242
238
243
restore .Status .Warnings = len (restoreWarnings .Ark ) + len (restoreWarnings .Cluster )
@@ -482,6 +487,7 @@ func (c *restoreController) runRestore(
482
487
restore * api.Restore ,
483
488
actions []restore.ItemAction ,
484
489
info backupInfo ,
490
+ pluginManager plugin.Manager ,
485
491
) (restoreWarnings , restoreErrors api.RestoreResult , restoreFailure error ) {
486
492
logFile , err := ioutil .TempFile ("" , "" )
487
493
if err != nil {
@@ -531,10 +537,18 @@ func (c *restoreController) runRestore(
531
537
}
532
538
defer closeAndRemoveFile (resultsFile , c .logger )
533
539
540
+ volumeSnapshots , err := info .backupStore .GetBackupVolumeSnapshots (restore .Spec .BackupName )
541
+ if err != nil {
542
+ log .WithError (errors .WithStack (err )).Error ("Error fetching volume snapshots" )
543
+ restoreErrors .Ark = append (restoreErrors .Ark , err .Error ())
544
+ restoreFailure = err
545
+ return
546
+ }
547
+
534
548
// Any return statement above this line means a total restore failure
535
549
// Some failures after this line *may* be a total restore failure
536
550
log .Info ("starting restore" )
537
- restoreWarnings , restoreErrors = c .restorer .Restore (log , restore , info .backup , backupFile , actions )
551
+ restoreWarnings , restoreErrors = c .restorer .Restore (log , restore , info .backup , volumeSnapshots , backupFile , actions , c . snapshotLocationLister , pluginManager )
538
552
log .Info ("restore completed" )
539
553
540
554
// Try to upload the log file. This is best-effort. If we fail, we'll add to the ark errors.
0 commit comments