Skip to content

feat(hns): remove empty-dir check before folder rename#4614

Draft
PranjalC100 wants to merge 1 commit intomasterfrom
remove-empty-dir-check-hns-rename
Draft

feat(hns): remove empty-dir check before folder rename#4614
PranjalC100 wants to merge 1 commit intomasterfrom
remove-empty-dir-check-hns-rename

Conversation

@PranjalC100
Copy link
Copy Markdown
Member

Description

This PR optimizes the renameHierarchicalDir operation for Hierarchical Namespace (HNS) buckets by removing the preliminary checkDirNotEmpty validation step.

Previously, GCSFuse performed a recursive listing of the destination directory via ReadDescendants (translating to a ListObjects call with MaxResults=2) to verify it was empty before attempting a rename.

By eliminating this redundant client-side check, we shift the validation burden to the native GCS backend, which inherently rejects the action if the destination is not empty. This saves a Class A List API operation, reducing latency and operational costs for customers, while maintaining strict POSIX compliance.

This implementation covers the "Code Changes" task outlined in the HNS Folder Rename Optimization design document.

Link to the issue in case of a bug fix.

https://b.corp.google.com/issues/495920968

Testing details

  1. Manual - Ran custom Python os.rename tests against mounted HNS buckets with TRACE logs enabled. Verified that renaming to a non-empty directory natively fails and returns ENOTEMPTY without triggering any preliminary ListObjects calls.
  2. Unit tests - Updated rename and directory validation tests to align with the removed check.
  3. Integration tests - Ran existing HNS rename integration tests to ensure expected POSIX behavior is maintained.

Any backward incompatible change? If so, please explain.

No backward incompatible changes. The error propagation to the OS (e.g., ENOTEMPTY) remains functionally identical.

@PranjalC100 PranjalC100 added execute-perf-test Execute performance test in PR execute-integration-tests Run only integration tests execute-integration-tests-on-zb To run E2E tests on zonal bucket. labels Apr 13, 2026
@PranjalC100 PranjalC100 force-pushed the remove-empty-dir-check-hns-rename branch from 0e40c26 to 23376c1 Compare April 13, 2026 12:43
@PranjalC100 PranjalC100 force-pushed the remove-empty-dir-check-hns-rename branch from 23376c1 to f7305ea Compare April 13, 2026 13:07
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.65%. Comparing base (9651ba5) to head (f7305ea).
⚠️ Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
internal/fs/fs.go 50.00% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4614       +/-   ##
===========================================
+ Coverage        0   83.65%   +83.65%     
===========================================
  Files           0      164      +164     
  Lines           0    20216    +20216     
===========================================
+ Hits            0    16911    +16911     
- Misses          0     2668     +2668     
- Partials        0      637      +637     
Flag Coverage Δ
unittests 83.65% <50.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

execute-integration-tests Run only integration tests execute-integration-tests-on-zb To run E2E tests on zonal bucket. execute-perf-test Execute performance test in PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant