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

Add additional information to the error message #30

Merged
merged 2 commits into from
Nov 19, 2024
Merged

Conversation

hlts2
Copy link
Member

@hlts2 hlts2 commented Nov 19, 2024

WHAT

Add additional information, such as the volume id and current state ..etc, to error returned by the handler

WHY

To make it easier to identify the cause of issue by including more detailed information in the error messages, improving debugging efficiency.

FYI

💡 There are no logic changes to this PR.

  • The following is the result of all unit test on Local environment
❯ go clean -testcache && go test ./...
ok  	github.com/civo/civo-csi	70.132s
ok  	github.com/civo/civo-csi/e2e	0.008s
ok  	github.com/civo/civo-csi/pkg/driver	10.016s

Comment on lines -23 to -24
csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER: struct{}{},
csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY: struct{}{},
Copy link
Member Author

Choose a reason for hiding this comment

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

Note

Since the struct specifications is not necessary, it has been removed 🙏

@@ -105,10 +105,10 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
availableSize := int64(quota.DiskGigabytesLimit - quota.DiskGigabytesUsage)
if availableSize < desiredSize {
log.Error().Msg("Requested volume would exceed storage quota available")
return nil, status.Error(codes.OutOfRange, fmt.Sprintf("Requested volume would exceed volume space quota by %d GB", desiredSize-availableSize))
Copy link
Member Author

Choose a reason for hiding this comment

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

Note

I changed it to pass the arguments directory to status.Errorf, which achieves the same result.
This makes the implementation simpler.

@hlts2 hlts2 marked this pull request as ready for review November 19, 2024 09:29
@hlts2 hlts2 changed the title Add more details to error message Add additional information to the error message Nov 19, 2024
@hlts2
Copy link
Member Author

hlts2 commented Nov 19, 2024

@RealHarshThakur @rytswd
Thank you for reviewing it 🙏
I will merge this PR 🚀

@hlts2 hlts2 merged commit 418cece into master Nov 19, 2024
4 checks passed
@hlts2 hlts2 deleted the feat/add-error-info branch November 19, 2024 09:52
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.

3 participants