Allow nested Maps in crd generation

469 views
Skip to first unread message

Vijay Tripathi

unread,
Sep 15, 2021, 4:14:55 PM9/15/21
to K8s API Machinery SIG
Hi,

TL;DR:
I wish to bring PR#518 to everyone's attention and gather knowledge on when it can be merged and What tests can i perform to validate that allowing nested maps in go types for CRD generation will not cause any issues down the line.  

Problem:
During generation of CRD using controller-gen, if go type has nested Map member(s), following error is thrown "map values must be a named type, not *ast.MapType".

As you can see on the PR, AWS and Microsoft Azure both depend on generating CRDs from their go-sdks, which in the end assists k8s customers in interacting with the cloud provider services in k8s native manner.
AWS Controllers for Kubernetes(short: ACK) uses "controller-gen" to generate these CRDs.

aws-sdk-go v1.36.17 introduced some fields which are map of maps and controller-gen error has blocked ACK team to upgrade the aws-sdk-go dependency further for apigatewayv2 controller.

Solution:
The mentioned PR#518 allows nested Maps to be supported in controller-gen. Based on the comment feedback on the PR, i created a separate PR#569 , which allows nested maps only when "allowDangerousTypes" flag is marked as true during CRD generation.

I did receive feedback in SIG meeting on 8/25/2021 to not have this support behind "allowDangerousTypes" flag, hence I am back to requesting feedback on PR#518 again and requesting validations under which  PR#518 or PR#569 can be merged to unblock ACK controller generation.

Thank you in advance!

- Vijay 

Clayton Coleman

unread,
Sep 15, 2021, 4:24:19 PM9/15/21
to Vijay Tripathi, K8s API Machinery SIG
There is nothing about Kube APIs that implies “map of map should be disallowed” (early on we discouraged certain constructs like named maps, but in retrospect we were too aggressive).

So a kube API is absolutely allowed to host a map of maps as an API at the most fundamental level unless an implementation bug or limitation sits in its way.

I would certainly not consider it “dangerous” to have a CRD with a map of maps, and if there was, that would be a great issue to fix or mitigate.

On Sep 15, 2021, at 4:07 PM, Vijay Tripathi <vijay.tri...@gmail.com> wrote:

Hi,
--
You received this message because you are subscribed to the Google Groups "K8s API Machinery SIG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-sig-api-m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kubernetes-sig-api-machinery/6512e3a6-5b14-4365-9543-b4c085867390n%40googlegroups.com.

Vijay Tripathi

unread,
Sep 16, 2021, 5:22:46 PM9/16/21
to K8s API Machinery SIG
Thank you so much for getting PR#518 merged. 
Where can I read about the release cycle for controller-tools? Or What will be the expected date of a new release which includes this change?

Thank you very much!
-Vijay

Reply all
Reply to author
Forward
0 new messages