Skip to content

K8SPG-781 add original error #1207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions percona/watcher/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func GetLatestCommitTimestamp(ctx context.Context, cli client.Client, execCli *c

primary, err := perconaPG.GetPrimaryPod(ctx, cli, cr)
if err != nil {
return nil, PrimaryPodNotFound
return nil, errors.Wrap(PrimaryPodNotFound, err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be the opposite? i mean errors.Wrap(err, PrimaryPodNotFound.Error())

@gkech wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we wanted to just log this it would be fine, but in our case we use errors.Is(err, PrimaryPodNotFound) in the call stack. This cannot work properly because given that we do errors.Wrap(err, PrimaryPodNotFound.Error()) , the used error err does not contain the original PrimaryPodNotFound error value, only the string message and errors.Is cannot identify it properly.

}

log.V(1).Info("Getting latest commit timestamp from primary pod", "pod", primary.Name)
Expand Down Expand Up @@ -203,7 +203,7 @@ func GetLatestCommitTimestamp(ctx context.Context, cli client.Client, execCli *c
func getBackupStartTimestamp(ctx context.Context, cli client.Client, cr *pgv2.PerconaPGCluster, backup *pgv2.PerconaPGBackup) (time.Time, error) {
primary, err := perconaPG.GetPrimaryPod(ctx, cli, cr)
if err != nil {
return time.Time{}, PrimaryPodNotFound
return time.Time{}, errors.Wrap(PrimaryPodNotFound, err.Error())
}

pgbackrestInfo, err := pgbackrest.GetInfo(ctx, primary, backup.Spec.RepoName)
Expand Down
Loading