Skip to content

[Backport release-0.8] Fix: delete an in-memory context under the key it was stored as - #343

Open
briankane wants to merge 1 commit into
kubevela:release-0.8from
briankane:backport/release-0.8-336
Open

briankane wants to merge 1 commit into
kubevela:release-0.8from
briankane:backport/release-0.8-336

Conversation

@briankane

@briankane briankane commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Backport of #336 to release-0.8, for workflow v0.8.0 (KubeVela 1.12.0). The fix is @marcus-beauregard's; the commit keeps him as author and is cherry-picked with -x.

What it fixes

DeleteInMemoryContext built its key as workflow-<app>-context, while every write and read keys the store as <namespace>/workflow-<app>-context. The keys never matched, so the delete did nothing and a deleted Application's context stayed in memory for the life of the controller. It now takes the namespace and builds the key the same way the writes do.

How it differs from #336

release-0.8 doesn't have #262, so the store is still a plain map rather than pkg/cache. The intent is unchanged:

As on main, DeleteInMemoryContext now takes (appName, namespace), so KubeVela's call site has to pass app.Namespace when it bumps to this release.

Testing

  • go build ./... and go vet ./... clean.
  • go test ./pkg/context -run TestDeleteInMemoryContext: passes (deletes the stored context, leaves another namespace's alone, defaults an empty namespace both ways, no-op on a missing key).
  • go test ./pkg/...: everything passes except the two email packages, which fail on macOS arm64 with or without this change (gomonkey can't patch the binary there).

Summary by cubic

Fixes DeleteInMemoryContext so it deletes in-memory contexts under the same key format used by reads and writes.

Previously it built the key as workflow-<app>-context while all other operations used <namespace>/workflow-<app>-context, so the delete never matched and stale contexts lingered in memory for the controller's lifetime. It now takes the namespace and builds the key through the shared contextKey helper. Callers must pass app.Namespace when invoking the method.

  • Adds tests covering namespace isolation, empty-namespace defaulting, and missing-key no-ops.

Written for commit c2bef41. Summary will update on new commits.

View guided diff

…vela#336)

DeleteInMemoryContext built its key as "workflow-<app>-context", while
every write and read goes through contextKey(name, namespace), which is
"<namespace>/workflow-<app>-context". The keys could never match, so the
delete was a no-op and the context of a deleted Application stayed in
memory for the life of the controller.

Take the namespace the same way GetInMemoryContext does and build the key
with contextKey and generateStoreName. The KubeVela call site has to pass
app.Namespace after it bumps this repo.

Signed-off-by: Marcus Beauregard <marcus.beauregard.developer@gmail.com>
(cherry picked from commit 593f538)

release-0.8 has no kubevela#262, so the store is still a plain map: contextKey is
added here and used by getKey, GetInMemoryContext and DeleteInMemoryContext,
and the test file is new, carrying only TestDeleteInMemoryContext.

Signed-off-by: Brian Kane <briankane1@gmail.com>
@briankane briankane added the type/bug Something isn't working label Nov 26, 2026
@briankane
briankane requested a review from Somefive as a code owner November 26, 2026 19:42
@briankane briankane added the area/data-passing Inputs, outputs, parameterKey and the workflow context store (pkg/hooks, pkg/context) label Nov 26, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

View guided diff | Re-trigger cubic

@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (release-0.8@95f3bd2). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff               @@
##             release-0.8     #343   +/-   ##
==============================================
  Coverage               ?   80.49%           
==============================================
  Files                  ?       88           
  Lines                  ?     7046           
  Branches               ?        0           
==============================================
  Hits                   ?     5672           
  Misses                 ?     1374           
  Partials               ?        0           
Flag Coverage Δ
e2etests 37.50% <0.00%> (?)
unit-test 74.87% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

area/data-passing Inputs, outputs, parameterKey and the workflow context store (pkg/hooks, pkg/context) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants