Skip to content

Add a test to validate changing code and env vars - #204

Closed
willthames wants to merge 2 commits into
aws-controllers-k8s:mainfrom
willthames:add-code-and-config-test
Closed

Add a test to validate changing code and env vars#204
willthames wants to merge 2 commits into
aws-controllers-k8s:mainfrom
willthames:add-code-and-config-test

Conversation

@willthames

Copy link
Copy Markdown

Description of changes:

Create a test that updates both function code and environment variables at the same time.

In theory, both should work, but there is currently a bug that means that only the code gets updated. This test should allow validation of any fix.

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

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-prow
ack-prow Bot requested review from a-hilaly and jlbutler February 25, 2026 04:07
@ack-prow

ack-prow Bot commented Feb 25, 2026

Copy link
Copy Markdown

Hi @willthames. 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/test-infra repository.

@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 Feb 25, 2026
@willthames
willthames force-pushed the add-code-and-config-test branch from 493c1c8 to 04634c5 Compare February 25, 2026 04:30
@willthames

Copy link
Copy Markdown
Author

This is based on #203 because the test suite doesn't work for me without #203 (for this test, the main problem is non-matching sha256 hashes)

If #203 is rejected then I can unpick the changes but won't be able to validate that the tests succeed locally!

@AlJohri

AlJohri commented Apr 7, 2026

Copy link
Copy Markdown

@a-hilaly @aws-controllers-k8s/lambda-maintainer can this PR get a /ok-to-test?

Add setup.sh, pickle.sh and teardown.sh scripts to help manage test
infrastructure

Update all configuration to allow flexible regions (no longer
hard-coding to us-west-2)

Update S3 object hash management to store checksum alongside S3
object and use that to validate lambda hashes.
Create a test that updates both function code and environment
variables at the same time.

In theory, both should work, but there is currently a bug that
means that only the code gets updated. This test should allow
validation of any fix.
@willthames
willthames force-pushed the add-code-and-config-test branch from 04634c5 to 2fb62b9 Compare August 24, 2026 04:32
@ack-prow

ack-prow Bot commented Aug 24, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: willthames
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

@willthames

Copy link
Copy Markdown
Author

Superseded by #237 - once that's merged, this can be closed

ack-prow Bot pushed a commit that referenced this pull request Aug 25, 2026
…nger left partially unapplied (#237)

Issue #, if available: [1968](aws-controllers-k8s/community#1968)

Description of changes:

**Problem**

When a single kubectl apply updates both a Function's code (spec.code.sha256 / architectures / code.imageURI) and its configuration (e.g. spec.environment), only the code change was applied. The configuration change was silently dropped until the next full resync (~10h) or the next manual spec edit, even though the resource reported ACK.ResourceSynced=True.

**Root cause**

customUpdateFunction intentionally issues either UpdateFunctionCode or UpdateFunctionConfiguration in a single reconcile, never both, because either async call puts the function into an updating state and Lambda rejects a second concurrent update. After issuing the code update the Function's status is read as Active which is considered a synced state by the controller. As a result the controller failed to requeue to apply the configuration updates and instead waited the default re-sync duration.

**Fix**

Derive whether both a code and a configuration change were requested directly from the delta passed into customUpdateFunction, and requeue only in that combined case:

- Reconcile 1 applies the code change and requeues after 30s (keeping ResourceSynced=False).
- Reconcile 2 sees the code has settled (code delta gone) and applies the deferred configuration change; no requeue.
- Reconcile 3 has an empty delta → ResourceSynced=True.

Code-only, config-only, and architectures-only updates each apply everything in a single call and do not requeue, so their behavior is unchanged.

Fix is similar to work done in #151 

**Testing**

Added e2e regression test test_function_update_code_and_environment_variable, which patches code.sha256 + code.s3Key + environment in one update and waits on ACK.ResourceSynced=True (long enough to span the 30s requeue) before asserting both the new CodeSha256 and the environment variables are applied. This test fails on main (env var dropped) and passes with the fix. Test is based on #204 work done by @willthames

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
@willthames willthames closed this Aug 25, 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