Skip to content

Commit

Permalink
capturing actual error msg while trying to check if repo exists
Browse files Browse the repository at this point in the history
  • Loading branch information
shkumari-px committed Jan 10, 2024
1 parent 19632f8 commit 59b9e52
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ GO_FILES := $(shell find . -name '*.go' | grep -v 'vendor' | \
all: do-fmt pretest test-container test build container

test:
docker run --rm -it -v ${GOPATH}:/go: $(KDMP_UNITTEST_IMG) make unittest
docker run --rm -it -v ${GOPATH}:/go $(KDMP_UNITTEST_IMG) make unittest

test-container:
@echo "Building container: docker build --tag $(KDMP_UNITTEST_IMG) -f Dockerfile.unittest ."
Expand Down
23 changes: 11 additions & 12 deletions pkg/executor/kopia/kopiabackup.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,45 +617,44 @@ 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,
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 checking if repo exists: %v", repoExistsError)
}
if exists {
logrus.Infof("%s exists", kopiaRepositoryFile)
} else {
logrus.Infof("%s doesn't exists", kopiaRepositoryFile)
}

return "", false, nil
}

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 59b9e52

Please sign in to comment.