Merge pull request #43016 from liggitt/time-added-pointer

Automatic merge from submit-queue (batch tested with PRs 43016, 50503, 51281, 51518, 51582). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>..

Omit timeAdded from taint when empty

Fixes omitempty portion of https://github.com/kubernetes/kubernetes/issues/42394
This commit is contained in:
Kubernetes Submit Queue 2017-09-22 23:35:52 -07:00 committed by GitHub
commit 1c0f22ea01
11 changed files with 740 additions and 709 deletions

View File

@ -49,7 +49,7 @@ func TestMarkMaster(t *testing.T) {
"master label and taint missing", "master label and taint missing",
"", "",
nil, nil,
"{\"metadata\":{\"labels\":{\"node-role.kubernetes.io/master\":\"\"}},\"spec\":{\"taints\":[{\"effect\":\"NoSchedule\",\"key\":\"node-role.kubernetes.io/master\",\"timeAdded\":null}]}}", "{\"metadata\":{\"labels\":{\"node-role.kubernetes.io/master\":\"\"}},\"spec\":{\"taints\":[{\"effect\":\"NoSchedule\",\"key\":\"node-role.kubernetes.io/master\"}]}}",
}, },
{ {
"master label missing", "master label missing",
@ -61,7 +61,7 @@ func TestMarkMaster(t *testing.T) {
"master taint missing", "master taint missing",
kubeadmconstants.LabelNodeRoleMaster, kubeadmconstants.LabelNodeRoleMaster,
nil, nil,
"{\"spec\":{\"taints\":[{\"effect\":\"NoSchedule\",\"key\":\"node-role.kubernetes.io/master\",\"timeAdded\":null}]}}", "{\"spec\":{\"taints\":[{\"effect\":\"NoSchedule\",\"key\":\"node-role.kubernetes.io/master\"}]}}",
}, },
{ {
"nothing missing", "nothing missing",

View File

@ -2229,7 +2229,7 @@ type Taint struct {
// TimeAdded represents the time at which the taint was added. // TimeAdded represents the time at which the taint was added.
// It is only written for NoExecute taints. // It is only written for NoExecute taints.
// +optional // +optional
TimeAdded metav1.Time TimeAdded *metav1.Time
} }
type TaintEffect string type TaintEffect string

View File

@ -5101,7 +5101,7 @@ func autoConvert_v1_Taint_To_api_Taint(in *v1.Taint, out *api.Taint, s conversio
out.Key = in.Key out.Key = in.Key
out.Value = in.Value out.Value = in.Value
out.Effect = api.TaintEffect(in.Effect) out.Effect = api.TaintEffect(in.Effect)
out.TimeAdded = in.TimeAdded out.TimeAdded = (*meta_v1.Time)(unsafe.Pointer(in.TimeAdded))
return nil return nil
} }
@ -5114,7 +5114,7 @@ func autoConvert_api_Taint_To_v1_Taint(in *api.Taint, out *v1.Taint, s conversio
out.Key = in.Key out.Key = in.Key
out.Value = in.Value out.Value = in.Value
out.Effect = v1.TaintEffect(in.Effect) out.Effect = v1.TaintEffect(in.Effect)
out.TimeAdded = in.TimeAdded out.TimeAdded = (*meta_v1.Time)(unsafe.Pointer(in.TimeAdded))
return nil return nil
} }

View File

@ -5903,7 +5903,15 @@ func (in *TCPSocketAction) DeepCopy() *TCPSocketAction {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Taint) DeepCopyInto(out *Taint) { func (in *Taint) DeepCopyInto(out *Taint) {
*out = *in *out = *in
in.TimeAdded.DeepCopyInto(&out.TimeAdded) if in.TimeAdded != nil {
in, out := &in.TimeAdded, &out.TimeAdded
if *in == nil {
*out = nil
} else {
*out = new(v1.Time)
(*in).DeepCopyInto(*out)
}
}
return return
} }

View File

@ -63,17 +63,22 @@ var (
noExecuteTaints = []v1.Taint{{Key: "dedicated", Value: "user1", Effect: "NoExecute"}} noExecuteTaints = []v1.Taint{{Key: "dedicated", Value: "user1", Effect: "NoExecute"}}
) )
func nowPointer() *metav1.Time {
now := metav1.Now()
return &now
}
var ( var (
nodeNotReady = []v1.Taint{{ nodeNotReady = []v1.Taint{{
Key: algorithm.TaintNodeNotReady, Key: algorithm.TaintNodeNotReady,
Effect: v1.TaintEffectNoExecute, Effect: v1.TaintEffectNoExecute,
TimeAdded: metav1.Now(), TimeAdded: nowPointer(),
}} }}
nodeUnreachable = []v1.Taint{{ nodeUnreachable = []v1.Taint{{
Key: algorithm.TaintNodeUnreachable, Key: algorithm.TaintNodeUnreachable,
Effect: v1.TaintEffectNoExecute, Effect: v1.TaintEffectNoExecute,
TimeAdded: metav1.Now(), TimeAdded: nowPointer(),
}} }}
) )

View File

@ -33,11 +33,12 @@ import (
var timeForControllerToProgress = 500 * time.Millisecond var timeForControllerToProgress = 500 * time.Millisecond
func createNoExecuteTaint(index int) v1.Taint { func createNoExecuteTaint(index int) v1.Taint {
now := metav1.Now()
return v1.Taint{ return v1.Taint{
Key: "testTaint" + fmt.Sprintf("%v", index), Key: "testTaint" + fmt.Sprintf("%v", index),
Value: "test" + fmt.Sprintf("%v", index), Value: "test" + fmt.Sprintf("%v", index),
Effect: v1.TaintEffectNoExecute, Effect: v1.TaintEffectNoExecute,
TimeAdded: metav1.Now(), TimeAdded: &now,
} }
} }

View File

@ -256,7 +256,8 @@ func RecordNodeStatusChange(recorder record.EventRecorder, node *v1.Node, newSta
// otherwise. // otherwise.
func SwapNodeControllerTaint(kubeClient clientset.Interface, taintsToAdd, taintsToRemove []*v1.Taint, node *v1.Node) bool { func SwapNodeControllerTaint(kubeClient clientset.Interface, taintsToAdd, taintsToRemove []*v1.Taint, node *v1.Node) bool {
for _, taintToAdd := range taintsToAdd { for _, taintToAdd := range taintsToAdd {
taintToAdd.TimeAdded = metav1.Now() now := metav1.Now()
taintToAdd.TimeAdded = &now
} }
err := controller.AddOrUpdateTaintOnNode(kubeClient, node.Name, taintsToAdd...) err := controller.AddOrUpdateTaintOnNode(kubeClient, node.Name, taintsToAdd...)

File diff suppressed because it is too large Load Diff

View File

@ -2469,7 +2469,7 @@ type Taint struct {
// TimeAdded represents the time at which the taint was added. // TimeAdded represents the time at which the taint was added.
// It is only written for NoExecute taints. // It is only written for NoExecute taints.
// +optional // +optional
TimeAdded metav1.Time `json:"timeAdded,omitempty" protobuf:"bytes,4,opt,name=timeAdded"` TimeAdded *metav1.Time `json:"timeAdded,omitempty" protobuf:"bytes,4,opt,name=timeAdded"`
} }
type TaintEffect string type TaintEffect string

View File

@ -5905,7 +5905,15 @@ func (in *TCPSocketAction) DeepCopy() *TCPSocketAction {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Taint) DeepCopyInto(out *Taint) { func (in *Taint) DeepCopyInto(out *Taint) {
*out = *in *out = *in
in.TimeAdded.DeepCopyInto(&out.TimeAdded) if in.TimeAdded != nil {
in, out := &in.TimeAdded, &out.TimeAdded
if *in == nil {
*out = nil
} else {
*out = new(meta_v1.Time)
(*in).DeepCopyInto(*out)
}
}
return return
} }

View File

@ -36,11 +36,12 @@ import (
) )
func getTestTaint() v1.Taint { func getTestTaint() v1.Taint {
now := metav1.Now()
return v1.Taint{ return v1.Taint{
Key: "kubernetes.io/e2e-evict-taint-key", Key: "kubernetes.io/e2e-evict-taint-key",
Value: "evictTaintVal", Value: "evictTaintVal",
Effect: v1.TaintEffectNoExecute, Effect: v1.TaintEffectNoExecute,
TimeAdded: metav1.Now(), TimeAdded: &now,
} }
} }