-
Notifications
You must be signed in to change notification settings - Fork 38.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 custom pod conversion functions from pre-v1.1 mirror pods #16080
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,12 +24,22 @@ import ( | |
"k8s.io/kubernetes/pkg/conversion" | ||
) | ||
|
||
const ( | ||
// Annotation key used to identify mirror pods. | ||
mirrorAnnotationKey = "kubernetes.io/config.mirror" | ||
|
||
// Value used to identify mirror pods from pre-v1.1 kubelet. | ||
mirrorAnnotationValue_1_0 = "mirror" | ||
) | ||
|
||
func addConversionFuncs() { | ||
// Add non-generated conversion functions | ||
err := api.Scheme.AddConversionFuncs( | ||
convert_api_Pod_To_v1_Pod, | ||
convert_api_PodSpec_To_v1_PodSpec, | ||
convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec, | ||
convert_api_ServiceSpec_To_v1_ServiceSpec, | ||
convert_v1_Pod_To_api_Pod, | ||
convert_v1_PodSpec_To_api_PodSpec, | ||
convert_v1_ReplicationControllerSpec_To_api_ReplicationControllerSpec, | ||
convert_v1_ServiceSpec_To_api_ServiceSpec, | ||
|
@@ -386,9 +396,32 @@ func convert_v1_PodSpec_To_api_PodSpec(in *PodSpec, out *api.PodSpec, s conversi | |
} else { | ||
out.ImagePullSecrets = nil | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func convert_api_Pod_To_v1_Pod(in *api.Pod, out *Pod, s conversion.Scope) error { | ||
if err := autoconvert_api_Pod_To_v1_Pod(in, out, s); err != nil { | ||
return err | ||
} | ||
// We need to reset certain fields for mirror pods from pre-v1.1 kubelet | ||
// (#15960). | ||
// TODO: Remove this code after we drop support for v1.0 kubelets. | ||
if value, ok := in.Annotations[mirrorAnnotationKey]; ok && value == mirrorAnnotationValue_1_0 { | ||
// Reset the TerminationGracePeriodSeconds. | ||
out.Spec.TerminationGracePeriodSeconds = nil | ||
// Reset the resource requests. | ||
for i := range out.Spec.Containers { | ||
out.Spec.Containers[i].Resources.Requests = nil | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func convert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lavalamp, I don't think we need to muck with the conversion on this end since we will always reset the fields when converting to the versioned pod. Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. On Thu, Oct 22, 2015 at 12:34 PM, Yu-Ju Hong notifications@github.com
|
||
return autoconvert_v1_Pod_To_api_Pod(in, out, s) | ||
} | ||
|
||
func convert_api_ServiceSpec_To_v1_ServiceSpec(in *api.ServiceSpec, out *ServiceSpec, s conversion.Scope) error { | ||
if err := autoconvert_api_ServiceSpec_To_v1_ServiceSpec(in, out, s); err != nil { | ||
return err | ||
|
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.
I realize this is too late now, but, for the future, this should have been something like
kubelet.kubernetes.io/mirror-config
. Prefix before the slash should be at least kubelet-specific, and suffix after the slash should use dashes rather than dots.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.
Ack.