Skip to content

kubectl diff finds differences on time field #94121

Closed
@jpmsilva

Description

@jpmsilva

What happened:
I'm trying to automate the usage of kubectl diff to check for changes that need to be applied to the cluster based on a static set of manifests.
However, for some manifests, if I run kubectl diff the output contains differences on fields called time and date, after the manifest was applied to the cluster.

I ran kubectl apply -f https://cloud.weave.works/k8s/v1.18/net.yaml.
After that, I ran kubectl diff -f https://cloud.weave.works/k8s/v1.18/net.yaml

The following output was produced (I copied just the first diff, as many more followed):

diff -u -N /tmp/LIVE-185931702/apps.v1.DaemonSet.kube-system.weave-net /tmp/MERGED-226760605/apps.v1.DaemonSet.kube-system.weave-net
--- /tmp/LIVE-185931702/apps.v1.DaemonSet.kube-system.weave-net 2020-08-20 01:02:52.435371952 +0000
+++ /tmp/MERGED-226760605/apps.v1.DaemonSet.kube-system.weave-net       2020-08-20 01:02:52.451372598 +0000
@@ -6,7 +6,7 @@
       {
         "original-request": {
           "url": "/k8s/v1.16/net.yaml",
-          "date": "Thu Aug 20 2020 01:02:44 GMT+0000 (UTC)"
+          "date": "Thu Aug 20 2020 01:02:50 GMT+0000 (UTC)"
         },
         "email-address": "[email protected]"
       }
@@ -231,7 +231,7 @@
           f:type: {}
     manager: kubectl
     operation: Update
-    time: "2020-08-20T01:02:44Z"
+    time: "2020-08-20T01:02:52Z"
   name: weave-net
   namespace: kube-system
   resourceVersion: "134873"

What you expected to happen:
No differences should be detected.

How to reproduce it (as minimally and precisely as possible):
Run kubectl apply -f https://cloud.weave.works/k8s/v1.18/net.yaml
Then run kubectl diff -f https://cloud.weave.works/k8s/v1.18/net.yaml

Anything else we need to know?:
This does not happen to all manifests.

If I try with the manifest https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.3.7/components.yaml no differences are detected.

I also tried with manifests loaded from disk, and was able to reproduce the behavior with the following manifest:

apiVersion: v1
kind: LimitRange
metadata:
  name: default-limit-range
spec:
  limits:
  - default:
      cpu: 1
      memory: 2Gi
    defaultRequest:
      cpu: 0.5
      memory: 1Gi
    max:
      memory: 8Gi
    type: Container

With the above manifest the following occurs:

# kubectl diff -f test.yaml
diff -u -N /tmp/LIVE-129755485/v1.LimitRange.default.default-limit-range /tmp/MERGED-076660504/v1.LimitRange.default.default-limit-range
--- /tmp/LIVE-129755485/v1.LimitRange.default.default-limit-range       2020-08-20 01:07:43.195113076 +0000
+++ /tmp/MERGED-076660504/v1.LimitRange.default.default-limit-range     2020-08-20 01:07:43.199113237 +0000
@@ -0,0 +1,28 @@
+apiVersion: v1
+kind: LimitRange
+metadata:
+  creationTimestamp: "2020-08-20T01:07:43Z"
+  managedFields:
+  - apiVersion: v1
+    fieldsType: FieldsV1
+    fieldsV1:
+      f:spec:
+        f:limits: {}
+    manager: kubectl
+    operation: Update
+    time: "2020-08-20T01:07:43Z"
+  name: default-limit-range
+  namespace: default
+  selfLink: /api/v1/namespaces/default/limitranges/default-limit-range
+  uid: 42383e29-013b-43a3-a155-15c851e34bfb
+spec:
+  limits:
+  - default:
+      cpu: "1"
+      memory: 2Gi
+    defaultRequest:
+      cpu: 500m
+      memory: 1Gi
+    max:
+      memory: 8Gi
+    type: Container

# kubectl apply -f test.yaml
limitrange/default-limit-range created

# kubectl diff -f test.yaml
diff -u -N /tmp/LIVE-761467746/v1.LimitRange.default.default-limit-range /tmp/MERGED-905026905/v1.LimitRange.default.default-limit-range
--- /tmp/LIVE-761467746/v1.LimitRange.default.default-limit-range       2020-08-20 01:07:51.759458923 +0000
+++ /tmp/MERGED-905026905/v1.LimitRange.default.default-limit-range     2020-08-20 01:07:51.763459084 +0000
@@ -17,7 +17,7 @@
         f:limits: {}
     manager: kubectl
     operation: Update
-    time: "2020-08-20T01:07:49Z"
+    time: "2020-08-20T01:07:51Z"
   name: default-limit-range
   namespace: default
   resourceVersion: "135599"

Empirically, the differences observed always seem to be some seconds apart between the two versions.

Environment:

  • Kubernetes version (use kubectl version):
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.8", GitCommit:"9f2892aab98fe339f3bd70e3c470144299398ace", GitTreeState:"clean", BuildDate:"2020-08-13T16:12:48Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.8", GitCommit:"9f2892aab98fe339f3bd70e3c470144299398ace", GitTreeState:"clean", BuildDate:"2020-08-13T16:04:18Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}
  • Cloud provider or hardware configuration: baremetal

  • OS (e.g: cat /etc/os-release):

NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
  • Kernel (e.g. uname -a): Linux pluto-next 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  • Install tools:
  • Network plugin and version (if this is a network-related bug):
  • Others:

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.sig/api-machineryCategorizes an issue or PR as relevant to SIG API Machinery.sig/cliCategorizes an issue or PR as relevant to SIG CLI.wg/api-expressionCategorizes an issue or PR as relevant to WG API Expression.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions