Conversation
|
Hi @copilot. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
…only permission Co-authored-by: andyzhangx <4178417+andyzhangx@users.noreply.github.com> Agent-Logs-Url: https://github.com/kubernetes-sigs/azurefile-csi-driver/sessions/fd54079c-0b66-4abf-8a0b-bde03213b851
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Copilot The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/ok-to-test |
The new GetFileShareQuota check before CreateFileShare calls Get() on the file share client. In the 'Account limit exceeded' test, the Get mock was returning success (share exists), causing CreateFileShare to short-circuit and skip the Create call. This left the Create mock expectations unsatisfied. Fix by returning 404 NotFound from the Get mock, simulating the file share not existing yet, so the code proceeds to call Create as expected.
|
/hold |
There was a problem hiding this comment.
Pull request overview
This PR updates the Azure File share creation flow to avoid calling the write-requiring Create operation when a share already exists, enabling read-only permissions for pre-provisioned shares.
Changes:
- Added a pre-check in
Driver.CreateFileShareto detect existing shares (via a quota read) and skip creation when present. - Updated controller-server unit tests to account for the new pre-check behavior.
- Added a dedicated unit test for
Driver.CreateFileSharecovering “exists / absent / quota-check-error” paths.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
pkg/azurefile/azurefile.go |
Adds an existence check before attempting share creation to reduce required permissions for existing shares. |
pkg/azurefile/controllerserver_test.go |
Adjusts mocked share GET behavior to align with the new pre-check in CreateFileShare. |
pkg/azurefile/azurefile_test.go |
Adds tests validating CreateFileShare behavior when the share exists, does not exist, or the existence check errors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- For 404 errors: proceed to CreateFileShare as before - For retriable errors (throttling/5xx): retry via backoff instead of falling through to unnecessary CreateFileShare - For other non-404 errors (e.g., ShareQuota nil but share exists): assume share exists and skip creation to avoid requiring write perms Signed-off-by: andyzhangx <xiazhang@microsoft.com>
325dd36 to
e06a7ae
Compare
- Fix indent-error-flow: flatten if/else after early return - Fix empty-block: add log message for 404 case instead of empty block - Fix TestDriverCreateFileShare: non-404 error now skips creation (assumes share exists) instead of proceeding to create Signed-off-by: andyzhangx <xiazhang@microsoft.com>
Instead of assuming the share exists when GetFileShareQuota returns a non-404, non-retriable error (e.g. 403 Forbidden), proceed to call Create. This avoids silently skipping share creation when the check itself fails due to insufficient permissions or other transient issues.
Remove special handling for 404, retriable, and non-retriable errors. Any error from GetFileShareQuota simply falls through to CreateFileShare, keeping the logic minimal and letting Create handle all error scenarios.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CreateFileShareunconditionally calls theCreateAPI even for pre-existing shares, requiring write permissions in all cases. This prevents scenarios where an existing share should only need read access.Changes
pkg/azurefile/azurefile.go: Before callingfileClient.CreateFileShare, callGetFileShareQuota(a read-only operation) to check existence. If the share already exists, skipCreateentirely.pkg/azurefile/azurefile_test.go: AddedTestDriverCreateFileSharecovering three cases: share exists (Create skipped), share absent (Create called),GetFileShareQuotaerror (Create called as fallback).Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
test.file.ut/tmp/go-build2833821331/b001/azurefile.test /tmp/go-build2833821331/b001/azurefile.test -test.testlogfile=/tmp/go-build2833821331/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.run=TestDriverCreateFileShare|TestGetFileShareQuota -test.v=true driver/azurefile-ifaceassert ux-amd64/pkg/tool/linux_amd64/vet ibrary-for-go/ap/home/REDACTED/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.0.linux-amd64/pkg/too-buildtags .io/otel/attribu-atomic mpile ux-amd64/pkg/too-buildtags -o driver/azurefile-errorsas .cfg ux-amd64/pkg/tool/linux_amd64/vet /virtualnetworkl/home/REDACTED/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.0.linux-amd64/pkg/too-buildtags /virtualnetworkl-atomic mpile ux-amd64/pkg/too-buildtags(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.