-
Notifications
You must be signed in to change notification settings - Fork 490
Implement support for function-timeout configuration #1852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Hey @96malhar and @philasmar, could you please review? Thanks |
This is an interesting change for the test tool and wonder if would disrupt user's debugging in other ways. For example I can see users having Is the currently struggle that the value is |
Thanks for the reply @normj! |
Hey @normj @96malhar @philasmar, Thanks |
Is there any estimate when this could be deployed? I'm also waiting for this feature. |
@normj What do you think of the idea of having an additional configuration property that can override the function-timeout during debugging sessions. This way, they can either use the configured debug timeout, the function's real timeout, or the default 15 minutes. Either way, my argument that any of these are better than the existing 0 second timeout. Also, any other recommendations such that we could get this pushed out? |
Hey @philasmar + @GarrettBeatty, |
I think that makes sense to me. @philasmar what do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements support for function-timeout configuration in the Lambda Test Tool by allowing users to specify timeout values that correlate to the number of seconds until the lambda function times out. This enables proper testing of functions that rely on ILambdaContext.RemainingTime
as a CancellationTokenSource
.
- Adds support for
function-timeout
andfunction-debugtimeout
configuration fields with fallback logic - Integrates timeout configuration into the lambda execution context
- Provides comprehensive test coverage for timeout configuration parsing with various scenarios
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
LambdaConfigFile.cs | Adds new properties for function-timeout and function-debugtimeout configuration |
LambdaFunctionInfo.cs | Adds Timeout property to store the configured timeout value |
LambdaDefaultsConfigFileParser.cs | Implements logic to parse timeout configuration with fallback behavior |
LambdaExecutor.cs | Sets the RemainingTime property in the lambda context using the configured timeout |
DefaultsFileParseTests.cs | Adds comprehensive test coverage for timeout configuration parsing |
Comments suppressed due to low confidence (5)
Tools/LambdaTestTool/tests/Amazon.Lambda.TestTool.Tests/DefaultsFileParseTests.cs:170
- The method name 'SetTimeOut' should be 'SetTimeout' to match standard .NET naming conventions where 'timeout' is a single word.
public void SetTimeOut(int? timeOut, int? debugTimeout, int expectedSeconds)
Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/LambdaConfigFile.cs:19
- The property name 'FunctionTimeOut' should be 'FunctionTimeout' to match standard .NET naming conventions where 'timeout' is a single word.
public int? FunctionTimeOut { get; set; }
Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/LambdaConfigFile.cs:21
- The property name 'FunctionDebugTimeOut' should be 'FunctionDebugTimeout' to match standard .NET naming conventions where 'timeout' is a single word.
public int? FunctionDebugTimeOut { get; set; }
Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Runtime/LambdaDefaultsConfigFileParser.cs:373
- The method name 'GetFunctionTimeOut' should be 'GetFunctionTimeout' to match standard .NET naming conventions where 'timeout' is a single word.
private static TimeSpan GetFunctionTimeOut(LambdaConfigFile configFile)
Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Runtime/LambdaDefaultsConfigFileParser.cs:375
- The property references 'FunctionDebugTimeOut' and 'FunctionTimeOut' should be 'FunctionDebugTimeout' and 'FunctionTimeout' to match standard .NET naming conventions where 'timeout' is a single word.
var configValue = configFile.FunctionDebugTimeOut ?? configFile.FunctionTimeOut;
The V1 version of the test tool which is what @UnholyRanger is using supports reading the config from either the JSON config file or the CloudFormation template. If we do this PR of adding a debug timeout then we have an inconsistency with the CloudFormation version. I think in that situation we would have to allow setting the debug timeout in the CloudFormation template's metadata. Then there is the getting the value read from both JSON and YAML based templates. In the V2 version which is what we do with the .NET Aspire integration. It does default to 15 minutes for the timeout. In v2 the could at pretty easily extend it to allow setting default timeout on the emulator. Something like this: builder.AddAWSLambdaServiceEmulator(new LambdaEmulatorOptions
{
DefaultFunctionTimeout = TimeSpan.FromMinutes(10)
}); To do it at a per function level in V2 we would need to do some rework to pass the function configuration into the emulator. @UnholyRanger Given we really want to move V2 to get past some of V1's architecture problems would the 15 minute default it uses today and if we make the default timeout configurable would that solve your needs? |
A 15-minute timeout is perfectly fine for what I need; it doesn't even need to be configurable. That may be a nice follow-up feature. |
Issue #665
Description of changes:
The templates deploy a
function-timeout
field which should correlate to the number of seconds until the lambda function times out and exits. This is a requirement for functions that rely on theILambdaContext.RemainingTime
as aCancellationTokenSoucre
. The remaining time is always set toTimeSpan.Zero
currently making it harder to test, or requiring to break and manually set the value.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.