Skip to content

Commit fab4c54

Browse files
committed
Updated file header to fix boilerplate error
1 parent 4825d64 commit fab4c54

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

fuzzer/cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright The Kubernetes Authors.
2+
Copyright 2026 The Kubernetes Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

fuzzer/fuzzer.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright The Kubernetes Authors.
2+
Copyright 2026 The Kubernetes Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -48,6 +48,9 @@ type ExemplaryPodFuzzer struct {
4848
// Maps BasePodName -> FuzzedPrototype
4949
mu sync.Mutex
5050
cachedPrototypes map[string]*v1.Pod
51+
52+
// rngMu protects access to the non-thread-safe rng.
53+
rngMu sync.Mutex
5154
}
5255

5356
// NewExemplaryPodFuzzer creates a new fuzzer with a seeded RNG and global settings.
@@ -163,7 +166,10 @@ func (f *ExemplaryPodFuzzer) fuzzMapRecursive(m map[string]interface{}) {
163166

164167
var newKey string
165168
if strings.HasPrefix(oldKey, "k:") {
166-
newKey = fmt.Sprintf("k:{\"id\":%d,\"name\":\"fuzzed-node-%s\"}", f.rng.Intn(100), f.randomString(4))
169+
f.rngMu.Lock()
170+
idx := f.rng.Intn(100)
171+
f.rngMu.Unlock()
172+
newKey = fmt.Sprintf("k:{\"id\":%d,\"name\":\"fuzzed-node-%s\"}", idx, f.randomString(4))
167173
} else if strings.HasPrefix(oldKey, "f:") {
168174
newKey = "f:fuzzed_field_" + f.randomString(4)
169175
} else if oldKey == "." {
@@ -187,6 +193,8 @@ func (f *ExemplaryPodFuzzer) randomString(length int) string {
187193
}
188194
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
189195
b := make([]byte, length)
196+
f.rngMu.Lock()
197+
defer f.rngMu.Unlock()
190198
for i := range b {
191199
b[i] = charset[f.rng.Intn(len(charset))]
192200
}

fuzzer/fuzzer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright The Kubernetes Authors.
2+
Copyright 2026 The Kubernetes Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)