fix(utils): report buffered file write failures - #1793
Conversation
Close the output stream before reporting success so failures surfaced during flush or close, such as ENOSPC from /dev/full, are returned to callers. Add a regression test for the delayed write-error path. Signed-off-by: 做着百万梦的鱼 <yangzihao_41@outlook.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: unbridled-41 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 |
|
Hi @unbridled-41. Thanks for your PR. I'm waiting for a OpenAtom-Linyaps member to verify that this patch is reasonable to test. If it is, they should reply with 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/test-infra repository. |
Summary
Return an error when a buffered file write fails during stream flush or close.
Root cause
writeFile()checkedout.bad()immediately after inserting data into the stream. A buffered stream can accept the insertion and only surface an error while flushing or closing, so callers could receive success even though the file contents were not written.A reproducible example is
/dev/full: it opens successfully but reportsENOSPCwhen buffered data is flushed.Changes
/dev/full, skipped on platforms where it is unavailable.Reproduction
Call
linglong::utils::writeFile("/dev/full", "test data")on Linux. Before this change it could report success; after this change it returns an error.Test plan
ll-tests --gtest_filter='FileTest.WriteFileToDevFull'git diff --check