CLI commands do not return trace ID on failure #1716
Labels
No labels
P0
P1
P2
P3
badger
frostfs-adm
frostfs-cli
frostfs-ir
frostfs-lens
frostfs-node
good first issue
triage
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-node#1716
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
CLI commands don't return trace ID on failure.
Expected Behavior
Each CLI command that supports
--trace
flag returns trace ID on both success and failure.Added debug output here.
Current Behavior
At least two commands,
object delete
andobject get
, don't return trace ID. Didn't check other commands.Possible Solution
I can't suggest a solution, but I think the problem is in misuse of some
cobra
hooks. In order to stop command span and print trace ID, we usePersistentPostRun
. Here is where we call it when a command failedif cmd.PersistentPostRun != nil {
cmd.PersistentPostRun(cmd, nil)
}
PersistentPostRun
documentation says "PersistentPostRun: children of this command will inherit and execute after PostRun". I think "will inherit" doesn't mean "will contain". Here howcobra
handles this hookceb39aba25/command.go (L1028-L1042)
.Steps to Reproduce (for bugs)
Run
object get
command on non-existing container with--trace
flag.Regression
Unlikely.
Your Environment
FrostFS CLI
Version: v0.44.0-23-gb348b202-dirty
GoVersion: go1.23.7
Introduced in
5521737f0b
.Here is the timeline:
PersistentPostRun
hook for every command.EnableTraverseHooks = true
and definePersistentPostRun
once. But error cases are, of course, not tested, so the old code stops working.Let's process post run hooks in
ExitOnErr
similarly to what we do in cobra -- this includes checkingEnableTraverseHooks
variable.