Open henrique-freitas opened 12 months ago
This resource is currently based on Terraform. It is possible the default value of enforceOnKey ("ALL") was populated back into spec thus causing the 400 error.
Could you try adding cnrm.cloud.google.com/state-into-spec: absent
and see if it helps?
This behavior is due to the underlying Terraform. They specifically asked users to set "enforce_on_key" to empty string when using "enforce_on_key_configs".
@jingyih Good spot! In that case I am not sure if the state-into-spec
annotation will help. We could potentially patch the Terraform provider to solve this friction.
@jingyih Good spot! In that case I am not sure if the
state-into-spec
annotation will help. We could potentially patch the Terraform provider to solve this friction.
i added the annotationcnrm.cloud.google.com/state-into-spec: absent
just to test, and the error persist
It is enforced by the underlying library. So please set "enforece_on_key" to empty string if you are using "enforce_on_key_configs".
The requirement imposed by the underlying library seems counterintuitive. We are currently discussing regarding potential strategies to address and mitigate this issue.
Checklist
Bug Description
We started the task of managing the cloud resources we have using the config connector. The API behaves strangely when creating or updating the resource. in both cases the API rejects the call with
Invalid value for field 'resource.rateLimitOptions.enforceOnKeyConfigs, Only one of enforceOnKey and enforceOnKeyConfigs can be specified
even when we create the policy manually in the Google Cloud console and export it using the command
config-connector export "//compute.googleapis.com/projects/my-project-id/global/securityPolicies/my-test-policy-2" --output my-test-policy-2.yaml
, and trying to apply using kubectl apply we received the same error.In the documentation ComputeSecurityPolicy there is a optional string field called
enforceOnKey
In export command this field is not shown in the yaml file, we decided to put it with an empty valueenforceOnKey: ""
and after that it worked normally without the error above, even though it was described as optional, it was a solution we found to solve the problem for now.Additional Diagnostic Information
Without the optional field
enforceOnKey: ""
set, returns :Message: Update call failed: error applying desired state: summary: Error updating SecurityPolicy "my-project-id": googleapi: Error 400: Invalid value for field 'resource.rateLimitOptions.enforceOnKeyConfigs': ''. Only one of enforceOnKey and enforceOnKeyConfigs can be specified., invalid
Kubernetes Cluster Version
v1.27
Config Connector Version
1.111.0
Config Connector Mode
cluster mode
Log Output
Warning UpdateFailed 5m13s (x4253 over 5d23h) computesecuritypolicy-controller Update call failed: error applying desired state: summary: Error updating SecurityPolicy "my-project-id": googleapi: Error 400: Invalid value for field 'resource.rateLimitOptions.enforceOnKeyConfigs': ''. Only one of enforceOnKey and enforceOnKeyConfigs can be specified., invalid
Steps to reproduce the issue
then kubectl apply -f file.yaml -n "your-namespace"
YAML snippets