kubernetes: copylock vet errors in staging files
https://github.com/kubernetes/kubernetes/pull/109184 found that our vet checks are not running under the /staging dir.
Once it ran those checks, it revealed exposure to real issues in non-test files:
staging/src/k8s.io/apimachinery/pkg/util/managedfields/gvkparser.go:61:39: copylocks: literal copies lock value from *typeSchema: sigs.k8s.io/structured-merge-diff/v4/schema.Schema contains sync.Once contains sync.Mutex (govet)
staging/src/k8s.io/component-base/metrics/counter.go:215:15: copylocks: literal copies lock value from *v: k8s.io/component-base/metrics.CounterVec contains k8s.io/component-base/metrics.lazyMetric contains sync.RWMutex (govet)
staging/src/k8s.io/component-base/metrics/gauge.go:192:24: copylocks: newGaugeFunc passes lock by value: k8s.io/component-base/metrics.GaugeOpts contains sync.Once contains sync.Mutex (govet)
func newGaugeFunc(opts GaugeOpts, function func() float64, v semver.Version) GaugeFunc {
^
staging/src/k8s.io/component-base/metrics/gauge.go:208:24: copylocks: NewGaugeFunc passes lock by value: k8s.io/component-base/metrics.GaugeOpts contains sync.Once contains sync.Mutex (govet)
func NewGaugeFunc(opts GaugeOpts, function func() float64) GaugeFunc {
^
staging/src/k8s.io/component-base/metrics/gauge.go:211:22: copylocks: call of newGaugeFunc copies lock value: k8s.io/component-base/metrics.GaugeOpts contains sync.Once contains sync.Mutex (govet)
staging/src/k8s.io/component-base/metrics/gauge.go:218:13: copylocks: literal copies lock value from *v: k8s.io/component-base/metrics.GaugeVec contains k8s.io/component-base/metrics.lazyMetric contains sync.RWMutex (govet)
staging/src/k8s.io/component-base/metrics/histogram.go:202:17: copylocks: literal copies lock value from *v: k8s.io/component-base/metrics.HistogramVec contains k8s.io/component-base/metrics.lazyMetric contains sync.RWMutex (govet)
staging/src/k8s.io/component-base/metrics/metric.go:172:26: copylocks: assignment copies lock value to r.markDeprecationOnce: sync.Once contains sync.Mutex (govet)
staging/src/k8s.io/component-base/metrics/metric.go:173:17: copylocks: assignment copies lock value to r.createOnce: sync.Once contains sync.Mutex (govet)
staging/src/k8s.io/component-base/metrics/summary.go:196:15: copylocks: literal copies lock value from *v: k8s.io/component-base/metrics.SummaryVec contains k8s.io/component-base/metrics.lazyMetric contains sync.RWMutex (govet)
While it looks like many of these were present in previous releases, copying locks by value breaks them. These should be fixed to ensure we don’t race/panic.
/milestone v1.24
_Originally posted by @liggitt in https://github.com/kubernetes/kubernetes/issues/109184#issuecomment-1084528954_
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 18 (16 by maintainers)
Commits related to this issue
- fix remove implicit copy of a lock addressing #109197 fix packag enaming — committed to alexzielenski/kubernetes by alexzielenski 2 years ago
- fix remove implicit copy of a lock addressing #109197 fix packag enaming — committed to muyangren2/kubernetes by alexzielenski 2 years ago
/sig instrumentation for metrics files /assign @dashpole for routing
/sig api-machinery for managedfields file /assign @apelisse for routing
/priority important-soon