-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Carlisia <carlisia@vmware.com>
- Loading branch information
Carlisia
committed
Jun 10, 2020
1 parent
0017553
commit 38715c8
Showing
10 changed files
with
400 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
creationTimestamp: null | ||
name: manager-role | ||
rules: | ||
- apiGroups: | ||
- velero.io | ||
resources: | ||
- backupstoragelocations | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- velero.io | ||
resources: | ||
- backupstoragelocations/status | ||
verbs: | ||
- get | ||
- patch | ||
- update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package backupstoragelocation | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/vmware-tanzu/velero/pkg/persistence" | ||
|
||
"github.com/sirupsen/logrus" | ||
|
||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" | ||
"github.com/vmware-tanzu/velero/pkg/plugin/clientmgmt" | ||
) | ||
|
||
type Processor struct { | ||
DefaultStorageLocation string | ||
DefaultStoreValidationFrequency time.Duration | ||
NewPluginManager func(logrus.FieldLogger) clientmgmt.Manager | ||
} | ||
|
||
func (p *Processor) IsReadyToValidate(location *velerov1api.BackupStorageLocation, log logrus.FieldLogger) bool { | ||
storeValidationFrequency := p.DefaultStoreValidationFrequency | ||
// If the bsl validation frequency is not specifically set, skip this block and use the server's default | ||
if location.Spec.ValidationFrequency != nil { | ||
storeValidationFrequency = location.Spec.ValidationFrequency.Duration | ||
if storeValidationFrequency == 0 { | ||
log.Debug("Validation period for this backup location is set to 0, skipping validation") | ||
return false | ||
} | ||
|
||
if storeValidationFrequency < 0 { | ||
log.Debug("Validation period must be non-negative") | ||
storeValidationFrequency = p.DefaultStoreValidationFrequency | ||
} | ||
} | ||
|
||
lastValidation := location.Status.LastValidationTime | ||
if lastValidation != nil { | ||
nextValidation := lastValidation.Add(storeValidationFrequency) | ||
if time.Now().UTC().Before(nextValidation) { | ||
//location.Status.Phase = velerov1api.BackupStorageLocationPhaseUnverified | ||
//c.updateCurrentTallyOfAvailability(location) | ||
return false | ||
} | ||
} | ||
|
||
return true | ||
} | ||
|
||
func (p *Processor) IsValidFor(location *velerov1api.BackupStorageLocation, log logrus.FieldLogger) error { | ||
pluginManager := p.NewPluginManager(log) | ||
defer pluginManager.CleanupClients() | ||
|
||
var newBackupStore func(*velerov1api.BackupStorageLocation, persistence.ObjectStoreGetter, logrus.FieldLogger) (persistence.BackupStore, error) | ||
newBackupStore = persistence.NewObjectBackupStore | ||
backupStore, err := newBackupStore(location, pluginManager, log) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := backupStore.IsValid(); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.