The problem
When a certain property is wrapped in a condition and has a value of 0, condition evaulating to false in a template (property is no longer in the template), property does not get removed from the object.
Reproduction steps
Consider a following scenario: Using a NamespaceConfig you create a ResourceQuota in a project with some quota (for example persistentvolumeclaims) set with value 0.
For example:
apiVersion: v1
kind: ResourceQuota
metadata:
name: some-quota
namespace: my-namespace
spec:
hard:
persistentvolumeclaims: '0'
otherquota: '5'
You want to use it based on a condition so you write something like this:
{{- if ne (index .Annotations "allow-pvc") "true" }}
persistentvolumeclaims: '0'
{{- end }}
Then if I set the annotation so the mentioned condition returned false I see:
Actual result:
apiVersion: v1
kind: ResourceQuota
metadata:
name: some-quota
namespace: my-namespace
spec:
hard:
persistentvolumeclaims: '0'
otherquota: '5'
Expected result:
apiVersion: v1
kind: ResourceQuota
metadata:
name: some-quota
namespace: my-namespace
spec:
hard:
otherquota: '5'
Expected result can be achieved by removing the ResourceQuota object so it gets re-created by the operator. Operator does not see the difference between two mentioned resources (actual vs expected).
The problem
When a certain property is wrapped in a condition and has a value of 0, condition evaulating to false in a template (property is no longer in the template), property does not get removed from the object.
Reproduction steps
Consider a following scenario: Using a NamespaceConfig you create a ResourceQuota in a project with some quota (for example
persistentvolumeclaims) set with value0.For example:
You want to use it based on a condition so you write something like this:
Then if I set the annotation so the mentioned condition returned false I see:
Actual result:
Expected result:
Expected result can be achieved by removing the
ResourceQuotaobject so it gets re-created by the operator. Operator does not see the difference between two mentioned resources (actual vs expected).