From 5ee5632811fcaf0d86eacc38203c0fca7243786d Mon Sep 17 00:00:00 2001 From: Nishant Burte Date: Thu, 14 Dec 2023 22:26:22 -0800 Subject: [PATCH 1/4] Route addition in routeTable changes CR spec This fix accomodates an aws api bug so as to prevent routeTable CR spec from changing. Details explained in the issue description. --- apis/v1alpha1/ack-generate-metadata.yaml | 8 ++++---- pkg/resource/route_table/sdk.go | 13 +++++++++++++ .../sdk_read_many_post_set_output.go.tpl | 12 ++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index 8d1d4144..da7552ac 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,13 +1,13 @@ ack_generate_info: - build_date: "2023-12-12T12:34:35Z" + build_date: "2023-12-15T06:34:46Z" build_hash: 3653329ceeb20015851b8776a6061a3fb0ec2935 - go_version: go1.21.0 - version: "3653329" + go_version: go1.21.1 + version: v0.27.1-6-g3653329 api_directory_checksum: d452bf19bfd1496aacdc215bf7cc9ea86c55c122 api_version: v1alpha1 aws_sdk_go_version: v1.44.93 generator_config_info: - file_checksum: df1057de840147701c11acfdbed0e28e9b0ddd96 + file_checksum: 0ea278e11a33d237e88a1bcdca878656a8ba43f9 original_file_name: generator.yaml last_modification: reason: API generation diff --git a/pkg/resource/route_table/sdk.go b/pkg/resource/route_table/sdk.go index 37b6dda4..95a79b9e 100644 --- a/pkg/resource/route_table/sdk.go +++ b/pkg/resource/route_table/sdk.go @@ -235,6 +235,19 @@ func (rm *resourceManager) sdkFind( ko.Spec.Tags = r.ko.Spec.Tags } + // Even if route is created with arguments as VPCEndpointID, + // when aws api is called to describe the route (inside skdFind), it + // returns VPCEndpointID as GatewayID. Due to this bug, spec section for + // routes is populated incorrectly in above auto-gen code. + // To solve this, if 'GatewayID' has prefix 'vpce-', then the entry is + // moved from 'GatewayID' to 'VPCEndpointID'. + for i, route := range ko.Spec.Routes { + if route.GatewayID != nil && strings.HasPrefix(*route.GatewayID, "vpce-") { + ko.Spec.Routes[i].VPCEndpointID = route.GatewayID + ko.Spec.Routes[i].GatewayID = nil + } + } + return &resource{ko}, nil } diff --git a/templates/hooks/route_table/sdk_read_many_post_set_output.go.tpl b/templates/hooks/route_table/sdk_read_many_post_set_output.go.tpl index d669b0f3..11dfec72 100644 --- a/templates/hooks/route_table/sdk_read_many_post_set_output.go.tpl +++ b/templates/hooks/route_table/sdk_read_many_post_set_output.go.tpl @@ -9,3 +9,15 @@ ko.Spec.Tags = r.ko.Spec.Tags } + // Even if route is created with arguments as VPCEndpointID, + // when aws api is called to describe the route (inside skdFind), it + // returns VPCEndpointID as GatewayID. Due to this bug, spec section for + // routes is populated incorrectly in above auto-gen code. + // To solve this, if 'GatewayID' has prefix 'vpce-', then the entry is + // moved from 'GatewayID' to 'VPCEndpointID'. + for i, route := range ko.Spec.Routes { + if route.GatewayID != nil && strings.HasPrefix(*route.GatewayID, "vpce-") { + ko.Spec.Routes[i].VPCEndpointID = route.GatewayID + ko.Spec.Routes[i].GatewayID = nil + } + } From ec0c1e102841dfbad49e9b320e31d64a414edcb4 Mon Sep 17 00:00:00 2001 From: Nishant Burte Date: Thu, 14 Dec 2023 22:26:22 -0800 Subject: [PATCH 2/4] Route addition in routeTable changes CR spec This fix accomodates an aws api bug so as to prevent routeTable CR spec from changing. Details explained in the issue description. --- apis/v1alpha1/ack-generate-metadata.yaml | 2 +- .../hooks/route_table/sdk_read_many_post_set_output.go.tpl | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index 1fdc8c62..0ae2dc3b 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,5 +1,5 @@ ack_generate_info: - build_date: "2024-09-12T18:02:26Z" + build_date: "2024-09-17T17:43:02Z" build_hash: f8f98563404066ac3340db0a049d2e530e5c51cc go_version: go1.22.6 version: v0.38.1 diff --git a/templates/hooks/route_table/sdk_read_many_post_set_output.go.tpl b/templates/hooks/route_table/sdk_read_many_post_set_output.go.tpl index e11e4e31..1969d0c1 100644 --- a/templates/hooks/route_table/sdk_read_many_post_set_output.go.tpl +++ b/templates/hooks/route_table/sdk_read_many_post_set_output.go.tpl @@ -8,7 +8,7 @@ // then assign resource's tags to maintain tag order ko.Spec.Tags = r.ko.Spec.Tags } - + // Even if route is created with arguments as VPCEndpointID, // when aws api is called to describe the route (inside skdFind), it // returns VPCEndpointID as GatewayID. Due to this bug, spec section for @@ -20,4 +20,5 @@ ko.Spec.Routes[i].VPCEndpointID = route.GatewayID ko.Spec.Routes[i].GatewayID = nil } - } \ No newline at end of file + } + From 7a9d55667d9fc65eef20bdd39c06d1ed8ebbdcd0 Mon Sep 17 00:00:00 2001 From: Nishant Burte Date: Thu, 14 Dec 2023 22:26:22 -0800 Subject: [PATCH 3/4] Route addition in routeTable changes CR spec This fix accomodates an aws api bug so as to prevent routeTable CR spec from changing. Details explained in the issue description. --- templates/hooks/route_table/sdk_read_many_post_set_output.go.tpl | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/hooks/route_table/sdk_read_many_post_set_output.go.tpl b/templates/hooks/route_table/sdk_read_many_post_set_output.go.tpl index 1969d0c1..2c613fbd 100644 --- a/templates/hooks/route_table/sdk_read_many_post_set_output.go.tpl +++ b/templates/hooks/route_table/sdk_read_many_post_set_output.go.tpl @@ -21,4 +21,3 @@ ko.Spec.Routes[i].GatewayID = nil } } - From 50e122d34193a2c492762a6fd2bd0dff2340cb48 Mon Sep 17 00:00:00 2001 From: Nishant Burte Date: Thu, 14 Dec 2023 22:26:22 -0800 Subject: [PATCH 4/4] Route addition in routeTable changes CR spec This fix accomodates an aws api bug so as to prevent routeTable CR spec from changing. Details explained in the issue description. --- apis/v1alpha1/ack-generate-metadata.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index 0ae2dc3b..2e53a7e0 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,5 +1,5 @@ ack_generate_info: - build_date: "2024-09-17T17:43:02Z" + build_date: "2024-09-17T17:53:28Z" build_hash: f8f98563404066ac3340db0a049d2e530e5c51cc go_version: go1.22.6 version: v0.38.1