Using the Ansible-Operator from the Operator-SDK, we have created a Custom Resource that is essentially a wrapper around a namespace and a resourceQuota called Project. In the spec of Project we can define:
requests:
cpu: "1"
memory: "120Gi"
which translates into a resourceQuota that looks like this:
kind-test-local:/# k get resourcequota -n projecta
NAME AGE REQUEST LIMIT
projecta 3m43s cpu: 0/1, memory: 0/120Gi
Now when we change the request for memory to e.g. 240Gi the resourceQuota is updated accordingly:
kind-test-local:/# k get resourcequota -n projecta
NAME AGE REQUEST LIMIT
projecta 3m46s cpu: 0/1, memory: 0/240Gi
However, when we delete the memory value in our Project CRD the 240Gi are kept...
My suspicion is that the following does not work as I would expect it (i.e. if default(omit) is set, delete the value from the resource definition):
Is there any way this can be handled with default() without needing to build a custom dictionary beforehand, where the different requests are only added to if they exist?
ISSUE TYPE
Bug Report
COMPONENT NAME
K8s version: 1.18.8
Ansible requirements:
- name: community.kubernetes
version: "=1.0.0" # locked to 1.0.0 because of issue with operator_sdk.util.k8s_status (https://github.com/operator-framework/operator-sdk-ansible-util/issues/11)
- operator_sdk.util
SUMMARY
Using the Ansible-Operator from the Operator-SDK, we have created a Custom Resource that is essentially a wrapper around a
namespace
and aresourceQuota
calledProject
. In thespec
ofProject
we can define:which translates into a
resourceQuota
that looks like this:Now when we change the request for memory to e.g.
240Gi
theresourceQuota
is updated accordingly:However, when we delete the
memory
value in ourProject
CRD the240Gi
are kept...My suspicion is that the following does not work as I would expect it (i.e. if
default(omit)
is set, delete the value from the resource definition):Is there any way this can be handled with
default()
without needing to build a custom dictionary beforehand, where the different requests are only added to if they exist?ISSUE TYPE
COMPONENT NAME
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Operator-SDK v1.5.0
STEPS TO REPRODUCE
see description
EXPECTED RESULTS
Empty fields in resourceDefinition should be omitted
ACTUAL RESULTS
The old values persist