From 7b6bb58f3ae3ce9eb43195dc25ac6f173d200be1 Mon Sep 17 00:00:00 2001 From: Mike Brown Date: Mon, 8 Jul 2019 09:24:50 -0500 Subject: [PATCH] update code docs around old todo that is not going to happen Signed-off-by: Mike Brown --- pkg/kubelet/status/status_manager.go | 12 +++++------- pkg/kubelet/status/status_manager_test.go | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pkg/kubelet/status/status_manager.go b/pkg/kubelet/status/status_manager.go index 1563ac9c67c..efbc8667924 100644 --- a/pkg/kubelet/status/status_manager.go +++ b/pkg/kubelet/status/status_manager.go @@ -582,13 +582,11 @@ func (m *manager) needsReconcile(uid types.UID, status v1.PodStatus) bool { return true } -// We add this function, because apiserver only supports *RFC3339* now, which means that the timestamp returned by -// apiserver has no nanosecond information. However, the timestamp returned by metav1.Now() contains nanosecond, -// so when we do comparison between status from apiserver and cached status, isPodStatusByKubeletEqual() will always return false. -// There is related issue #15262 and PR #15263 about this. -// In fact, the best way to solve this is to do it on api side. However, for now, we normalize the status locally in -// kubelet temporarily. -// TODO(random-liu): Remove timestamp related logic after apiserver supports nanosecond or makes it consistent. +// normalizeStatus normalizes nanosecond precision timestamps in podStatus +// down to second precision (*RFC339NANO* -> *RFC3339*). This must be done +// before comparing podStatus to the status returned by apiserver because +// apiserver does not support RFC339NANO. +// Related issue #15262/PR #15263 to move apiserver to RFC339NANO is closed. func normalizeStatus(pod *v1.Pod, status *v1.PodStatus) *v1.PodStatus { bytesPerStatus := kubecontainer.MaxPodTerminationMessageLogLength if containers := len(pod.Spec.Containers) + len(pod.Spec.InitContainers); containers > 0 { diff --git a/pkg/kubelet/status/status_manager_test.go b/pkg/kubelet/status/status_manager_test.go index c3068763fe7..b882ddfe029 100644 --- a/pkg/kubelet/status/status_manager_test.go +++ b/pkg/kubelet/status/status_manager_test.go @@ -745,7 +745,7 @@ func TestReconcilePodStatus(t *testing.T) { // If the pod status is the same, only the timestamp is in Rfc3339 format (lower precision without nanosecond), // a reconciliation is not needed, syncBatch should do nothing. // The StartTime should have been set in SetPodStatus(). - // TODO(random-liu): Remove this later when api becomes consistent for timestamp. + // This test is done because the related issue #15262/PR #15263 to move apiserver to RFC339NANO is closed. t.Logf("Syncbatch should do nothing, as a reconciliation is not required") normalizedStartTime := testPod.Status.StartTime.Rfc3339Copy() testPod.Status.StartTime = &normalizedStartTime