Skip to content

Commit a0f264a

Browse files
aws-sam-tooling-bot[bot]lambda-tooling+rietobixleagithub-advanced-security[bot]roger-zhangg
authored
chore: sync from internal (rie-private-to-public) (aws#181)
* Update from upstream - 2026-03-18 * Update from upstream - 2026-03-18 * Update from upstream - 2026-03-18 * Update from upstream - 2026-03-19 * Update from upstream - 2026-03-19 * Potential fix for code scanning alert no. 7: Workflow does not contain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * Update from upstream - 2026-03-27 * Update from upstream - 2026-03-30 * Update from upstream - 2026-04-01 * Update from upstream - 2026-07-13 --------- Co-authored-by: lambda-tooling+rie <lambda-tooling+rie@amazon.com> Co-authored-by: tobixlea <tobixlea@amazon.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: Roger Zhang <ruojiazh@amazon.com>
1 parent 391c3f1 commit a0f264a

28 files changed

Lines changed: 293 additions & 149 deletions

‎.github/workflows/validate-branch-into-main.yaml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Check source branch
13+
env:
14+
SOURCE_BRANCH: ${{ github.head_ref }}
1315
run: |
14-
SOURCE_BRANCH="${{ github.head_ref }}"
1516
if [[ "$SOURCE_BRANCH" != "develop" ]]; then
1617
echo "Error: Only pull requests from develop branch are allowed into main"
1718
echo "Current source branch ($SOURCE_BRANCH)."

‎internal/lambda-managed-instances/aws-lambda-rie/internal/app_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestApp_ServeHTTP(t *testing.T) {
7979
defer mockApp.AssertExpectations(t)
8080
mockApp.On("Init", mock.Anything, mock.Anything, mock.Anything).Return(tt.initResponse)
8181
if tt.initResponse == nil {
82-
mockApp.On("Invoke", mock.Anything, mock.Anything, mock.Anything).Return(tt.invokeErr, tt.responseSent)
82+
mockApp.On("Invoke", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(tt.invokeErr, tt.responseSent, false)
8383
}
8484

8585
initMsg := intmodel.InitRequestMessage{

‎internal/lambda-managed-instances/aws-lambda-rie/internal/run.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func Run(supv supvmodel.ProcessSupervisor, args []string, fileUtil utils.FileUti
7575
}
7676

7777
rieApp := NewHTTPHandler(raptorApp, initMsg)
78-
s, err := raptor.StartServer(raptorApp, rieApp, &raptor.TCPAddress{AddrPort: rieAddr})
78+
s, err := raptor.StartServer(raptorApp, rieApp, &raptor.TCPAddress{AddrPort: rieAddr}, false)
7979
if err != nil {
8080
return nil, nil, nil, fmt.Errorf("could not start RIE server: %w", err)
8181
}

‎internal/lambda-managed-instances/aws-lambda-rie/internal/telemetry/README.md‎

Lines changed: 0 additions & 97 deletions
This file was deleted.

‎internal/lambda-managed-instances/aws-lambda-rie/main.go‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎internal/lambda-managed-instances/interop/sandbox_model.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ type EEStaticData struct {
253253
XRayTracingMode intmodel.XrayTracingMode
254254
ArtefactType intmodel.ArtefactType
255255
RuntimeVersion string
256+
RuntimeRelease string
256257
AmiId string
257258
AvailabilityZoneId string
258259
}

‎internal/lambda-managed-instances/interop/service_log_values.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ const (
2727
ShutdownWaitAllProcessesDuration = "WaitCustomerProcessesExitDuration"
2828
ShutdownRuntimeServerDuration = "StopRuntimeServerDuration"
2929

30+
RuntimeNextCountMetric = "RuntimeNextCount"
31+
32+
RuntimeWorkerCountMetric = "RuntimeWorkerCount"
33+
3034
ClientErrorMetric = "ClientError"
3135
ClientErrorReasonTemplate = "ClientErrorReason-%s"
3236
CustomerErrorMetric = "CustomerError"

‎internal/lambda-managed-instances/invoke/invoke_router.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ func (ir *InvokeRouter) GetRuntimePoolCounts() RuntimePoolCounts {
195195
func (ir *InvokeRouter) ReserveIdleRuntime(ctx context.Context, invokeID interop.InvokeID, timeout time.Duration) (interop.ReserveIdleRuntimeResponse, model.AppError) {
196196
logging.Debug(ctx, "InvokeRouter: reserving idle runtime")
197197

198+
if _, exists := ir.runningInvokes.Get(invokeID); exists {
199+
logging.Warn(ctx, "InvokeRouter: reservation collides with in-flight invoke")
200+
return interop.ReserveIdleRuntimeFailureResponse{ErrorType: model.ErrorDuplicatedInvokeId},
201+
model.NewClientError(ErrInvokeIdAlreadyExists, model.ErrorSeverityError, model.ErrorDuplicatedInvokeId)
202+
}
203+
198204
err := ir.runtimePool.Reserve(invokeID, timeout, func() {
199205
if ir.runtimePool.ExpireReservation(invokeID) {
200206
logging.Info(ctx, "InvokeRouter: reservation expired")

‎internal/lambda-managed-instances/invoke/invoke_router_test.go‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,29 @@ func TestReserveIdleRuntime_DuplicateInvokeID(t *testing.T) {
399399
assert.Equal(t, model.ErrorDuplicatedInvokeId, appErr.ErrorType())
400400
}
401401

402+
func TestReserveIdleRuntime_DuplicateAgainstRunningInvoke(t *testing.T) {
403+
t.Parallel()
404+
405+
mocks, router := createMocksAndInitRouter()
406+
407+
_, err := router.RuntimeNext(mocks.ctx, mocks.runtimeNextRequest)
408+
require.NoError(t, err)
409+
410+
const inFlightID = "reserve-vs-running"
411+
router.runningInvokes.Set(inFlightID, &mocks.runnningInvoke)
412+
413+
resp, appErr := router.ReserveIdleRuntime(mocks.ctx, inFlightID, 100*time.Millisecond)
414+
415+
require.NotNil(t, appErr)
416+
failResp, ok := resp.(interop.ReserveIdleRuntimeFailureResponse)
417+
assert.True(t, ok, "expected ReserveIdleRuntimeFailureResponse")
418+
assert.Equal(t, model.ErrorDuplicatedInvokeId, failResp.ErrorType)
419+
assert.Equal(t, model.ErrorDuplicatedInvokeId, appErr.ErrorType())
420+
421+
assert.Equal(t, 0, router.runtimePool.ReservedCount(), "no reservation should have been recorded")
422+
assert.Equal(t, 1, router.GetRuntimePoolCounts().Idle, "idle runtime should still be available")
423+
}
424+
402425
func TestReserveIdleRuntime_Expiration(t *testing.T) {
403426
t.Parallel()
404427

‎internal/lambda-managed-instances/invoke/reservation_metrics.go‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ import (
1313
)
1414

1515
const (
16-
ReserveSuccessMetric = "ReserveSuccess"
17-
ReserveFailedMetric = "ReserveFailed"
16+
ReserveSuccessMetric = "ReserveSuccess"
17+
ReserveFailedMetric = "ReserveFailed"
18+
ReserveParseDurationMetric = "ReserveParseDuration"
19+
ReserveLogicDurationMetric = "ReserveLogicDuration"
1820
)
1921

20-
func ReserveServiceLog(logger servicelogs.Logger, opStart time.Time, invokeID string, appErr model.AppError) {
22+
func ReserveServiceLog(logger servicelogs.Logger, opStart time.Time, invokeID string, appErr model.AppError, parseDuration, reserveDuration time.Duration) {
2123
props := []servicelogs.Property{
2224
{Name: "invoke_id", Value: invokeID},
2325
}
@@ -43,6 +45,11 @@ func ReserveServiceLog(logger servicelogs.Logger, opStart time.Time, invokeID st
4345
servicelogs.Counter(ReserveFailedMetric, failed),
4446
servicelogs.Counter(interop.ClientErrorMetric, clientErrCnt),
4547
servicelogs.Counter(interop.NonCustomerErrorMetric, nonCustomerErrCnt),
48+
servicelogs.Timer(ReserveParseDurationMetric, parseDuration),
49+
}
50+
51+
if reserveDuration > 0 {
52+
metrics = append(metrics, servicelogs.Timer(ReserveLogicDurationMetric, reserveDuration))
4653
}
4754

4855
if appErr != nil {

0 commit comments

Comments
 (0)