Repository navigation
feat(dir): add publish job - #2357
Conversation
7a2c2f0 to
b2fbdc6
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@csirmazbendeguz every PR must have an issue to link against + a PR description for context and auditing. |
muscariello
left a comment
There was a problem hiding this comment.
Clean and consistent with the sync task (#2298): off by default, dry_run on by default, stable paging, good coverage. Two things before merge:
- Description. The body is empty and there is no linked issue. Please add a description and link #2136.
- The CronJob. The PR doesn't touch
install/charts/dirctlor the docs, and thepublishCronJob (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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Validate() always returns nil. Please either drop it or reject limit < 0 and interval < 0. Today they silently fall back to the defaults.
| DefaultLimit = 100 | ||
| ) | ||
|
|
||
| // Criteria is the local-store search filter the publish applies. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Yes, I had this in mind, gonna submit a new PR to add filters to both
The plan is to remove the CronJobs once this PR is merged |
| // 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{}) |
There was a problem hiding this comment.
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]>
921c360 to
178d46e
Compare
#2136
This PR migrates the publish K8S CronJob to the reconciler