Repository navigation
Conversation
… outcome KernelAlreadyExistsError is logged at trace and skipped by the error monitor, as KernelNotFoundError is. The error carries the kernel id.
2 of 7 tasks
Member
Author
|
Closed: superseded by #15978 (start claim); not needed for the CC MVP. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolves #NNN (BA-XXXX)
AbstractAgent.create_kernelrejects a creation that is still in progress (track_create), but acceptscreate_kernelfor a kernel id that already finished creating and sits inkernel_registry. A duplicate request for a running kernel therefore re-allocates its slots and re-runs scratch and network setup for it. Nowcreate_kernelraisesKernelAlreadyExistsErrorfor that id before any of those steps.Change (
src/ai/backend/agent/agent.py,errors/agent.py,errors/__init__.py)create_kernel: when notrestartingandkernel_id in self.kernel_registry, raiseKernelAlreadyExistsErrorwith the kernel id in the message (409,ErrorDomain.KERNEL/CREATE/ALREADY_EXISTS). The check runs insidetrack_create, before the throttle semaphore, theKernelPreparingevents,init_kernel_context, resource allocation, scratch and network.server.py:_create_kernellogs the error at trace and re-raises; therpc_functionwrapper skipserror_monitor.capture_exception()for it (as forKernelNotFoundError).collect_erroris unchanged and still emits oneAgentErrorEvent(as it does forResourceErrorandKernelNotFoundError); no lifecycle event is injected, so the registered kernel is not destroyed or cleaned. The manager sees the failure of that request only.create_kernel:server.pycreate_kernels(non-restart, now guarded) andrestart_kernel(restarting=True, unaffected; its kernel is still inkernel_registry).Rig evidence (agent log of a containerd-backend rig; not main)
create_kernelsfor the kernel: "kernel creating" ... "kernel creation done" (~60 s)track_createlets it throughip netns add("File exists")After the failure the live kernel's netns, DNAT rules and scratch dir were gone (containerd cleanup is keyed by kernel id, #15588/#15613, not on main).
Shown vs inferred
track_createonly); the lines above; the live kernel's host state gone afterwards.Related: the duplicate's trigger is fixed separately in the manager (advisory lock PR, link to follow). This is the agent-side defence for any duplicate request.
Known gap: a container present but missing from
kernel_registry(for example after recovery) is not covered.A stale entry is the reverse case, pre-existing and not changed here: the base agent registers
kernel_registry[kernel_id]afterprepare_containerand beforestart_container, so a crash mid-start can pickle a container-less entry that_clean_kernel_registry_loop(RUNNING kernels only) never cleans, and a re-sent create for that id then gets the 409.When several kernels in one
create_kernelsrequest fail, the errors are wrapped inTaskGroupErrorand still reachcapture_exception, the same asKernelNotFoundError.Tests:
tests/unit/agent/test_create_kernel_duplicate.py(conditions are fixtures)restarting=False: raisesKernelAlreadyExistsError;init_kernel_contextand theKernelPreparingevents are not awaited.restarting=True: proceeds toinit_kernel_context.create_kernelswithcreate_kernelraising the error: no ERROR-level log,capture_exceptionnot awaited; oneAgentErrorEventproduced.create_kernels, no lifecycle event injected: a regression guard that also passes on main.server.pychange, 1 of 5 fails (expected-outcome test). Green with both. Outputs in the evidence report.Not run on a live agent.
Checklist: (if applicable)
fix:PR goes to every version in.github/maintained-versions.ymlautomatically.A
Backport:line here names the targets instead — some of them, other ones, ornone.ai.backend.testdocsdirectory