-
Notifications
You must be signed in to change notification settings - Fork 85
🐛OCPBUGS-97746: Add fsync to storeCatalogData and storeIndexData #2819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -179,6 +179,13 @@ func (s *LocalDirV1) storeAtomicSwap(ctx context.Context, catalog string, fsys f | |
| return "", err | ||
| } | ||
|
|
||
| if err := syncDir(catalogDir); err != nil { | ||
| return "", fmt.Errorf("error syncing catalog directory: %w", err) | ||
| } | ||
| if err := syncDir(s.RootDir); err != nil { | ||
| return "", fmt.Errorf("error syncing storage root directory: %w", err) | ||
| } | ||
|
Comment on lines
+185
to
+187
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Persist the rollback removal after GraphQL validation fails. When 🤖 Prompt for AI Agents |
||
|
|
||
| return catalogDir, nil | ||
| } | ||
|
|
||
|
|
@@ -281,7 +288,7 @@ func storeCatalogData(catalogDir string, metas <-chan *declcfg.Meta) error { | |
| return err | ||
| } | ||
| } | ||
| return nil | ||
| return f.Sync() | ||
| } | ||
|
|
||
| func storeIndexData(catalogDir string, metas <-chan *declcfg.Meta) error { | ||
|
|
@@ -295,7 +302,19 @@ func storeIndexData(catalogDir string, metas <-chan *declcfg.Meta) error { | |
|
|
||
| enc := json.NewEncoder(f) | ||
| enc.SetEscapeHTML(false) | ||
| return enc.Encode(idx) | ||
| if err := enc.Encode(idx); err != nil { | ||
| return err | ||
| } | ||
| return f.Sync() | ||
| } | ||
|
|
||
| func syncDir(dir string) error { | ||
| d, err := os.Open(dir) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| defer d.Close() | ||
| return d.Sync() | ||
| } | ||
|
|
||
| func discoverAndStoreSchema(catalogDir string, metas <-chan *declcfg.Meta) error { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be worthwhile to add a comment around why we're explicitly sync'ing the directories?