Repository navigation
Mask the Ceph key in KVM agent logs and errors - #14934
bhouse-nexthop wants to merge 1 commit into
Conversation
A failed qemu-img copy to or from RBD logged the image URI with its cephx key at ERROR. Script masked only an argument that starts with "rbd:", so the key was logged as is when the URI was inside --image-opts or a comma-joined disk list, or passed to the rbd CLI with --key. Command output that repeats the URI, such as the NAS backup script's error, went into the agent log and into the error returned to the management server. Mask the key with one helper wherever a command line, its output, a qemu-img error or an RBD file name is logged or returned. Signed-off-by: Brad House <bhouse@nexthop.ai>
|
Lab test, nested KVM lab with Ceph RBD primary storage, running a main (24.0.0-SNAPSHOT) build. The fix was tested by replacing the agents'
Not run in the lab: NAS backup/restore and template from an RBD volume (covered by the unit tests). |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14934 +/- ##
============================================
+ Coverage 18.34% 18.36% +0.02%
- Complexity 16670 16687 +17
============================================
Files 5939 5939
Lines 537814 537808 -6
Branches 65937 65935 -2
============================================
+ Hits 98637 98794 +157
+ Misses 427953 427767 -186
- Partials 11224 11247 +23
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20264 |
Description
When a
qemu-img convertto or from an RBD pool fails, the KVM agent writes the cephx key to its log: the ERROR line fromLibvirtStorageAdaptor.copyPhysicalDiskprints therbd:...:key=<key>:...URI, andScriptlogs qemu-img's error output, which repeats the URI, at WARN.Scriptmasked only an argument that starts withrbd:, so the key was also logged when the URI sits inside--image-optsor the comma-joined disk list passed tonasbackup.sh, and for therbd du ... --key <key>command run on every RBD snapshot (DEBUG).Now one helper,
StringUtils.maskCephKey, replaces the key with******and is used:Scriptfor the logged command line (it replaces the oldrbd:-only sanitizer), the error and timeout output it logs and returns, and the DEBUG output ofOutputLogger;QemuImgException, whose message becomes Answer details sent to the management server;LibvirtStorageAdaptor,LibvirtCreatePrivateTemplateFromVolumeCommandWrapper,LibvirtRestoreBackupCommandWrapper);nasbackup.shfailure output thatLibvirtTakeBackupCommandWrapperlogs and returns.The key stays on the qemu-img and rbd command lines themselves; this change is about logs and returned errors only.
Fixes: #14933
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
Before, a failed template copy to RBD (agent.log, key replaced here by
<redacted>):After:
How Has This Been Tested?
Unit tests for each path:
StringUtilsTest,ScriptTest(command line with--image-opts, a joined disk list andrbd du --key; error output ofexecuteandexecuteIgnoreExitValue),KVMStorageProcessorTest(template from an RBD volume, Answer details),LibvirtStorageAdaptorTest(NFS to RBD and RBD to RBD copies),LibvirtCreatePrivateTemplateFromVolumeCommandWrapperTest,LibvirtRestoreBackupCommandWrapperTest,LibvirtTakeBackupCommandWrapperTest.Lab test results follow in a comment.
How did you try to break this feature and the system with this change?
The pattern only matches
:key=afterrbd:and--keyin anrbdcommand, so otherkey=text such as OVSoptions:key=<id>orovstunnel --key <id>is left as is (unit tested).Script.toString()is executed as a command byQemuImg.checkAndRepair; its file there is never anrbd:URI with a key, so the masking does not change what runs.