Skip to content

Commit 0461ec0

Browse files
committed
fix: provide more details on buffer overrun mode
This allows to see details of the overrun if it happens. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
1 parent b1de5a5 commit 0461ec0

14 files changed

Lines changed: 69 additions & 37 deletions

File tree

.drone.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
33
#
4-
# Generated on 2025-04-16T09:43:54Z by kres fd5cab0.
4+
# Generated on 2025-05-06T13:52:04Z by kres 1a0156b.
55

66
kind: pipeline
77
type: kubernetes
@@ -270,7 +270,7 @@ steps:
270270

271271
services:
272272
- name: docker
273-
image: docker:28.0-dind
273+
image: docker:28.1-dind
274274
entrypoint:
275275
- dockerd
276276
commands:

.golangci.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2025-04-16T09:43:54Z by kres fd5cab0.
3+
# Generated on 2025-05-06T13:52:04Z by kres 1a0156b.
44

55
version: "2"
66

@@ -48,6 +48,7 @@ linters:
4848
- protogetter # complains about us using Value field on typed spec, instead of GetValue which has a different signature
4949
- perfsprint # complains about us using fmt.Sprintf in non-performance critical code, updating just kres took too long
5050
- musttag # seems to be broken - goes into imported libraries and reports issues there
51+
- nolintlint # gives false positives - disable until https://github.com/golangci/golangci-lint/issues/3228 is resolved
5152
# all available settings of specific linters
5253
settings:
5354
cyclop:
@@ -89,11 +90,6 @@ linters:
8990
simple: true
9091
range-loops: true # Report preallocation suggestions on range loops, true by default
9192
for-loops: false # Report preallocation suggestions on for loops, false by default
92-
nolintlint:
93-
allow-unused: false
94-
allow-no-explanation: [ ]
95-
require-explanation: false
96-
require-specific: true
9793
rowserrcheck: { }
9894
testpackage: { }
9995
unparam:

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# syntax = docker/dockerfile-upstream:1.14.1-labs
1+
# syntax = docker/dockerfile-upstream:1.15.1-labs
22

33
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
44
#
5-
# Generated on 2025-04-16T09:43:54Z by kres fd5cab0.
5+
# Generated on 2025-05-06T13:52:04Z by kres 1a0156b.
66

77
ARG TOOLCHAIN
88

@@ -11,7 +11,7 @@ FROM ghcr.io/siderolabs/ca-certificates:v1.10.0 AS image-ca-certificates
1111
FROM ghcr.io/siderolabs/fhs:v1.10.0 AS image-fhs
1212

1313
# runs markdownlint
14-
FROM docker.io/oven/bun:1.2.9-alpine AS lint-markdown
14+
FROM docker.io/oven/bun:1.2.11-alpine AS lint-markdown
1515
WORKDIR /src
1616
RUN bun i markdownlint-cli@0.44.0 sentences-per-line@0.3.0
1717
COPY .markdownlint.json .

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2025-04-16T09:43:54Z by kres fd5cab0.
3+
# Generated on 2025-05-06T13:52:04Z by kres 1a0156b.
44

55
# common variables
66

@@ -22,9 +22,9 @@ GRPC_GO_VERSION ?= 1.5.1
2222
GRPC_GATEWAY_VERSION ?= 2.26.3
2323
VTPROTOBUF_VERSION ?= 0.6.0
2424
GOIMPORTS_VERSION ?= 0.32.0
25-
GOMOCK_VERSION ?= 0.5.1
25+
GOMOCK_VERSION ?= 0.5.2
2626
DEEPCOPY_VERSION ?= v0.5.6
27-
GOLANGCILINT_VERSION ?= v2.1.1
27+
GOLANGCILINT_VERSION ?= v2.1.5
2828
GOFUMPT_VERSION ?= v0.8.0
2929
GO_VERSION ?= 1.24.2
3030
GO_BUILDFLAGS ?=

pkg/controller/generic/qtransform/qtransform_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ func TestDestroyInputFinalizers(t *testing.T) {
621621

622622
// controller should remove finalizer on inputs
623623
rtestutils.AssertResources(ctx, t, st, []resource.ID{"2"}, func(r *A, assert *assert.Assertions) {
624-
assert.True(r.Metadata().Finalizers().Add("TransformABController"))
624+
assert.False(r.Metadata().Finalizers().Has("QTransformABController"))
625625
})
626626

627627
require.NoError(t, st.Destroy(ctx, NewA("2", ASpec{}).Metadata()))

pkg/controller/runtime/internal/cache/cache_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ func resourceIDGenerator(i int) resource.ID {
2828
}
2929

3030
func TestCacheOperations(t *testing.T) {
31+
metrics.CachedResources.Init()
32+
3133
ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)
3234
defer cancel()
3335

pkg/resource/protobuf/registry_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package protobuf_test
77
import (
88
"testing"
99

10+
"github.com/siderolabs/gen/ensure"
1011
"github.com/stretchr/testify/assert"
1112
"github.com/stretchr/testify/require"
1213

@@ -15,9 +16,11 @@ import (
1516
"github.com/cosi-project/runtime/pkg/state/conformance"
1617
)
1718

18-
func BenchmarkCreateResource(b *testing.B) {
19-
_ = protobuf.RegisterResource(conformance.PathResourceType, &conformance.PathResource{}) //nolint:errcheck
19+
func init() {
20+
ensure.NoError(protobuf.RegisterResource(conformance.PathResourceType, &conformance.PathResource{}))
21+
}
2022

23+
func BenchmarkCreateResource(b *testing.B) {
2124
protoR := &v1alpha1.Resource{
2225
Metadata: &v1alpha1.Metadata{
2326
Namespace: "ns",
@@ -53,8 +56,6 @@ func BenchmarkCreateResource(b *testing.B) {
5356
func TestRegistry(t *testing.T) {
5457
t.Parallel()
5558

56-
require.NoError(t, protobuf.RegisterResource(conformance.PathResourceType, &conformance.PathResource{}))
57-
5859
protoR := &v1alpha1.Resource{
5960
Metadata: &v1alpha1.Metadata{
6061
Namespace: "ns",

pkg/state/impl/inmem/collection.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,17 @@ func (collection *ResourceCollection) Watch(ctx context.Context, id resource.ID,
399399
}
400400

401401
if collection.writePos-pos > int64(collection.capacity) {
402+
collectionWritePos, collectionCapacity := collection.writePos, collection.capacity
403+
402404
collection.mu.Unlock()
403405

404406
channel.SendWithContext(ctx, ch,
405407
state.Event{
406-
Type: state.Errored,
407-
Error: fmt.Errorf("buffer overrun: namespace %q type %q", collection.ns, collection.typ),
408+
Type: state.Errored,
409+
Error: fmt.Errorf(
410+
"buffer overrun: namespace %q type %q, write pos %d, pos %d, capacity %d",
411+
collection.ns, collection.typ, collectionWritePos, pos, collectionCapacity,
412+
),
408413
},
409414
)
410415

@@ -608,11 +613,16 @@ func (collection *ResourceCollection) WatchAll(ctx context.Context, singleCh cha
608613
}
609614

610615
if collection.writePos-pos > int64(collection.capacity) {
616+
collectionWritePos, collectionCapacity := collection.writePos, collection.capacity
617+
611618
collection.mu.Unlock()
612619

613620
overrunEvent := state.Event{
614-
Type: state.Errored,
615-
Error: fmt.Errorf("buffer overrun: namespace %q type %q", collection.ns, collection.typ),
621+
Type: state.Errored,
622+
Error: fmt.Errorf(
623+
"buffer overrun: namespace %q type %q, write pos %d, pos %d, capacity %d",
624+
collection.ns, collection.typ, collectionWritePos, pos, collectionCapacity,
625+
),
616626
}
617627

618628
switch {

pkg/state/impl/inmem/local_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ watchKindChLoop:
117117

118118
// buffer overrun
119119
require.Equal(t, state.Errored, ev.Type)
120-
require.EqualError(t, ev.Error, fmt.Sprintf("buffer overrun: namespace %q type %q", namespace, conformance.PathResourceType))
120+
require.ErrorContains(t, ev.Error, fmt.Sprintf("buffer overrun: namespace %q type %q", namespace, conformance.PathResourceType))
121121

122122
break watchKindChLoop
123123
case <-time.After(time.Second):
@@ -145,7 +145,7 @@ watchLoop:
145145

146146
// buffer overrun
147147
require.Equal(t, state.Errored, ev.Type)
148-
require.EqualError(t, ev.Error, fmt.Sprintf("buffer overrun: namespace %q type %q", namespace, conformance.PathResourceType))
148+
require.ErrorContains(t, ev.Error, fmt.Sprintf("buffer overrun: namespace %q type %q", namespace, conformance.PathResourceType))
149149

150150
break watchLoop
151151
case <-time.After(time.Second):

pkg/state/impl/store/bolt/bbolt_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"path/filepath"
99
"testing"
1010

11+
"github.com/siderolabs/gen/ensure"
1112
"github.com/stretchr/testify/assert"
1213
"github.com/stretchr/testify/require"
1314
"go.etcd.io/bbolt"
@@ -19,11 +20,13 @@ import (
1920
"github.com/cosi-project/runtime/pkg/state/impl/store/bolt"
2021
)
2122

23+
func init() {
24+
ensure.NoError(protobuf.RegisterResource(conformance.PathResourceType, &conformance.PathResource{}))
25+
}
26+
2227
func TestBboltStore(t *testing.T) { //nolint:tparallel
2328
t.Parallel()
2429

25-
require.NoError(t, protobuf.RegisterResource(conformance.PathResourceType, &conformance.PathResource{}))
26-
2730
tmpDir := t.TempDir()
2831

2932
marshaler := store.ProtobufMarshaler{}

0 commit comments

Comments
 (0)