Skip to content

log-format-json throws panic in v0.5.0 #312

@montaguethomas

Description

@montaguethomas

Describe the bug
When trying to use the -log-format-json=true flag, kms panics:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xafb309]

goroutine 1 [running]:
k8s.io/component-base/logs/json.(*nopSync).Write(0x8?, {0xc0000fec00?, 0x0?, 0xc9a865?})
	<autogenerated>:1 +0x29
go.uber.org/zap/zapcore.(*lockedWriteSyncer).Write(0xc000352990, {0xc0000fec00?, 0x23348a0?, 0x12a8c20?})
	/go/pkg/mod/go.uber.org/[email protected]/zapcore/write_syncer.go:66 +0x72
go.uber.org/zap/zapcore.(*ioCore).Write(0xc00031d260, {0x0, {0xc1461a375222ccdc, 0x23348a0, 0x12a8c20}, {0x0, 0x0}, {0xc9df10, 0xf}, {0x1, ...}, ...}, ...)
	/go/pkg/mod/go.uber.org/[email protected]/zapcore/core.go:99 +0xb5
go.uber.org/zap/zapcore.(*CheckedEntry).Write(0xc00035a1a0, {0xc000364000, 0x2, 0x2})
	/go/pkg/mod/go.uber.org/[email protected]/zapcore/entry.go:255 +0x1d9
github.com/go-logr/zapr.(*zapLogger).Info(0xc00031d2f0, 0x0, {0xc9df10?, 0x5a3522?}, {0xc0003564e0, 0x2, 0x2})
	/go/pkg/mod/github.com/go-logr/[email protected]/zapr.go:210 +0xa5
github.com/go-logr/logr.Logger.Info({{0xdc20c8?, 0xc00031d2f0?}, 0x0?}, {0xc9df10, 0xf}, {0xc0003564e0, 0x2, 0x2})
	/go/pkg/mod/github.com/go-logr/[email protected]/logr.go:278 +0xe4
k8s.io/klog/v2.(*loggingT).infoS(0x3?, 0x20?, {0x0?, 0x0?}, 0xc00025dad0?, {0xc9df10?, 0xdbd568?}, {0xc0003564e0, 0x2, 0x2})
	/go/pkg/mod/k8s.io/klog/[email protected]/klog.go:780 +0x113
k8s.io/klog/v2.InfoS(...)
	/go/pkg/mod/k8s.io/klog/[email protected]/klog.go:1512
github.com/Azure/kubernetes-kms/pkg/metrics.InitMetricsExporter({0xc9a865, 0xa}, {0xc9472b, 0x4})
	/workspace/pkg/metrics/exporter.go:17 +0xf6
main.main()
	/workspace/main.go:82 +0x195

Steps To Reproduce
/kubernetes-kms -log-format-json=true

Expected behavior
Does not panic

KMS Plugin for Key Vault version
v0.5.0

Kubernetes version
v1.26.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions