hierarchical-namespaces icon indicating copy to clipboard operation
hierarchical-namespaces copied to clipboard

Always show diffs in `HierarchicalResourceQuota` resources and manifests

Open summerwind opened this issue 5 months ago • 0 comments

I found a case where there is always a diff between the HierarchicalResourceQuota resource and the manifest. The following manifest can be used to reproduce the problem.

apiVersion: hnc.x-k8s.io/v1alpha2
kind: HierarchicalResourceQuota
metadata:
  name: default
  namespace: default
spec:
  hard:
    count/replicasets.apps: 1000

After applying the above manifest, the diffs obtained using kubectl diff command are as follows. It seems that the values are always diffed by replacing them with SI units.

$ kubectl diff -f hrq.yaml
diff -u -N /var/folders/5l/b5vxg_4x5mj_ty2lvlnslbph0000gp/T/LIVE-460512288/hnc.x-k8s.io.v1alpha2.HierarchicalResourceQuota.default.default /var/folders/5l/b5vxg_4x5mj_ty2lvlnslbph0000gp/T/MERGED-1098353043/hnc.x-k8s.io.v1alpha2.HierarchicalResourceQuota.default.default
--- /var/folders/5l/b5vxg_4x5mj_ty2lvlnslbph0000gp/T/LIVE-460512288/hnc.x-k8s.io.v1alpha2.HierarchicalResourceQuota.default.default	2024-09-19 16:19:25
+++ /var/folders/5l/b5vxg_4x5mj_ty2lvlnslbph0000gp/T/MERGED-1098353043/hnc.x-k8s.io.v1alpha2.HierarchicalResourceQuota.default.default	2024-09-19 16:19:25
@@ -5,14 +5,14 @@
     kubectl.kubernetes.io/last-applied-configuration: |
       {"apiVersion":"hnc.x-k8s.io/v1alpha2","kind":"HierarchicalResourceQuota","metadata":{"annotations":{},"name":"default","namespace":"default"},"spec":{"hard":{"count/replicasets.apps":1000}}}
   creationTimestamp: "2024-09-19T07:19:21Z"
-  generation: 3
+  generation: 4
   name: default
   namespace: default
   resourceVersion: "39813"
   uid: e997b707-8c33-45f6-ab01-37e4574baeec
 spec:
   hard:
-    count/replicasets.apps: 1k
+    count/replicasets.apps: 1000
 status:
   hard:
     count/replicasets.apps: 1k

The replacement to SI units is also done in ResourceQuota, but the following definition of ResourceQuota will not show any difference using kubectl diff.

apiVersion: v1
kind: ResourceQuota
metadata:
  name: default
  namespace: default
spec:
  hard:
    count/replicasets.apps: 1000

This difference in behavior causes problems with GitOps constantly causing manifest synchronization. Is this HierarchicalResourceQuota resource behavior intended?

summerwind avatar Sep 19 '24 07:09 summerwind