-
Notifications
You must be signed in to change notification settings - Fork 39.6k
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
Add conversion to properly parse query parameter propagationPolicy #63414
Conversation
can you add a test for this? |
@liggitt do we want a unit test for the conversion function, or do we have some place to test the behavior of api server delete handler? |
unit test for the conversion function added |
|
||
// Convert_Slice_string_To_v1_DeletionPropagation allows converting a URL query parameter propagationPolicy | ||
func Convert_Slice_string_To_v1_DeletionPropagation(input *[]string, out *DeletionPropagation, s conversion.Scope) error { | ||
if len(*input) > 0 { |
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.
Don't you need to check if *input
is nil
first?
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.
We don't check if *input
and *output
are nil
in conversion functions, e.g. https://github.com/kubernetes/kubernetes/blob/7e75a09db6dc13218b4f5e06493115ae96f83774/staging/src/k8s.io/apimachinery/pkg/runtime/conversion.go
https://github.com/kubernetes/kubernetes/blob/7e75a09db6dc13218b4f5e06493115ae96f83774/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1beta1/conversion.go
I will take another look to see where is it enforced.
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.
It's enforced by
func (c *Converter) doConversion(src, dest interface{}, flags FieldMatchingFlags, meta *Meta, f conversionFunc) error { |
through
kubernetes/staging/src/k8s.io/apimachinery/pkg/conversion/helper.go
Lines 27 to 39 in bed4531
func EnforcePtr(obj interface{}) (reflect.Value, error) { | |
v := reflect.ValueOf(obj) | |
if v.Kind() != reflect.Ptr { | |
if v.Kind() == reflect.Invalid { | |
return reflect.Value{}, fmt.Errorf("expected pointer, but got invalid kind") | |
} | |
return reflect.Value{}, fmt.Errorf("expected pointer, but got %v type", v.Type()) | |
} | |
if v.IsNil() { | |
return reflect.Value{}, fmt.Errorf("expected pointer, but got nil") | |
} | |
return v.Elem(), nil | |
} |
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.
Ok thanks 👍
@liggitt Would like another round of review :) |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: liggitt, roycaihw The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Review the full test history for this PR. Silence the bot with an |
@roycaihw: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
What this PR does / why we need it:
This delete request query parameter has been broken for a year. I'm not sure if we want to deprecate the non-standard DeleteOptions body on delete request eventually.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #43329
Special notes for your reviewer:
Release note:
/sig api-machinery