Layers added to a Function that has no layers in AWS are no longer ignored - #239
Layers added to a Function that has no layers in AWS are no longer ignored#239suprahh wants to merge 2 commits into
Conversation
sdkFind() builds the latest resource from a deep copy of the desired one. When GetFunction returns no layer, only Status.LayerStatuses was cleared, so Spec.Layers kept the desired value. desired and latest were then identical, no delta was computed for Spec.Layers and updateFunctionConfiguration skipped the field, leaving the resource marked as synced while AWS was never updated. Clear Spec.Layers as well, so the latest resource reflects the actual state in AWS and the delta is computed. The existing e2e test creates the function with layers already attached, so it never covered this path. Add a test that starts from a function without layers and then adds them. Issue #, if available: aws-controllers-k8s/community#3010 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. |
|
Cool to have it in the next release! Kudos @suprahh |
Issue #, if available: aws-controllers-k8s/community#3010
Description of changes
Adding layers to a Function that has no layers in AWS had no effect: the resource
was marked as synced and
UpdateFunctionConfigurationwas never called with theLayersparameter.sdkFind()builds the latest resource from a deep copy of the desired one. WhenGetFunctionreturns no layer, theelsebranch only clearedStatus.LayerStatusesand leftSpec.Layersholding the desired value inheritedfrom that deep copy.
desiredandlatestwere then identical, sodelta.DifferentAt("Spec.Layers")never became true and the guard inupdateFunctionConfigurationskipped the field.Clearing
Spec.Layersas well makes the latest resource reflect the actual statein AWS, so the delta is computed. The code lives in the
sdk_read_one_post_set_outputhook template and is injected intopkg/resource/function/sdk.go, so both files carry the same change. Nothing wasregenerated, so
ack-generate-metadata.yamlis untouched (same approach as #174).Why the existing e2e test did not catch it
test_function_layerscreates the function with layers already attached and onlyreplaces them, so the
elsebranch is never exercised. This addstest_function_add_layers_to_function_without_layers, which starts from afunction without layers and then adds them.
Verification
Run against a real AWS account in
us-west-2. Before the fix the new test failswith
KeyError: 'Layers'; after the fix it passes.test_function_layersstillpasses, so replacing existing layers is unaffected.
Also reproduced the original adoption scenario by hand: a Function adopted with no
layers in AWS and patched with
spec.layersreportedACK.ResourceSynced=Truewith an empty
status.layerStatuseswhile AWS still hadLayers: null. Runningthe fixed controller against the same CR, without touching it, attached the layers.
By submitting this pull request, I confirm that my contribution is made under the
terms of the Apache 2.0 license.