-
Notifications
You must be signed in to change notification settings - Fork 7
Add PATCH Request Scenario to kperf for Evaluating Latency of Mutating API Calls #187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
// Validate patch type | ||
_, ok := PatchTypeMapping[r.PatchType] | ||
if !ok { | ||
return fmt.Errorf("unknown patch type: %s (valid types: json, merge, strategic-merge)", r.PatchType) | ||
} | ||
|
||
// Validate JSON body and trim it | ||
trimmed := strings.TrimSpace(r.Body) | ||
if !json.Valid([]byte(trimmed)) { | ||
return fmt.Errorf("invalid JSON in patch body: %q", r.Body) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed #187 (comment) #187 (comment)
Move validation to Request Patch Validate()
Error handling for incorrect patch types. If an invalid patch type is provided, the system will throw following error:
kperf: idx: 0 request: unknown patch type: strategic-mergd (valid types: json, merge, strategic-merge)
return nil | ||
} | ||
|
||
var PatchTypeMapping = map[string]string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion adding function instead of exported var.
func GetCliJSONPatchType(name string) (string, bool) {
switch name {
case "json":
return "application/json-patch+json", false
...
}
You can handle it in the following-up.
Addressed #187 (comment), replace var with function for consistency as per suggestion
This PR introduces a new scenario in kperf to benchmark the latency of PATCH operations on Kubernetes resources. It focuses on measuring the performance impact of partial updates during the resource lifecycle, simulating realistic mutation patterns such as updating metadata and container specs.
Patch API Request
Patch Use Case
JSON Patch
Merge Patch
metadata.labels
field.Strategic-Merge Patch
name
using Kubernetes' strategic merge strategy.containers
.