Skip to content

feat(dir): add sync-netsec job - #2298

Merged
csirmazbendeguz merged 1 commit into
mainfrom
feat/sync-netsec
Oct 13, 2026
Merged

csirmazbendeguz merged 1 commit into
mainfrom
feat/sync-netsec

Conversation

@csirmazbendeguz

@csirmazbendeguz csirmazbendeguz commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

#2136
This PR adds the sync job. This is the migration of the K8S CronJob sync-netsec to the reconciler.

@github-actions github-actions Bot added the size/M Denotes a PR that changes 200-999 lines label Oct 6, 2026
@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

@csirmazbendeguz
csirmazbendeguz marked this pull request as ready for review October 7, 2026 12:20
@csirmazbendeguz
csirmazbendeguz requested a review from a team as a code owner October 7, 2026 12:20
@github-actions github-actions Bot added size/L Denotes a PR that changes 1000-1999 lines and removed size/M Denotes a PR that changes 200-999 lines labels Oct 8, 2026

@ramizpolic ramizpolic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

overall its good, just a couple of pointers here and there. i would just like to clarify the client before merging

Comment thread cli/cmd/daemon/daemon.config.yaml Outdated
Comment on lines +194 to +195
criteria:
domain: network_security

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we possibly extend this to encapsulate an AND relationship of all skills and domains to sync. When we have a reusable sync job (ie. being able to define multiple sync jobs), this would allow usage of "sync specific filters that match", or serve for general data synchronization/replication.

Suggested change
criteria:
domain: network_security
criteria:
domains:
- network_security
- some other domain
skills:
- skillA
- skillB

which syncs everything that has at least these labels

@csirmazbendeguz csirmazbendeguz Oct 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, thanks for pointing it out!

CronJobs support this so the reconciler job should support it as well

but note that these would use OR because search uses OR - not AND

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added this

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we need to redeclare the client? We already have access to our actual DIR go client which we use in things like sync, etc. We should simply reuse that

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @ramizpolic! Fair point, though to be precise this isn't a redeclared client — it's reconciler/tasks/metrics/grpc.go moved into its own package. You're right that what it holds already duplicates client.SearchRouting, but we can't drop it entirely: in daemon mode the reconciler has no DIR client at all since routing runs in-process over the embedded Badger store, so the tasks need an interface satisfied by both types.RoutingAPI and the gRPC client — and those two spell the same operations differently (Search vs SearchRouting, plus GetProviderCount with incompatible signatures).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

im not sure what the problem is still by using client. you can use client even when in daemon mode

Copilot AI 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.

🟡 Changes recommended

Stream errors, capped-search starvation, unvalidated peer addresses, and unsafe configuration edge cases can produce incomplete or unbounded synchronization.

5 open findings
What changed in this PR

Adds a reconciler-managed sync job to replace the Kubernetes sync-netsec CronJob.

Changes:

  • Adds configurable routing search, peer grouping, dry-run, and sync creation.
  • Introduces a shared standalone routing gRPC client.
  • Wires sync configuration into daemon, Docker, and Helm deployments.
File Description
reconciler/​tasks/​sync/​task.go Implements sync execution.
reconciler/​tasks/​sync/​task_test.go Tests sync behavior.
reconciler/​tasks/​sync/​group.go Groups results by peer.
reconciler/​tasks/​sync/​config.go Defines sync configuration.
reconciler/​tasks/​sync/​config_test.go Tests configuration defaults.
reconciler/​tasks/​metrics/​task.go References shared routing client.
reconciler/​tasks/​metrics/​grpc.go Removes metrics-specific client.
reconciler/​service/​service.go Registers the sync task.
reconciler/​service/​service_test.go Tests task registration.
reconciler/​routing/​client.go Adds shared routing gRPC client.
reconciler/​routing/​client_test.go Tests routing RPC behavior.
reconciler/​main.go Initializes shared routing access.
reconciler/​config/​config.go Adds sync settings and defaults.
reconciler/​config/​config_test.go Tests sync environment settings.
install/​docker/​reconciler.env Documents Docker configuration.
install/​charts/​dir/​values.yaml Adds parent-chart sync values.
install/​charts/​dir/​apiserver/​values.yaml Adds subchart sync values.
cli/​cmd/​daemon/​daemon.config.yaml Adds daemon sync defaults.
cli/​cmd/​daemon/​daemon_test.go Tests safe daemon defaults.
cli/​cmd/​daemon/​config.go Registers daemon sync defaults.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment thread reconciler/tasks/sync/config.go Resolved
Comment thread reconciler/tasks/sync/task.go Resolved
Comment on lines +98 to +101
if err != nil {
logger.Error("error receiving search result", "error", err)

return

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is not a huge problem, I'm not sure it's a problem at all

Comment on lines +83 to +84
MinMatchScore: &minScore,
Limit: &limit,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I understand this is a limitation and I would be open to iterating on it further in future PRs. The point if this PR though is to migrate the sync CronJobs. And this is how the CronJobs work as well. I will open an issue for this, but I would like to get this PR merged first, then we can address limitations

Comment on lines +141 to +144
func (t *Task) createPeerSync(peer *peerGroup) error {
switch {
case peer.dirAddr != "":
id, err := t.db.CreateSync(peer.dirAddr, peer.cids, "", "")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this is fine. We're using the search results which should contain valid endpoints. If not, then we can let it retry. This is how CronJobs work too. We can create an issue for this though and add a fix for it later, similar to above

@csirmazbendeguz
csirmazbendeguz force-pushed the feat/sync-netsec branch 4 times, most recently from e053eac to fd3c251 Compare October 13, 2026 08:46
ramizpolic
ramizpolic previously approved these changes Oct 13, 2026
Comment thread cli/cmd/daemon/config.go Resolved
Comment thread cli/cmd/daemon/daemon.config.yaml Resolved
Comment thread reconciler/tasks/sync/config.go Resolved
@ramizpolic

Copy link
Copy Markdown
Member

LGTM @csirmazbendeguz with a couple of nits:

  • use domains to indicate its multiple items in configs
  • documentation is missing for these policies, perhaps to sort out in a followup PR

@csirmazbendeguz

Copy link
Copy Markdown
Contributor Author

LGTM @csirmazbendeguz with a couple of nits:

  • use domains to indicate its multiple items in configs
  • documentation is missing for these policies, perhaps to sort out in a followup PR

Thanks! I renamed it to domains.
I think this PR is already quite large, let's include docs in another PR.

Signed-off-by: Bendegúz Csirmaz <[email protected]>

@ramizpolic ramizpolic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@csirmazbendeguz
csirmazbendeguz added this pull request to the merge queue Oct 13, 2026
Merged via the queue into main with commit d03f638 Oct 13, 2026
35 checks passed
@csirmazbendeguz
csirmazbendeguz deleted the feat/sync-netsec branch October 13, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 1000-1999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants