Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ceph: print the c-v output when inventory command fails #8971

Merged
merged 1 commit into from Oct 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/util/sys/device.go
Expand Up @@ -407,13 +407,13 @@ func inventoryDevice(executor exec.Executor, devicePath string) (CephVolumeInven
args := []string{"inventory", "--format", "json", devicePath}
inventory, err := executor.ExecuteCommandWithOutput("ceph-volume", args...)
if err != nil {
return CVInventory, fmt.Errorf("failed to execute ceph-volume inventory on disk %q. %v", devicePath, err)
return CVInventory, fmt.Errorf("failed to execute ceph-volume inventory on disk %q. %s. %v", devicePath, inventory, err)
Copy link
Member

@travisn travisn Oct 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it fails, will the inventory even be set? In general I wouldn't expect it to be, but if it is I guess it would help to log and it won't hurt to log if it is empty.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inventory won't be there but what we call inventory is just the output of the command so it's still valuable even on failures.

}

bInventory := []byte(inventory)
err = json.Unmarshal(bInventory, &CVInventory)
if err != nil {
return CVInventory, fmt.Errorf("error unmarshalling json data coming from ceph-volume inventory %q. %v", devicePath, err)
return CVInventory, fmt.Errorf("failed to unmarshal json data coming from ceph-volume inventory %q. %q. %v", devicePath, inventory, err)
}

return CVInventory, nil
Expand Down