feat(request): implement PUT for configmaps and add payloadSize to postDel#238
Merged
Conversation
xinWeiWei24
commented
Jul 1, 2026
Contributor
- Wire RequestPut through requestPutBuilder; build ConfigMap body inline and PUT to /api/v1/namespaces//configmaps/. Restricted to core/v1 configmaps (validated in load_traffic.go).
- Add payloadSize to RequestPostDel; expose it as env.PAYLOAD in pod.tpl so POST'd fake pods actually carry the configured bytes.
- Add randomPayload helper (crypto/rand, [a-zA-Z0-9]).
…stDel - Wire RequestPut through requestPutBuilder; build ConfigMap body inline and PUT to /api/v1/namespaces/<ns>/configmaps/<name>. Restricted to core/v1 configmaps (validated in load_traffic.go). - Add payloadSize to RequestPostDel; expose it as env.PAYLOAD in pod.tpl so POST'd fake pods actually carry the configured bytes. - Add randomPayload helper (crypto/rand, [a-zA-Z0-9]).
fuweid
reviewed
Jul 1, 2026
|
|
||
| // randomPayload returns a string of exactly n bytes from a printable | ||
| // alphabet, generated from crypto/rand. Returns "" when n <= 0. | ||
| func randomPayload(n int) string { |
Collaborator
There was a problem hiding this comment.
how about this?
func randomPayload(n int) string {
if n <= 0 {
return ""
}
const alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
// Only use byte values in [0, max). Since len(alphabet)=62 and
// 248 is the largest multiple of 62 below 256, mapping b%62 is uniform
// for accepted bytes. Bytes 248..255 are skipped to avoid modulo bias.
const max = byte(256 - 256%len(alphabet))
out := make([]byte, n)
bufSize := n
if bufSize > 4096 {
bufSize = 4096
}
buf := make([]byte, bufSize)
for i := 0; i < n; {
if _, err := rand.Read(buf); err != nil {
panic(fmt.Errorf("failed to read random bytes: %w", err))
}
for _, b := range buf {
if b >= max {
continue
}
out[i] = alphabet[int(b)%len(alphabet)]
i++
if i == n {
return string(out)
}
}
}
return string(out)
}
Contributor
Author
There was a problem hiding this comment.
Thanks for the feedback! Updated in the latest commit, PTAL.
fuweid
approved these changes
Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.