Skip to content

feat(dir): add publish job - #2357

Merged
lgecse merged 2 commits into
mainfrom
feat/publish-job
Oct 14, 2026
Merged

lgecse merged 2 commits into
mainfrom
feat/publish-job

Conversation

@csirmazbendeguz

@csirmazbendeguz csirmazbendeguz commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

#2136
This PR migrates the publish K8S CronJob to the reconciler

@github-actions github-actions Bot added the size/M Denotes a PR that changes 200-999 lines label Oct 13, 2026
@csirmazbendeguz
csirmazbendeguz marked this pull request as ready for review October 13, 2026 17:30
@csirmazbendeguz
csirmazbendeguz requested a review from a team as a code owner October 13, 2026 17:30
@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.24771% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
reconciler/service/service.go 77.8% 2 Missing ⚠️
reconciler/tasks/publish/task.go 98.5% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@muscariello

Copy link
Copy Markdown
Member

@csirmazbendeguz every PR must have an issue to link against + a PR description for context and auditing.

@muscariello muscariello 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.

Clean and consistent with the sync task (#2298): off by default, dry_run on by default, stable paging, good coverage. Two things before merge:

  1. Description. The body is empty and there is no linked issue. Please add a description and link #2136.
  2. The CronJob. The PR doesn't touch install/charts/dirctl or the docs, and the publish CronJob (templates/cronjob.yaml) is still there. If both run, every record is announced twice. Please add a note to turn one of them off, and say whether the CronJob is deprecated.

The inline comments are smaller points and can be follow-ups.


var total, pages int

for offset := 0; ; offset += limit {

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.

Every run re-announces every matching record. There is no published state per record, so with the default interval: 24h this is one publication per 100 records, daily, and again on every reconciler restart. Same as the CronJob, but worth a line in the docs.

A record inserted during the run can shift the offsets, so a record may be skipped or sent twice. Harmless here, since republishing is idempotent.

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, that's expected. We can improve on this in the future but for now I would like to keep it simple and in line with the CronJob

"domains", domains,
"cids", cids,
)
} else if err := t.publishPage(cids); err != nil {

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.

dirctl routing unpublish doesn't stick. Nothing records that a record was unpublished, so the next run announces it again while it matches criteria. Please document this, or say that unpublishing means changing the criteria.

total += len(cids)

if t.config.DryRun {
logger.Info("Dry run: not creating publication",

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.

This logs every CID of every page at Info. On a large index that is a lot of output. Please log the counts at Info and the CIDs at Debug.

return nil
}

logger.Info("Publish complete", "records", total, "pages", pages, "domains", domains)

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.

The task only queues the publications, so a failure isn't visible here. The worker skips records the policy gate excludes, announces the rest of the page, then marks the whole publication failed. Publish complete is still logged in that case. Please log "queued" instead, or note that the status lives on the publication.


// Validate is reserved for criteria that can be wrong. Empty domains are
// valid: the task then publishes every indexed record.
func (c *Config) Validate() error {

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.

Validate() always returns nil. Please either drop it or reject limit < 0 and interval < 0. Today they silently fall back to the defaults.

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.

DefaultLimit = 100
)

// Criteria is the local-store search filter the publish applies.

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.

The CronJob's match accepted any dirctl search flag (trusted, scan severity and so on). This supports only domains. Fine as a first step, but please say so, because "migrating the CronJob" would otherwise lose those filters. Same point as on #2298.

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, I had this in mind, gonna submit a new PR to add filters to both

@csirmazbendeguz

Copy link
Copy Markdown
Contributor Author
  1. The CronJob. The PR doesn't touch install/charts/dirctl or the docs, and the publish CronJob (templates/cronjob.yaml) is still there. If both run, every record is announced twice. Please add a note to turn one of them off, and say whether the CronJob is deprecated.

The plan is to remove the CronJobs once this PR is merged

Comment thread cli/cmd/daemon/config.go
// to the zero value. Mirrors reconciler/config.
v.SetDefault("reconciler.publish.enabled", false)
v.SetDefault("reconciler.publish.interval", publishtask.DefaultInterval)
v.SetDefault("reconciler.publish.criteria.domains", []string{})

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.

i would just add maybe an additional filter for what can be published automatically, e.g. criteria.only_verified: true or criteria.signers: ["*cisco.com*", list of regexs or automatic things to guide autopublication

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

@muscariello muscariello 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

@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

@lgecse
lgecse added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit 51cce53 Oct 14, 2026
35 checks passed
@lgecse
lgecse deleted the feat/publish-job branch October 14, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 200-999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants