Skip to content

Commit 3a1bde1

Browse files
authored
Ensure logger is destroyed before returning from mount command. (#2125)
1 parent 7ac0ad9 commit 3a1bde1

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
**Bug Fixes**
66
- Fix panic while reading an archived blob using file-cache ([PR #2127](https://github.com/Azure/azure-storage-fuse/pull/2127)]
7+
- Ensure logger is properly deinitialized on mount failures ([PR #2125](https://github.com/Azure/azure-storage-fuse/pull/2125)]
78

89
## 2.5.2 (2026-01-19)
910
**Features**

cmd/mount.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,12 @@ var mountCmd = &cobra.Command{
440440
return fmt.Errorf("failed to initialize logger [%s]", err.Error())
441441
}
442442

443+
// It's best to destroy the logger before we return to the caller, as caller may abruptly exit on error and we
444+
// might lose some logs in the channel which are not yet flushed to the file in case of not destroying the logger
445+
defer func() {
446+
_ = log.Destroy()
447+
}()
448+
443449
if !disableVersionCheck {
444450
err := VersionCheck()
445451
if err != nil {

main.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,11 @@ package main
3535

3636
import (
3737
"github.com/Azure/azure-storage-fuse/v2/cmd"
38-
"github.com/Azure/azure-storage-fuse/v2/common/log"
3938
)
4039

4140
//go:generate ./cmd/componentGenerator.sh $NAME
4241
// To use go:generate run command "NAME="component" go generate"
4342

4443
func main() {
45-
defer log.Destroy() // nolint:errcheck
46-
// This recovers the panics only for the functions that run within this context. all the go-routine
47-
// spawned by this function need to handle their panics separately if required. Also the FUSE callbacks
48-
// wouldn't run in this context, so the panics originated from the callbacks can't get recovered here.
49-
defer func() {
50-
if panicErr := recover(); panicErr != nil {
51-
log.Crit("PANIC: %v", panicErr)
52-
panic(panicErr)
53-
}
54-
}()
55-
5644
_ = cmd.Execute()
5745
}

0 commit comments

Comments
 (0)