Skip to content

Removing every layer from spec.layers now detaches them in AWS - #240

Open
suprahh wants to merge 1 commit into
aws-controllers-k8s:mainfrom
suprahh:fix/function-layers-removal
Open

Removing every layer from spec.layers now detaches them in AWS#240
suprahh wants to merge 1 commit into
aws-controllers-k8s:mainfrom
suprahh:fix/function-layers-removal

Conversation

@suprahh

@suprahh suprahh commented Aug 27, 2026

Copy link
Copy Markdown

Issue #, if available: aws-controllers-k8s/community#3014

Description of changes

Removing every layer from spec.layers had no effect: the layers stayed
attached 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: updateFunctionConfiguration only assigned
input.Layers inside if len(dspec.Layers) > 0, so once the desired spec had
no layer left the field stayed nil. UpdateFunctionConfiguration treats an
omitted Layers as "leave them as they are" and only detaches the existing
layers when it receives an empty list.

Layers is now always set, including when the list is empty.

Verification

Run against a real AWS account (us-west-2), with the controller running
locally against a kind cluster.

Before the fix, the new test fails: after emptying spec.layers the layer is
still attached.

tests/test_function.py::TestFunction::test_function_remove_layers FAILED
>       assert "Layers" not in function["Configuration"]
E       AssertionError: assert 'Layers' not in {'FunctionName': 'functionrmlayers-...', ...}

After the fix:

tests/test_function.py::TestFunction::test_function_remove_layers PASSED
1 passed, 19 deselected, 1 warning in 124.24s

test_function_layers still passes, so replacing layers with a different
non-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) and
test_function_remove_layers all 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.

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>
@ack-prow
ack-prow Bot requested review from a-hilaly and michaelhtm August 27, 2026 14:39
@ack-prow

ack-prow Bot commented Aug 27, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: suprahh
Once this PR has been reviewed and has the lgtm label, please assign knottnt for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-prow ack-prow Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 27, 2026
@ack-prow

ack-prow Bot commented Aug 27, 2026

Copy link
Copy Markdown

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

@knottnt knottnt self-assigned this Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants