Skip to content
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

Better error messages / error codes #5

Merged
2 commits merged into from Jul 18, 2021
Merged

Better error messages / error codes #5

2 commits merged into from Jul 18, 2021

Conversation

ghost
Copy link

@ghost ghost commented Jul 13, 2021

Please describe the change you are making

This PR adds better error messages and error codes to identify failures from the oVirt engine.

@ghost
Copy link
Author

ghost commented Jul 14, 2021

Blocked by oVirt/ovirt-engine-sdk-go#227.

@ghost ghost marked this pull request as ready for review July 15, 2021 09:16
@ghost ghost requested a review from Gal-Zaidman July 15, 2021 09:16
@ghost
Copy link
Author

ghost commented Jul 15, 2021

@Gal-Zaidman here's another one for review please.

errors.go Outdated Show resolved Hide resolved
errors.go Outdated Show resolved Hide resolved
errors.go Outdated Show resolved Hide resolved
errors.go Outdated Show resolved Hide resolved
errors.go Outdated Show resolved Hide resolved
errors.go Outdated Show resolved Hide resolved
errors.go Outdated Show resolved Hide resolved
case errors.As(err, &authErr):
fallthrough
case strings.Contains(err.Error(), "access_denied"):
return wrap(err, EAccessDenied, "access denied, check your credentials")
Copy link
Contributor

Choose a reason for hiding this comment

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

or user is locked

Copy link
Author

Choose a reason for hiding this comment

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

We have to test how the engine reacts in that case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to track it as an issue?

Copy link
Author

Choose a reason for hiding this comment

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

#15

client_cluster_list.go Outdated Show resolved Hide resolved
client_disk_list.go Outdated Show resolved Hide resolved
This was referenced Jul 15, 2021
@ghost ghost assigned Gal-Zaidman Jul 16, 2021
ETimeout,
"timeout while removing disk",
)
case <-time.After(10 * time.Second):
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that the timeouts here are different on each retry method.
Maybe we should give the user a way to configure that with With.Context[1], and set a default.
I just think it is confusing that each retry method has a different interval (it also make sense because you don't want to retry connection like disk removal)

[1] https://pkg.go.dev/context#example-WithValue

Copy link
Author

Choose a reason for hiding this comment

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

@Gal-Zaidman leave it for now, this is handled properly in #14

}
template, err := convertSDKTemplate(sdkTemplate)
if err != nil {
return nil, fmt.Errorf("failed to convert template object (%w)", err)
return nil, wrap(err, EUnidentified, "failed to convert template object")
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above, should probably be EBug

Copy link
Author

@ghost ghost Jul 18, 2021

Choose a reason for hiding this comment

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

Fixed in #14

client_util.go Outdated
ovirtsdk "github.com/ovirt/go-ovirt"
)

// waitForJobFinished waits for a job to truly finish. This is especially important when disks are involved as their status changes to OK prematurely.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can remove "This is especially important when disks are involved as their status changes to OK prematurely." or at least say "Note: This is especially important when disks are involved as their status changes to OK prematurely."
Since it doesn't describe the function, just the motivation for creating/using it

Copy link
Contributor

@Gal-Zaidman Gal-Zaidman Jul 18, 2021

Choose a reason for hiding this comment

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

Also maybe add an example of how to set a correlationID, since it is not trivial, something like:

// waitForJobFinished waits for a job to truly finish by checking it was removed from the oVirt job queue using a caller predefined job correlationID.
// correlationID is a quarry parameter assigned to a job before it is sent to the ovirt engine, it must be unique and under 30 chars **(I think its a bit more but to be on the safe side).
// To set a correlationID add `Query("correlation_id", correlationID)` to the engine API call, for example:
correlationID := fmt.Sprintf("image_transfer_%s", utilrand.String(5))
conn.SystemService().DisksService().DiskService(diskId).
		Update().
		Query("correlation_id", correlationID).
		Send()

@@ -19,13 +18,13 @@ type VMClient interface {
// is 0. If the parameters are guaranteed to be non-zero MustNewVMCPUTopo should be used.
func NewVMCPUTopo(cores uint, threads uint, sockets uint) (VMCPUTopo, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

I'm afraid this link is broken. Can you add the comment in the correct place?

Copy link
Contributor

@Gal-Zaidman Gal-Zaidman left a comment

Choose a reason for hiding this comment

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

  • Some very minor changes are required.
  • Wanted to ask you to implement a general retry function since it has the same structure everywhere, but I see you beat me to the punch Retry #14

@ghost ghost merged commit 627e5a4 into oVirt:main Jul 18, 2021
@ghost ghost deleted the better-error-messages branch July 18, 2021 11:57
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant