Skip to content

Commit

Permalink
capturing actual error message while checking if repo exists
Browse files Browse the repository at this point in the history
  • Loading branch information
shkumari-px committed Dec 22, 2023
1 parent ee7f3ad commit 08959e7
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pkg/executor/kopia/kopiabackup.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,23 +617,24 @@ func isRepositoryExists(repository *executor.Repository) (bool, error) {
return false, err
}
exists := false
var repoExistsError error
t := func() (interface{}, bool, error) {
bucket, err := objectstore.GetBucket(bl)
if err != nil {
bucket, repoExistsError := objectstore.GetBucket(bl)
if repoExistsError != nil {
status := &executor.Status{
LastKnownError: err,
LastKnownError: repoExistsError,
}
if err = executor.WriteVolumeBackupStatus(status, volumeBackupName, bkpNamespace); err != nil {
errMsg := fmt.Sprintf("failed to write a VolumeBackup status: %v", err)
logrus.Errorf("%v", errMsg)
return "", true, fmt.Errorf(errMsg)
}
return "", true, fmt.Errorf("repo check status not available")
return "", true, fmt.Errorf("repo check status not available while fetching repository location: %v", repoExistsError)
}

bucket = blob.PrefixedBucket(bucket, repository.Name)
exists, err = bucket.Exists(context.TODO(), kopiaRepositoryFile)
if err != nil {
exists, repoExistsError = bucket.Exists(context.TODO(), kopiaRepositoryFile)
if repoExistsError != nil {
status := &executor.Status{
LastKnownError: err,
}
Expand All @@ -642,7 +643,7 @@ func isRepositoryExists(repository *executor.Repository) (bool, error) {
logrus.Errorf("%v", errMsg)
return "", true, fmt.Errorf(errMsg)
}
return "", true, fmt.Errorf("repo check status not available")
return "", true, fmt.Errorf("repo check status not available while checking if repo exists: %v", repoExistsError)
}
if exists {
logrus.Infof("%s exists", kopiaRepositoryFile)
Expand All @@ -654,8 +655,8 @@ func isRepositoryExists(repository *executor.Repository) (bool, error) {
}

if _, err := task.DoRetryWithTimeout(t, executor.DefaultTimeout, progressCheckInterval); err != nil {
logrus.Errorf("repository %s exists check failed: %v", repository.Name, err)
return exists, err
logrus.Errorf("max retries done, repository %s exists check failed: %v", repository.Name, repoExistsError)
return exists, repoExistsError
}

return exists, nil
Expand Down

0 comments on commit 08959e7

Please sign in to comment.