Removing every layer from spec.layers now detaches them in AWS - #240
Removing every layer from spec.layers now detaches them in AWS#240suprahh wants to merge 1 commit into
Conversation
Emptying spec.layers had no effect: the layers stayed attached to the function. updateFunctionConfiguration only assigned input.Layers inside `if len(dspec.Layers) > 0`, so once the desired spec had no layer left the field stayed nil and UpdateFunctionConfiguration kept the existing ones. The delta was computed correctly, the update call simply omitted the field. Always set Layers, including when the list is empty, which is how UpdateFunctionConfiguration detaches them. Add an e2e test that creates a function with a layer attached and then empties spec.layers. Signed-off-by: Carlos Gonzalez <carlos.gonzalezp838@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: suprahh The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @suprahh. Thanks for your PR. I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Issue #, if available: aws-controllers-k8s/community#3014
Description of changes
Removing every layer from
spec.layershad no effect: the layers stayedattached to the function in AWS while the resource was reported as synced.
Unlike #239, the delta is computed correctly here. The problem is in how the
update input is built:
updateFunctionConfigurationonly assignedinput.Layersinsideif len(dspec.Layers) > 0, so once the desired spec hadno layer left the field stayed nil.
UpdateFunctionConfigurationtreats anomitted
Layersas "leave them as they are" and only detaches the existinglayers when it receives an empty list.
Layersis now always set, including when the list is empty.Verification
Run against a real AWS account (
us-west-2), with the controller runninglocally against a kind cluster.
Before the fix, the new test fails: after emptying
spec.layersthe layer isstill attached.
After the fix:
test_function_layersstill passes, so replacing layers with a differentnon-empty list is unaffected.
This change is independent of #239 and can be merged in either order. I also
verified both branches merged together:
test_function_layers,test_function_add_layers_to_function_without_layers(from #239) andtest_function_remove_layersall pass on the combined tree.By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license.