Repository navigation
Conversation
Brian's five review comments on kubevela#7457, four as changes here and the fifth's access half tracked for the scope enforcement work. The Nacos client no longer falls back to the SDK's snapshot: with nacos-sdk-go v2.2.2 a GetConfig whose server query fails returned the snapshot of the last successful read with no error, so a revert while Nacos was down compared against stale content, recorded AlreadyCurrent and never retried once the hash matched. DisableUseSnapShot is set, so that read is ReadFailed with backoff, and each endpoint has its own cache directory because the SDK keys entries by dataId, group and namespaceId alone. group is optional again, kind-checked when present, and an empty group is normalised to DEFAULT_GROUP in the render, the group the SDK uses; requiring it had put every Config of a group-less template into Error after the upgrade. The nacos block is read from the value the Secret render produced, in the reconciler and in the CLI's ParseConfig, instead of a second render with the plain compiler: a template that imports a vela package renders like any other and a template's provider calls run once. syncNacos builds one Nacos client and hands it to the read and the publish through NacosData.Client; every construction re-initialises the SDK's global logger and opens a log writer nothing closes. The status records the endpoint the template names on every sync attempt, success or failure, and the Secret watch finds the Configs that use a changed, created or deleted endpoint config through a field index on it, so EndpointNotFound clears when the endpoint appears instead of on backoff. The status also gains endpointHash, a digest of the endpoint's server part (never its credentials: the status is readable), and the fast path requires it to match: a Config pointed at another server re-syncs read-first, and a synced Config whose endpoint is deleted reports EndpointNotFound. On upgrade each Config with a nacos block is read once and recorded AlreadyCurrent; nothing is published for that. The render of a template with a nacos block fails on any compile error instead of the "field does not exist" allowance the Secret render keeps for templates without one, so the real CUE error is reported. Follow-up to kubevela#7457. Part of kubevela#7410. Signed-off-by: Jerrin Francis <jerrinfrancis7@gmail.com>
jerrinfrancis
requested review from
FogDong,
Somefive,
anoop2811,
barnettZQG,
briankane,
chivalryq,
jefree-cat,
jguionnet,
leejanee,
roguepikachu,
wangyikewxgm and
wonderflow
as code owners
October 15, 2026 08:38
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 14 files
Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack
View guided diff | Re-trigger cubic
cubic round 1 on kubevela#7467. The per-endpoint cache directory joined the endpoint's namespace and name into one path component, which a 253-character Secret name pushes past the 255-byte file name limit; they are two components now. The ValidateExpandedWriter comment says group is optional, as the code has it. Signed-off-by: Jerrin Francis <jerrinfrancis7@gmail.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #7467 +/- ##
==========================================
- Coverage 79.85% 79.84% -0.01%
==========================================
Files 460 460
Lines 48089 48136 +47
==========================================
+ Hits 38401 38436 +35
- Misses 9685 9697 +12
Partials 3 3
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:
|
Collaborator
Author
|
/retest e2e-helm-test |
Collaborator
Author
|
/retest-failed e2e-test e2e-multicluster-test |
briankane
approved these changes
Oct 15, 2026
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
Follow-up to #7457 (Part of #7410, PR checklist box 4): the five inline comments from the
review, four as changes here and one tracked for the scope work (box 6).
A read never serves the SDK's snapshot (
nacos.go:220). Withnacos-sdk-gov2.2.2, aGetConfigwhose server query fails returns the snapshot the SDK wrote after the lastsuccessful read, with no error. The read-before-publish then compared against stale content:
revert a change while Nacos is briefly down and the controller recorded
AlreadyCurrentwhileNacos kept the newer value, with nothing left to retry once the hash matched. The client now
sets
DisableUseSnapShot, so that read isReadFailedwith backoff, and each endpoint has itsown cache directory (the SDK keys entries by dataId, group and namespaceId alone, so two servers
with the same ids would otherwise share them).
groupis optional again (sync.go:85). The SDK publishes to and reads fromDEFAULT_GROUPwhen the group is empty, and templates written before the controller publishednever had to set it; requiring it put every Config of such a template into
Errorafter theupgrade and refused edits to the template. The kind check stays (
group: 42is refused) and anempty group is normalised to
DEFAULT_GROUPin the render, so the hash, the status, the read andthe publish name the same group.
The nacos block comes out of the Secret's compile (
nacos_sync.go:71). The reconciler andthe CLI's
ParseConfigreadtemplate.nacosfrom the value the CueX render already produced,instead of rendering a second time with the plain compiler. A template that imports a vela
package renders like any other (it was admitted and then failed at reconcile with
builtin package "vela/config" undefined), and a template's provider calls run once perreconcile rather than twice.
One Nacos client per sync (
nacos_sync.go:116).syncNacosbuilds the client once andhands it to the read and the publish through
NacosData.Client, releasing it afterwards. Everyconstruction re-initialises the SDK's global logger and opens a rolling log writer nothing
closes, so one per sync that reaches Nacos is what the controller pays.
The endpoint is watched and part of "current" (
nacos_sync.go:166, the watch half). Achange to an endpoint config Secret (a velacore-config Secret whose properties carry
serversor
client) enqueues the Configs with a nacos block, soEndpointNotFoundclears when theendpoint appears rather than on backoff. The status gains
endpoint, the endpoint config thetemplate names, recorded on every sync attempt whether it succeeded or not, and
endpointHash, a digest of that config's server part (addresses, ports, discovery endpoint,region; never its credentials, the status being readable by whoever can read Configs), and the
fast path requires the digest to match too: a Config pointed at another server re-syncs the way
changed content does, read first, published only when the server does not hold it. The watch
finds the Configs that use a changed, created or deleted endpoint config through a field index
on that reference, the ones still waiting for it included. A synced Config whose endpoint is
deleted reports
EndpointNotFoundinstead of stayingTrue. On upgrade every stored statuslacks the digest, so each Config with a nacos block is read once and recorded
AlreadyCurrent;nothing is published for that. The access half of the same comment (endpoint credentials read with the controller's
permissions where the CLI read them as the user) is tracked for the scope enforcement PR: an
endpoint in the template's own namespace or in
vela-systemallowed, elsewhere aSubjectAccessReview for
geton the Secret as the requesting user, at ConfigTemplate admission.One commit:
Fix(config): Nacos sync follow-ups from #7457.Follow-up to #7457. Part of #7410
I have:
make reviewableto ensure this PR is ready for review.backport release-x.ylabels to auto-backport this PR if necessary.How has this code been tested
pkg/config/writer: the client param carriesDisableUseSnapShotand a per-endpoint cachedirectory;
NewClientis the shared seam (one construction for a read and a publish, releasedonce);
renderNacosreads a rendered value, renders a template behind a vela import anddefaults an empty group;
ValidateExpandedWriterpasses a block withoutgroupand stillrefuses
group: 42;EndpointHashis stable across key order, changes with a server or thediscovery endpoint, ignores the credentials, and leaves the caller's map alone.
records the endpoint on success and while waiting on
EndpointNotFoundor a failed publish;an endpoint Secret change re-syncs the Config through the watch with a read and no publish,
and the endpoint digest changes while the content hash does not; a template without a group
publishes to
DEFAULT_GROUPand records it; the index key function.pkg/configand the CLI config suites green; lint clean.(
262341c0c) to this branch: the stale-snapshot bug reproduced on the merged image (edit,stop Nacos, revert:
AlreadyCurrentrecorded, Nacos keeps the edit after the restart) andhealed by the upgrade (the new digest forces one read, the revert is published); with the fix
the same revert is
ReadFaileduntil Nacos is back and thenAlreadyCurrent; a templatewithout a group admitted and published to
DEFAULT_GROUP; the template behindvela/configrenders through the CLI and the controller; a Config whose endpoint arrives later syncs within
seconds of the endpoint's creation, re-syncs without a publish when the endpoint gains a
field, fails cleanly on a wrong port, and reports
EndpointNotFoundwhen the endpoint isdeleted; one cache directory per endpoint in the controller's
/tmp/nacos/cache.Special notes for your reviewer
endpointHashis a second field next tocontentHash, additive on the CRD, and an upgrade costs one read per nacos Config, never apublish.
notices a deleted endpoint and says so, where before it stayed
True.status.expandedWriter.nacos.endpoint, registered inSetupWithManager), gated on the velacore-config label, so a Secret event costs one cachequery for the Configs that name it and nothing for the rest. The reference is written in
nacosFailedas well asnacosSynced, which is what lets a waiting Config be found by name;a Config whose status predates the field is indexed at its next reconcile, which every Config
gets at controller start.
config.ReadConfigSecret, the Secret-level half of thelegacy
ReadConfig, so the controller and the CLI refuse a sensitive one the same way.config.RenderTemplateholds the one rule (the
IsFieldNotExistallowance stays for templates without the block,as the legacy path always had it), and the reconciler and
ParseConfigboth call it, so thereal CUE error is the one reported. Making
RunAndOutputWithCueXstop producing that errorclass for a template without
template.parameteris the deeper fix and is left for its ownchange, since the webhook shares the allowance.
client per sync is the floor without a per-endpoint client cache; that cache would need the
invalidation this PR's watch now provides, so it is a natural next step if the logger shows up
in profiles.
vela config createfrom a template behind a vela importused to fail with the plain compiler's error before writing the CR.