Description
Bug Report
In Kubernetes, some resource units are automatically converted to a more convenient format internally. For example:
resources:
limits:
cpu: 2000m
Even if the CPU is set to 2000m, when you retrieve this configuration using kubectl, you might see:
resources:
limits:
cpu: 2
This indicates that the unit has been converted.
The problem arises when an Operator sets the CPU unit as 2000m
, but the Kubernetes API server keeps converting it back to 2
. This leads to a situation where, during the DependentResource.match
process, the Operator and the API server identify the resources as different, causing match to return false
.
The reason for this issue is that when comparing the actual and desired states, the values are checked through simple string comparison.
As a result, the operator keeps sending patch requests, causing the resourceVersion
to increase infinitely.
Environment
$ java -version
17
$ kubectl version
v1.24
Possible Solution
Quantity("2000m") == Quantity("2")
In fact, when using Quantity
in fabric8 for comparison, it can be determined that these two values are the same. It might be better to use Quantity
for resource comparisons. However, given the current structure, this doesn't seem straightforward. Do you think it might be possible?