Repository navigation
Refactor: Migrate optional in-memory context storage to pkg/cache - #262
Open
NachiketPatil26 wants to merge 2 commits into
Open
NachiketPatil26 wants to merge 2 commits into
NachiketPatil26 wants to merge 2 commits into
Conversation
Back MemStore with the shared kubevela/pkg cache instead of a plain map. Entries are stored without expiry since this holds live workflow context. Also take the lock across GetOrCreateInMemoryContext so the lookup and create can't race, and use the same namespace defaulting for reads and writes. Signed-off-by: Nachiket <nachiketpatil2604@gmail.com>
NachiketPatil26
requested review from
FogDong,
Somefive,
anoop2811,
briankane,
jguionnet,
leejanee and
wonderflow
as code owners
October 1, 2026 05:53
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #262 +/- ##
==========================================
+ Coverage 62.49% 70.48% +7.99%
==========================================
Files 62 73 +11
Lines 4415 5852 +1437
==========================================
+ Hits 2759 4125 +1366
- Misses 1324 1341 +17
- Partials 332 386 +54
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The previous concurrency test only checked that a key existed afterwards, so it would pass even if GetOrCreateInMemoryContext were not atomic. Its DeleteInMemoryContext calls also never matched the stored keys. Race workers on a single key and assert every caller ends up with the stored context. Signed-off-by: Nachiket <nachiketpatil2604@gmail.com>
Author
|
Hi, CI is green and I tightened the concurrency test based on the bot review. Would someone have time to take a look? |
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.
Description of your changes
Moves
MemStoreontogithubproxy.fjygbaifeng.eu.org/kubevela/pkg/cache, same approach as the email change in #259. Entries go in with no expiry since this is live workflow context, and the exported methods stay the same because vela-core calls them.GetOrCreateInMemoryContextnow holds the lock for the whole lookup + create, and reads use the same namespace defaulting as writes (empty namespace ->default).Fixes #254
I have:
make reviewableto ensure this PR is ready for review. (fmt, vet, golangci-lint and staticcheck; no manifest or chart changes)backport release-x.ylabels to auto-backport this PR if necessary.How has this code been tested
Added
pkg/context/storage_test.go: create/get/update, empty namespace, get-or-create returning a copy, concurrent access, andNewContext->Commit->LoadContextwithEnableInMemoryContexton.go test -race ./pkg/context/...passes.Special notes for your reviewer
Two existing bugs I left out to keep this a straight refactor:
DeleteInMemoryContext(appName)builds the key without the namespace, so the delete vela-core does on app deletion never matches anything (details on Refactor: Migrate optional in-memory context storage to pkg/cache #254).sync()still falls through tocli.Patchafter updating the memory store. Looks like that came in with 9eda5ba.I can send follow-ups for either if you want.
Summary by cubic
Migrates in-memory workflow context storage from a plain map to
github.com/kubevela/pkg/cachewithout changing exported methods for vela-core callers. Entries are stored without expiry since they hold live workflow context. Fixes #254.GetOrCreateInMemoryContextnow holds the lock across the whole lookup and create, so concurrent calls can't race.default).pkg/context/storage_test.gocovering create/update/get, empty namespace handling, concurrent get-or-create asserting every caller ends up with the stored context, andNewContext/Commit/LoadContextwith in-memory storage enabled.DeleteInMemoryContextbuilds its key without the namespace, andsync()still falls through tocli.Patchwhen in-memory context is on. Can be sent as follow-ups.Written for commit 76bfa23. Summary will update on new commits.