WIP: bug fix: OCPBUGS-97746: verify and sync catalog.jsonl file is available before…#2819
WIP: bug fix: OCPBUGS-97746: verify and sync catalog.jsonl file is available before…#2819dis016 wants to merge 1 commit into
Conversation
… populating updateStatus
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
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.Instanceinterface withVerifyAndSync(catalog string) error. - Implemented
VerifyAndSyncforLocalDirV1to stat/open/fsync and minimally readcatalog.jsonl. - Updated the
ClusterCatalogreconciler to callVerifyAndSyncafterStore()and before settingServing, 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.
| // 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 | ||
| } |
| // 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 |
|
@dis016 please prefix your PR title with |
bug fix: OCPBUGS-97746 verify and sync catalog.jsonl file is available before populating updateStatus