Xuanwo opened a new pull request, #9020:
URL: https://github.com/apache/opendal/pull/9020
# Which issue does this PR close?
None.
# Rationale for this change
Fix correctness bugs in `opendal-service-hdfs` and `opendal-service-smb`
covering writer close and zero-byte write handling, directory listing path
normalization, copy retryability, rename validation ordering, and HDFS
configuration normalization.
# What changes are included in this PR?
### `services/hdfs`
- Return `ErrorKind::Unexpected` (wrapping `io::ErrorKind::WriteZero`) from
`HdfsWriter::write` when the underlying `AsyncWrite` writes 0 bytes instead of
looping indefinitely.
- Consume `self.f.take()` in `HdfsWriter::close` so subsequent
`write`/`close` calls fail cleanly rather than operating on a closed handle or
panicking; drop stale `target_path_exists` tracking and ignore
`io::ErrorKind::NotFound` from `remove_file` before `rename_file`; tighten the
`unsafe impl Sync` bound to `F: Send, C: Send + Sync`.
- Normalize `atomic_write_dir` via `normalize_root` in `HdfsBuilder::build`
(filtering empty strings to `None`) so `build_rooted_absolute_path` always
receives a rooted directory with a trailing `/`.
- Reject non-file sources with `ErrorKind::IsADirectory` in
`HdfsCore::hdfs_rename`, matching `HdfsCore::hdfs_copy`.
- Normalize `HdfsLister`'s initial directory entry path to end with `/` so
`oio::Entry` invariants hold when listing a path without a trailing `/`.
- Reject empty `name_node: Some("")` with `ErrorKind::ConfigInvalid` in
`HdfsBuilder::build`.
### `services/smb`
- Normalize directory prefix separators in `SmbLister::query` via a
dedicated helper so listing a directory path without a trailing `/` emits
`<dir>/` and `<dir>/<child>` instead of dropping `/`.
- Switch `SmbBackend::copy` from `oio::OneShotCopier::new` to
`oio::OneShotCopier::new_with` so `RetryLayer` can retry transient copy
failures.
- Track explicit `Idle`/`Open`/`Closed` state in `SmbWriter` and consume the
handle on close so a closed handle is never flushed, closed twice, or reopened
and truncated.
- Open and validate the rename source as a file in `SmbBackend::rename`
before creating destination parent directories, and close the source handle if
parent creation or rename fails.
- Add unit tests and live Samba fixture regression tests covering listing
without a trailing `/`, post-close writer rejection, copy retryability, and
invalid-source rename behavior.
# Are there any user-facing changes?
- `HdfsBuilder::build` now returns `ErrorKind::ConfigInvalid` when
`name_node` is set to an empty string via config deserialization, and
normalizes `atomic_write_dir` values lacking a leading or trailing `/`.
- Calling `write` or `close` on an already-closed `HdfsWriter` or
`SmbWriter` now returns `ErrorKind::Unexpected`.
# Breaking changes
# AI Usage Statement
- Harness: pi
- Model: Gemini 4 Neon
- Effort: high
- Role: Implemented the bug fixes and tests for `core/services/hdfs` and
`core/services/smb`. Verified unit tests locally for both crates and ran the
Samba Docker fixture integration and behavior suites for `core/services/smb`.
Live HDFS cluster tests were not run locally; HDFS runtime behavior against a
cluster relies on CI coverage.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]