Skip to content

WIP: bug fix: OCPBUGS-97746: verify and sync catalog.jsonl file is available before…#2819

Open
dis016 wants to merge 1 commit into
operator-framework:mainfrom
dis016:fix_OCPBUGS-97746
Open

WIP: bug fix: OCPBUGS-97746: verify and sync catalog.jsonl file is available before…#2819
dis016 wants to merge 1 commit into
operator-framework:mainfrom
dis016:fix_OCPBUGS-97746

Conversation

@dis016

@dis016 dis016 commented Jul 17, 2026

Copy link
Copy Markdown

bug fix: OCPBUGS-97746 verify and sync catalog.jsonl file is available before populating updateStatus

Copilot AI review requested due to automatic review settings July 17, 2026 11:30
@netlify

netlify Bot commented Jul 17, 2026

Copy link
Copy Markdown

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 1a8646a
🔍 Latest deploy log https://app.netlify.com/projects/olmv1/deploys/6a5a12428ee5a40007edaee4
😎 Deploy Preview https://deploy-preview-2819--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@openshift-ci
openshift-ci Bot requested review from pedjak and tmshort July 17, 2026 11:30
@openshift-ci

openshift-ci Bot commented Jul 17, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign joelanford for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dis016 dis016 changed the title bug fix: OCPBUGS-97746: verify and sync catalog.jsonl file is available before… WIP: bug fix: OCPBUGS-97746: verify and sync catalog.jsonl file is available before… Jul 17, 2026
@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 17, 2026

Copilot AI left a comment

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.

Pull request overview

This PR hardens catalogd catalog serving by verifying that catalog.jsonl is present and readable on disk (and forcing an fsync) before the ClusterCatalog status is updated to Serving, reducing the risk of advertising a serving URL before content is actually available.

Changes:

  • Extended the storage.Instance interface with VerifyAndSync(catalog string) error.
  • Implemented VerifyAndSync for LocalDirV1 to stat/open/fsync and minimally read catalog.jsonl.
  • Updated the ClusterCatalog reconciler to call VerifyAndSync after Store() and before setting Serving, plus updated mocks/tests accordingly.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/testutil/mock/storage/mock_instance.go Regenerated mock to include VerifyAndSync.
internal/catalogd/storage/storage.go Adds VerifyAndSync to the storage interface with API docs.
internal/catalogd/storage/localdir.go Implements LocalDirV1.VerifyAndSync (stat/open/fsync/read).
internal/catalogd/controllers/core/clustercatalog_controller.go Calls VerifyAndSync before marking catalogs as Serving.
internal/catalogd/controllers/core/clustercatalog_controller_test.go Updates mock expectations to include VerifyAndSync.
Files not reviewed (1)
  • internal/testutil/mock/storage/mock_instance.go: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +234 to +264
// VerifyAndSync verifies that catalog.jsonl exists at RootDir/<catalog>/catalog.jsonl,
// calls fsync to ensure the file is durably written to disk, and confirms the file is
// readable by attempting a small read. It should be called after Store() succeeds and
// before marking the catalog as Serving.
func (s *LocalDirV1) VerifyAndSync(catalog string) error {
s.m.RLock()
defer s.m.RUnlock()

path := catalogFilePath(s.catalogDir(catalog))

if _, err := os.Stat(path); err != nil {
return fmt.Errorf("catalog.jsonl not found at %q: %w", path, err)
}

f, err := os.Open(path)
if err != nil {
return fmt.Errorf("catalog.jsonl not readable at %q: %w", path, err)
}
defer f.Close()

if err := f.Sync(); err != nil {
return fmt.Errorf("fsync failed for catalog.jsonl at %q: %w", path, err)
}

buf := make([]byte, 1)
if _, err := f.Read(buf); err != nil && !errors.Is(err, io.EOF) {
return fmt.Errorf("catalog.jsonl read failed at %q: %w", path, err)
}

return nil
}
Comment on lines +18 to +22
// VerifyAndSync confirms that catalog.jsonl exists on disk for the given
// catalog, flushes it to stable storage via fsync, and verifies the file
// is readable. It must be called after Store and before marking the
// catalog as Serving.
VerifyAndSync(catalog string) error
@tmshort

tmshort commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

@dis016 please prefix your PR title with :bug: (before the OCPBUGS jira space name).
Also address the copilot comments.

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

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants