mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-08 14:21:18 +00:00
open kopia with no index change
Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
@@ -72,6 +72,10 @@ type kopiaObjectWriter struct {
|
||||
rawWriter object.Writer
|
||||
}
|
||||
|
||||
type openOptions struct {
|
||||
allowIndexWriteOnLoad bool
|
||||
}
|
||||
|
||||
const (
|
||||
defaultLogInterval = time.Second * 10
|
||||
defaultMaintainCheckPeriod = time.Hour
|
||||
@@ -115,7 +119,7 @@ func (ks *kopiaRepoService) Open(ctx context.Context, repoOption udmrepo.RepoOpt
|
||||
|
||||
repoCtx := kopia.SetupKopiaLog(ctx, ks.logger)
|
||||
|
||||
r, err := openKopiaRepo(repoCtx, repoConfig, repoOption.RepoPassword)
|
||||
r, err := openKopiaRepo(repoCtx, repoConfig, repoOption.RepoPassword, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -158,11 +162,15 @@ func (ks *kopiaRepoService) Maintain(ctx context.Context, repoOption udmrepo.Rep
|
||||
|
||||
repoCtx := kopia.SetupKopiaLog(ctx, ks.logger)
|
||||
|
||||
r, err := openKopiaRepo(repoCtx, repoConfig, repoOption.RepoPassword)
|
||||
ks.logger.Info("Start to open repo for maintenance, allow index write on load")
|
||||
|
||||
r, err := openKopiaRepo(repoCtx, repoConfig, repoOption.RepoPassword, &openOptions{allowIndexWriteOnLoad: true})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ks.logger.Info("Succeeded to open repo for maintenance")
|
||||
|
||||
defer func() {
|
||||
c := r.Close(repoCtx)
|
||||
if c != nil {
|
||||
@@ -546,8 +554,13 @@ func (lt *logThrottle) shouldLog() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func openKopiaRepo(ctx context.Context, configFile string, password string) (repo.Repository, error) {
|
||||
r, err := kopiaRepoOpen(ctx, configFile, password, &repo.Options{})
|
||||
func openKopiaRepo(ctx context.Context, configFile string, password string, options *openOptions) (repo.Repository, error) {
|
||||
allowIndexWriteOnLoad := false
|
||||
if options != nil {
|
||||
allowIndexWriteOnLoad = options.allowIndexWriteOnLoad
|
||||
}
|
||||
|
||||
r, err := kopiaRepoOpen(ctx, configFile, password, &repo.Options{AllowWriteOnIndexLoad: allowIndexWriteOnLoad})
|
||||
if os.IsNotExist(err) {
|
||||
return nil, errors.Wrap(err, "error to open repo, repo doesn't exist")
|
||||
}
|
||||
@@ -560,7 +573,7 @@ func openKopiaRepo(ctx context.Context, configFile string, password string) (rep
|
||||
}
|
||||
|
||||
func writeInitParameters(ctx context.Context, repoOption udmrepo.RepoOptions, logger logrus.FieldLogger) error {
|
||||
r, err := openKopiaRepo(ctx, repoOption.ConfigFilePath, repoOption.RepoPassword)
|
||||
r, err := openKopiaRepo(ctx, repoOption.ConfigFilePath, repoOption.RepoPassword, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user