Skip to content

Every scheduled sweep fails: scheduler-handler invokes sweep-orchestrator, but the function is spawn-sweep-orchestrator #812

Closed

Description

@scttfrdmn

spawn schedule is non-functional in production. This is #790's mirror image — a
missing prefix instead of an extra one — and it is invisible to the gate added
for #790.

Verified against the live infra account

$ aws lambda get-function-configuration --function-name sweep-orchestrator
  DOES NOT EXIST

$ aws lambda get-function-configuration --function-name spawn-sweep-orchestrator
spawn-sweep-orchestrator

$ aws lambda get-function-configuration --function-name scheduler-handler \
    --query 'Environment.Variables'
  (empty — no variables at all)

The chain

lambda/scheduler-handler/main.go:27:

defaultOrchestratorFuncName = "sweep-orchestrator"

:110 allows an override — orchestratorFuncName = getEnv("SPAWN_ORCHESTRATOR_FUNCTION_NAME", defaultOrchestratorFuncName) — but scripts/deploy-scheduler-handler.sh sets no environment whatsoever (grep for --environment and the variable name: 0 hits), and the live function confirms none is set.

:178 then builds the ARN and invokes it:

orchestratorArn := fmt.Sprintf("arn:aws:lambda:%s:%s:function:%s", schedule.Region, accountID, orchestratorFuncName)

So every scheduled execution calls arn:…:function:sweep-orchestrator and gets
ResourceNotFoundException.

Every other reference in the repo uses the prefixed name —
pkg/infrastructure/resolver.go, pkg/sweep/detached.go,
pkg/config/infrastructure.go, scripts/deploy-sweep-orchestrator.sh:16 (which
is what creates it).

Second-order: the ARN also interpolates schedule.Region, while the
orchestrator exists only in us-east-1 — so even with the name fixed, a schedule
in another region would fail.

Consistent with the symptom being unnoticed: all three spawn-schedules-*
buckets measured 0 objects, so no schedule has ever run far enough to stage
its parameters.

Why the #790 gate cannot see it

TestEveryHardcodedLambdaNameIsCreatedByADeployMechanism
(pkg/infrastructure/lambda_names_test.go) was written for exactly this class
and misses this instance on two counts:

  • its constDecl regex requires the identifier to end in Function — this
    one ends in FuncName;
  • its lit regex requires a literal after :function: — here the format string
    is %s, with the name arriving via a variable.

So the gate checks the shape of how I happened to write the constants in
pkg/infrastructure, not the property "every Lambda name reaches a function that
exists". That is the same mistake as #799's directory-scoped discovery, one layer
in: I generalised the search over files but not over naming styles.

TestScheduleRecordConstants (lambda/scheduler-handler/main_test.go:76)
asserts only that the constant is non-empty.

Suggested

  1. Fix the constant to spawn-sweep-orchestrator, and decide whether the region
    should be pinned to the orchestrator's region rather than the schedule's.
  2. Widen the gate so it cannot miss this shape: match any string constant or
    variable whose value is used to build a :function: ARN, regardless of
    identifier suffix or whether the name is interpolated. The robust form is to
    collect candidate values (any string literal matching a plausible function
    name) and check them against the discovered deploy-mechanism set, rather than
    keying on how the identifier is spelled.
  3. Have deploy-scheduler-handler.sh set the environment explicitly, so the
    deployed function's configuration is reproducible rather than relying on a
    compiled-in default.

Related: #790 (same class, opposite direction), #799 (a gate that matched the
author's own search scope), #804 (read side reconstructing a name the write side
resolved).

Activity

  1. added
    bug
    on Oct 11, 2026
  2. scttfrdmn commented on Oct 11, 2026

    @scttfrdmn
    ContributorAuthor

    Deployed. scheduler-handler now carries the fix, with zero config drift.

    field            before -> after
    Runtime          provided.al2023 -> provided.al2023
    Architectures    ['x86_64'] -> ['x86_64']
    Handler/Role/Timeout/MemorySize/State   all unchanged
    CodeSha256       /gfQDHIHbYJii3Ga… -> lg9GlSnLQR82FKp6…
    Environment      {} -> {"SPAWN_ORCHESTRATOR_FUNCTION_NAME": "spawn-sweep-orchestrator",
                            "SPAWN_ORCHESTRATOR_REGION": "us-east-1"}
    

    Also stamped spawn:version=0.127.0-7-g4602df8, so skew between the repo and this
    function is now readable in one API call (#768) — it previously had no version tag.

    The specific fix verified: the exact ARN the handler will build now resolves.

    $ aws lambda get-function-configuration \
        --function-name arn:aws:lambda:us-east-1:966362334030:function:spawn-sweep-orchestrator
    spawn-sweep-orchestrator   Active
    

    A correction to how I described the impact

    I wrote that "every scheduled sweep fails with ResourceNotFoundException". The
    tense was wrong — it would have failed. Measured after deploying:

    spawn-schedules Count=0
    spawn-schedule-history Count=0
    EventBridge Scheduler schedules for this handler 0 (the one that exists is lagotto-capacity-poller)
    /aws/lambda/scheduler-handler log group does not exist

    No log group means the function has never been invoked, not once since it was
    deployed. So nobody ever created a schedule, nothing ever fired, and the bug was
    latent rather than actively breaking users. It would have broken the first person
    to try.

    That makes the fix no less necessary and the severity lower than I stated. Worth
    correcting because "has never worked" and "is currently failing" imply different
    urgency, and only the first is true.

    What is still unverified

    Nothing has exercised this end to end. Config-level verification proves the
    handler will invoke a function that exists in a region it is deployed to; it does
    not prove a schedule runs. Doing that means creating a real schedule, letting it
    fire, and having it launch billable instances — which needs a TTL, an explicit
    teardown and an independent leak check, and is a separate piece of work rather
    than a deploy check.

    If someone does run it, #804 is the next thing in the path: the schedules-bucket
    name is resolved on the write side and reconstructed on the read side. The infra
    account owns spawn-schedules-us-east-1 so the preferred name is used there and
    #804 should not bite; an account that took the fallback would still fail.

    One small gap the deploy surfaced

    The retention step reported:

    log retention: could not set it yet (group not created until first invocation)
    

    which is correct and tolerated by design — but it means the group created by the
    first invocation will have no retention until someone re-deploys. For a
    function that has never run, that is the guaranteed outcome rather than an edge
    case. Worth either creating the group in the deploy script or re-running the
    retention step after the first invocation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions