Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mocks-gen: mocks-rm ## Generate mocks for all the defined interfaces.
mockgen -package=mocktarget -source=pkg/datastore/target/target.go -destination=$(MOCKDIR)/mocktarget/target.go
mockgen -package=mockTreeEntry -source=pkg/tree/api/entry.go -destination=$(MOCKDIR)/mocktreeentry/entry.go
mockgen -package=mocksdcpbpath -source=pkg/tree/api/sdcpb_path.go -destination=$(MOCKDIR)/mocksdcpbpath/sdcpb_path.go
mockgen -package=mockconfigread -destination=$(MOCKDIR)/mockconfigread/client.go github.com/sdcio/sdc-protos/config_read ConfigReadServiceClient
mockgen -package=mockconfigread -destination=$(MOCKDIR)/mockconfigread/client.go github.com/sdcio/sdc-protos/config_read ConfigSnapshotServiceClient

.PHONY: mocks-rm
mocks-rm: ## remove generated mocks
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/sdcio/cache v0.0.38
github.com/sdcio/logger v0.0.3
github.com/sdcio/schema-server v0.0.34
github.com/sdcio/sdc-protos v0.0.56-0.20260923101805-f894efbc2109
github.com/sdcio/sdc-protos v0.0.56-0.20260923110351-2e109b71c1dd
github.com/sdcio/yang-parser v0.0.12
github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ github.com/sdcio/schema-server v0.0.34 h1:NNDOkvtUMONtBA7cVvN96F+FWGD/Do6HNqfchy
github.com/sdcio/schema-server v0.0.34/go.mod h1:6t8HLXpqUqEJmE5yNZh29u/KZw0jlOICdNWns7zE4GE=
github.com/sdcio/sdc-protos v0.0.56-0.20260923101805-f894efbc2109 h1:LUWrCZAnPui2+vx2wdIYVEAHATqCv+/PVbK6QUmPhCY=
github.com/sdcio/sdc-protos v0.0.56-0.20260923101805-f894efbc2109/go.mod h1:hER0riYU3G55NnMQ0p0R9kIL/fzqq1zab4pOgUT3Yfg=
github.com/sdcio/sdc-protos v0.0.56-0.20260923110351-2e109b71c1dd h1:JUgGBY1KnMWOP6eNCgE5jcyZ6ZYy75slAk7iRzdI83k=
github.com/sdcio/sdc-protos v0.0.56-0.20260923110351-2e109b71c1dd/go.mod h1:hER0riYU3G55NnMQ0p0R9kIL/fzqq1zab4pOgUT3Yfg=
github.com/sdcio/yang-parser v0.0.12 h1:RSSeqfAOIsJx5Lno5u4/ezyOmQYUduQ22rBfU/mtpJ4=
github.com/sdcio/yang-parser v0.0.12/go.mod h1:CBqn3Miq85qmFVGHxHXHLluXkaIOsTzV06IM4DW6+D4=
github.com/sirikothe/gotextfsm v1.0.1-0.20200816110946-6aa2cfd355e4 h1:FHUL2HofYJuslFOQdy/JjjP36zxqIpd/dcoiwLMIs7k=
Expand Down
78 changes: 59 additions & 19 deletions mocks/mockconfigread/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 40 additions & 6 deletions pkg/cache/CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,30 @@ actually stores it.
## Language

**Intent**:
A named, prioritized piece of northbound-authored config, owned by whichever
system is the sole writer for the active `Cache.Type` (config-server, or
data-server itself under `local`). Read through the `Client.InstanceIntent*`
family.
A named, prioritized piece of northbound-authored config — the *desired*
value. Authorship (who decides what an Intent's content should be) belongs
to whichever system is the sole writer for the active `Cache.Type`
(config-server, or data-server itself under `local`). Read through the
`Client.InstanceIntent*` family. _Avoid_: using "Intent" when you mean
last-applied — under `Cache.Type: config-server` these are two different
values with two different owners (see **Last-applied** below).

**Last-applied**:
The value of a named Intent that this datastore last successfully pushed
southbound — updated at the same moment `IntentModify`/`IntentDelete` run
inside `TransactionSet`'s apply loop, for every `Cache.Type`, not gated on
`TransactionConfirm`. Under `Cache.Type: local` this has always been true by
construction (disk write happens at that exact call). Under
`Cache.Type: config-server`, data-server writes this back into config-server
so `Client.InstanceIntent*` reads (backed by `TargetSnapshot.Spec.Configs`)
never lag behind what was actually applied — a deleted Intent must stop
being last-applied at delete-apply time, not at some later, best-effort
snapshot refresh, or the next `LoadAllButRunningIntents` can rehydrate config
that was meant to be gone. _Avoid_: "confirmed" or "acknowledged" (collide
with the separate `TransactionConfirm` RPC step); "expected state" (says
nothing about whether it's desired-or-applied); and "Document" as a domain
concept (a branch-local Go DTO name for the ConfigSnapshotService
interchange shape — not a term in this language).

**Running**:
The synced, on-device configuration state — produced and consumed entirely
Expand Down Expand Up @@ -46,5 +66,19 @@ Tree Entry).

**ConfigSnapshotService**:
The canonical local gRPC seam name for config-server-backed intent reads and
writes (`Get`/`List`/`Modify`/`Delete`) against `TargetSnapshot` data. _Avoid_:
using the older `ConfigReadService` name for current behavior.
writes (`Get`/`List`/`Modify`/`Delete`) against `TargetSnapshot` data.
Data-server’s Go port over that wire is `ConfigSnapshotClient` (same four
operations, Document-shaped) in `pkg/cache/configserver`, implemented by
`GRPCConfigClient` and `FakeConfigSnapshotClient`. Distinct from the generated
gRPC stub `ConfigSnapshotServiceClient`. _Avoid_: the older
`ConfigReadService` name for current behavior; `LocalConfigClient` /
`LocalConfigReader` / `LocalConfigWriter` (retired half-split names for the
same port).

**Namespaced name**:
Under `Cache.Type: config-server` only, the `namespace.name` encoding that
splits on the first `.` — Target datastore identity (`prod.srl1`) and Intent
owner / Config identity (`prod.intent1`). Split and strip live next to
`ConfigServerCache`; join lives on the Document DTO (`IntentName`). Not a
`Client`-level concept; local cache has no namespaces. _Avoid_: treating it
as a generic cache key format across backends.
7 changes: 5 additions & 2 deletions pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ type IntentReader interface {
InstanceIntentGetAll(ctx context.Context, cacheName string, excludeIntentNames []string, intentChan chan<- importer.IntentAdapter, errChan chan<- error)
}

// IntentWriter persists real Intents. A backend that does not own those
// writes (config-server: kube-api writes them) composes noopIntentWriter.
// IntentWriter persists real Intents. Every current backend (LocalCache,
// ConfigServerCache) implements this directly. A future backend that
// genuinely cannot own real-Intent writes would need an explicit no-op
// composition at Server.createCacheClient so the type system makes that
// lack of ownership visible.
type IntentWriter interface {
InstanceIntentModify(ctx context.Context, cacheName string, intent *tree_persist.Intent) error
InstanceIntentDelete(ctx context.Context, cacheName string, intentName string, IgnoreNonExisting bool) error
Expand Down
Loading
Loading