<fix>[identity]: propagate ExternalTenantContext via TaskContext for cascade resources#3721
Open
ZStack-Robot wants to merge 1 commit intofeature-zcf-v0.1from
Open
<fix>[identity]: propagate ExternalTenantContext via TaskContext for cascade resources#3721ZStack-Robot wants to merge 1 commit intofeature-zcf-v0.1from
ZStack-Robot wants to merge 1 commit intofeature-zcf-v0.1from
Conversation
…cascade resources Resolves: ZSTAC-1147 Change-Id: I683e34ff9c5b15ff8da6a2a25b7eb506ad1d90f7
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough此变更在 Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 1 warning)
✅ Passed checks (1 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
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.
Problem
ExternalTenantResourceTracker fails to track cascade resources (Volume, NIC, CdRom) created during VM creation. Only the top-level VM gets an ExternalTenantResourceRefVO record.
Root cause:
VmInstanceBase.handle(InstantiateNewCreatedVmInstanceMsg)usesthdf.chainSubmit()which executes the FlowChain in a thread-pool worker thread. The ThreadLocalExternalTenantContextis lost during this thread handoff, so when cascade resources are persisted andnotifyResourceOwnershipCreated()is called,ExternalTenantContext.getCurrent()returns null.Fix
Piggyback on ZStack's existing
TaskContextpropagation infrastructure:Write side (BeforeDeliveryMessageInterceptor): When restoring ExternalTenantContext to ThreadLocal, also store it in
TaskContextviaputTaskContextItem().Read side (notifyResourceOwnershipCreated): If ThreadLocal is null, fallback to
TaskContext.getTaskContextItem()which is automatically propagated across thread boundaries byHasThreadContextAspect/SetThreadContextAspect.This works because:
HasThreadContextAspect.ajauto-captures TaskContext snapshot when anyHasThreadContextobject (ChainTask, Completion, etc.) is constructedSetThreadContextAspect.ajauto-restores TaskContext beforeChainTask.run(),Completion.success/fail(), etc.Changes
ExternalTenantResourceTracker.java: ~30 lines added/changed in 1 fileResolves
ZSTAC-1147
sync from gitlab !9588