X Tutup
Skip to content

feat: A reconciler to actually keep our records in check#4991

Open
another-rex wants to merge 5 commits intogoogle:masterfrom
another-rex:reconciler
Open

feat: A reconciler to actually keep our records in check#4991
another-rex wants to merge 5 commits intogoogle:masterfrom
another-rex:reconciler

Conversation

@another-rex
Copy link
Contributor

Wrote a reconciler so that we catch any missing records within 30 hours of it happening.

Copy link
Member

@michaelkedar michaelkedar left a comment

Choose a reason for hiding this comment

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

can we s/datastore/database (or similar) throughout (since the underlying database is abstracted away)

Comment on lines +274 to +277
_ = wt.Checkout(&git.CheckoutOptions{
Branch: plumbing.NewRemoteReferenceName("origin", sourceRepo.Git.Branch),
Force: true,
})
Copy link
Member

Choose a reason for hiding this comment

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

Have you verified that this actually checks it out on-disk?
I wouldn't be surprised if this was in-memory only.

Comment on lines +164 to +166
// "oss-fuzz",
// "debian-cve",
// "cve-osv",
Copy link
Member

Choose a reason for hiding this comment

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

why are these commented out.

Also FYI, "oss-fuzz" is explicitly filtered out of the SourceRepositoryStore implementation, so it shouldn't even be surfaced here.

if sourceRepo.Type == models.SourceRepositoryTypeGit && sourceRepo.Git != nil {
if existingBranch, ok := gitBranches[sourceRepo.Git.URL]; ok {
if existingBranch != sourceRepo.Git.Branch {
return fmt.Errorf("multiple sources with same git url %q but different branches (%q and %q) is not supported",
Copy link
Member

Choose a reason for hiding this comment

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

Should this stop the entire reconciler?
If not, we could just combine this loop with the one afterwards, and not store the sourceRepos

Copy link
Member

Choose a reason for hiding this comment

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

You have this in base, but no patch in the production environment, meaning it'll get deployed to prod without the PersistentVolume?
Either add the prod one (if you want it), or remove this from base, and add it as a resource (instead of a patch) to the test instance

// - parsed: A pointer to a pre-parsed gjson.Result if already available. If nil, sourceRecord is opened and parsed dynamically.
// - sourceRecord: The interface used to lazily retrieve file contents (from a bucket, git, or REST).
// - format: RecordFormat representing the format we expect to decode (JSON, YAML, etc.).
func checkReconcile(
Copy link
Member

Choose a reason for hiding this comment

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

This blocks the SourceRepository walking to download the record from GCS/REST (or open the file when in git), then sends it to the importerWorker which downloads the file again to do validation/send to worker.

IMO most of this function should be in the pool of workers for the reconciler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup