Skip to content

fix(ll-driver-detect): detect config write failures in saveConfig - #2120

Open
chennaji9 wants to merge 2 commits into
OpenAtom-Linyaps:masterfrom
chennaji9:fix/driver-detect-config-save-failure
Open

chennaji9 wants to merge 2 commits into
OpenAtom-Linyaps:masterfrom
chennaji9:fix/driver-detect-config-save-failure

Conversation

@chennaji9

Copy link
Copy Markdown

What does this PR do?

DriverDetectionConfigManager::saveConfig() only detected that the output file failed to OPEN:

std::ofstream file(configFilePath);
if (!file.is_open()) {
    return false;
}
file << jsonConfig.dump(4);
file.close();
return true;

If the write or close fails afterwards (ENOSPC, quota, read-only mount), the stream enters a failed state but the function still returns true — the user's "never remind me again" choice silently fails to persist.

Check the stream state after closing and return false on failure (with a warning log), so callers can react.

Validation

  • New unit test DriverDetectionConfigTest.SaveConfigFailsOnWriteError constructs the manager with /dev/full (opens fine, writes fail with ENOSPC) and asserts saveConfig() returns false. On systems without /dev/full the open itself fails, so the assertion holds either way.
  • All existing driver-detection config tests still pass: ctest -R DriverDetectionConfig → 7/7 Passed (DefaultConstruction, ConfigManagerConstruction, LoadNonExistentConfig, SaveAndLoadConfig, round-trip included, plus the new one).
  • Full ll-tests target builds cleanly with the change.

🤖 Generated with Claude Code

@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

Hi @chennaji9. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...s/ll-driver-detect/src/driver_detection_config.cpp 66.66% 0 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
...s/ll-driver-detect/src/driver_detection_config.cpp 37.14% <66.66%> (+9.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

saveConfig() only checked that the file opened; a failed write or close
(e.g. ENOSPC) still returned true so the user's choice could silently
fail to persist. Check the stream state after closing and return false
on failure. Add a unit test using /dev/full.

Signed-off-by: 陈那几 <2078634206@qq.com>
Extend the modified source file copyright range to 2026 and use the
single current year for the newly added test file, as required by the
SPDX Year Range Checker in the license-check workflow. No code change.

Signed-off-by: 陈那几 <2078634206@qq.com>
@chennaji9
chennaji9 force-pushed the fix/driver-detect-config-save-failure branch from 00fcbc5 to 7e34b3e Compare October 13, 2026 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants