-
Notifications
You must be signed in to change notification settings - Fork 0
Dual Storage Architecture #5
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: dual-storage-baseline
Are you sure you want to change the base?
Conversation
* Dual writer: mode 3 * Add integration tests for playlits in mode 3 * Remove todo * Update pkg/apiserver/rest/dualwriter_mode3.go Co-authored-by: Arati R. <[email protected]> * Admin: Fixes an issue where user accounts could not be enabled (#88117) Fix: unable to enable user * [REVIEW] FInish mode 3 and add tests * Improve logging * Update dependencies * Update pkg/apiserver/rest/dualwriter_mode3_test.go Co-authored-by: maicon <[email protected]> * remove test assertion * Use mode log when dual writer is initiated --------- Co-authored-by: Arati R. <[email protected]> Co-authored-by: gonvee <[email protected]> Co-authored-by: maicon <[email protected]>
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.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Greptile OverviewConfidence Score: 0/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client
participant DualWriterMode3
participant Storage as Unified Storage
participant Legacy as Legacy Storage
participant Metrics
Note over DualWriterMode3: Mode 3: Write to both, Read from Storage
rect rgb(200, 220, 255)
Note over Client,Metrics: Create/Update/Delete Operations
Client->>DualWriterMode3: Create/Update/Delete(obj)
DualWriterMode3->>Storage: Create/Update/Delete(obj)
Storage-->>DualWriterMode3: result, err
alt Storage Success
DualWriterMode3->>Metrics: recordStorageDuration(success)
DualWriterMode3-->>Client: return result
par Async Legacy Write
DualWriterMode3->>Legacy: Create/Update/Delete(obj)
Legacy-->>DualWriterMode3: result, err
DualWriterMode3->>Metrics: recordLegacyDuration(success/fail)
end
else Storage Error
DualWriterMode3->>Metrics: recordStorageDuration(error)
DualWriterMode3-->>Client: return error
end
end
rect rgb(200, 255, 220)
Note over Client,Metrics: Read Operations (Get/List)
Client->>DualWriterMode3: Get/List()
DualWriterMode3->>Storage: Get/List()
Storage-->>DualWriterMode3: result, err
DualWriterMode3->>Metrics: recordStorageDuration()
DualWriterMode3-->>Client: return result
Note over Legacy: Legacy storage not used for reads
end
|
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.
5 files reviewed, 5 comments
| created, err := d.Storage.Create(ctx, obj, createValidation, options) | ||
| if err != nil { | ||
| log.Error(err, "unable to create object in storage") | ||
| d.recordLegacyDuration(true, mode3Str, options.Kind, method, startStorage) |
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.
logic: calling recordLegacyDuration when Storage.Create fails, should be recordStorageDuration
| d.recordLegacyDuration(true, mode3Str, options.Kind, method, startStorage) | |
| d.recordStorageDuration(true, mode3Str, options.Kind, method, startStorage) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: pkg/apiserver/rest/dualwriter_mode3.go
Line: 45:45
Comment:
**logic:** calling `recordLegacyDuration` when Storage.Create fails, should be `recordStorageDuration`
```suggestion
d.recordStorageDuration(true, mode3Str, options.Kind, method, startStorage)
```
How can I resolve this? If you propose a fix, please make it concise.| upstream: objInfo, | ||
| updated: updated, | ||
| log.Error(err, "unable to update in storage") | ||
| d.recordLegacyDuration(true, mode3Str, options.Kind, method, startStorage) |
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.
logic: calling recordLegacyDuration when Storage.Update fails, should be recordStorageDuration
| d.recordLegacyDuration(true, mode3Str, options.Kind, method, startStorage) | |
| d.recordStorageDuration(true, mode3Str, options.Kind, method, startStorage) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: pkg/apiserver/rest/dualwriter_mode3.go
Line: 129:129
Comment:
**logic:** calling `recordLegacyDuration` when Storage.Update fails, should be `recordStorageDuration`
```suggestion
d.recordStorageDuration(true, mode3Str, options.Kind, method, startStorage)
```
How can I resolve this? If you propose a fix, please make it concise.| d.recordStorageDuration(true, mode3Str, options.Kind, method, startStorage) | ||
| return res, async, err | ||
| } | ||
| d.recordStorageDuration(false, mode3Str, name, method, startStorage) |
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.
logic: recording metric with name parameter instead of options.Kind - inconsistent with other methods
| d.recordStorageDuration(false, mode3Str, name, method, startStorage) | |
| d.recordStorageDuration(false, mode3Str, options.Kind, method, startStorage) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: pkg/apiserver/rest/dualwriter_mode3.go
Line: 106:106
Comment:
**logic:** recording metric with `name` parameter instead of `options.Kind` - inconsistent with other methods
```suggestion
d.recordStorageDuration(false, mode3Str, options.Kind, method, startStorage)
```
How can I resolve this? If you propose a fix, please make it concise.| ctx, cancel := context.WithTimeoutCause(ctx, time.Second*10, errors.New("legacy deletecollection timeout")) | ||
| defer cancel() | ||
| _, err := d.Legacy.DeleteCollection(ctx, deleteValidation, options, listOptions) | ||
| d.recordStorageDuration(err != nil, mode3Str, options.Kind, method, startLegacy) |
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.
logic: calling recordStorageDuration in legacy goroutine, should be recordLegacyDuration
| d.recordStorageDuration(err != nil, mode3Str, options.Kind, method, startLegacy) | |
| d.recordLegacyDuration(err != nil, mode3Str, options.Kind, method, startLegacy) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: pkg/apiserver/rest/dualwriter_mode3.go
Line: 166:166
Comment:
**logic:** calling `recordStorageDuration` in legacy goroutine, should be `recordLegacyDuration`
```suggestion
d.recordLegacyDuration(err != nil, mode3Str, options.Kind, method, startLegacy)
```
How can I resolve this? If you propose a fix, please make it concise.| func (d *DualWriterMode3) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error) { | ||
| var method = "delete" | ||
| log := d.Log.WithValues("name", name, "kind", options.Kind, "method", method) | ||
| ctx = klog.NewContext(ctx, d.Log) |
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.
logic: using d.Log instead of local log variable that was just created with enriched context
| ctx = klog.NewContext(ctx, d.Log) | |
| ctx = klog.NewContext(ctx, log) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: pkg/apiserver/rest/dualwriter_mode3.go
Line: 97:97
Comment:
**logic:** using `d.Log` instead of local `log` variable that was just created with enriched context
```suggestion
ctx = klog.NewContext(ctx, log)
```
How can I resolve this? If you propose a fix, please make it concise.
Test 6
Replicated from ai-code-review-evaluation/grafana-greptile#6