-
Notifications
You must be signed in to change notification settings - Fork 129
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
[release-4.10] Bug 2104454: improve performance of service sync #1173
Merged
openshift-merge-robot
merged 4 commits into
openshift:release-4.10
from
jcaamano:release-4.10
Aug 1, 2022
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,14 +150,19 @@ func (m *ModelClient) WithClient(client client.Client) *ModelClient { | |
If BulkOp is set, update or mutate can happen accross multiple models found. | ||
*/ | ||
func (m *ModelClient) CreateOrUpdate(opModels ...OperationModel) ([]ovsdb.OperationResult, error) { | ||
created, ops, err := m.CreateOrUpdateOps(opModels...) | ||
created, ops, err := m.createOrUpdateOps(nil, opModels...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return TransactAndCheckAndSetUUIDs(m.client, created, ops) | ||
} | ||
|
||
func (m *ModelClient) CreateOrUpdateOps(opModels ...OperationModel) (interface{}, []ovsdb.Operation, error) { | ||
func (m *ModelClient) CreateOrUpdateOps(ops []ovsdb.Operation, opModels ...OperationModel) ([]ovsdb.Operation, error) { | ||
_, ops, err := m.createOrUpdateOps(ops, opModels...) | ||
return ops, err | ||
} | ||
|
||
func (m *ModelClient) createOrUpdateOps(ops []ovsdb.Operation, opModels ...OperationModel) (interface{}, []ovsdb.Operation, error) { | ||
doWhenFound := func(model interface{}, opModel *OperationModel) ([]ovsdb.Operation, error) { | ||
if opModel.OnModelUpdates != nil { | ||
return m.update(model, opModel) | ||
|
@@ -169,7 +174,7 @@ func (m *ModelClient) CreateOrUpdateOps(opModels ...OperationModel) (interface{} | |
doWhenNotFound := func(model interface{}, opModel *OperationModel) ([]ovsdb.Operation, error) { | ||
return m.create(opModel) | ||
} | ||
return m.buildOps(doWhenFound, doWhenNotFound, opModels...) | ||
return m.buildOps(ops, doWhenFound, doWhenNotFound, opModels...) | ||
} | ||
|
||
/* | ||
|
@@ -188,30 +193,32 @@ func (m *ModelClient) CreateOrUpdateOps(opModels ...OperationModel) (interface{} | |
If BulkOp is set, delete or mutate can happen accross multiple models found. | ||
*/ | ||
func (m *ModelClient) Delete(opModels ...OperationModel) error { | ||
ops, err := m.DeleteOps(opModels...) | ||
ops, err := m.DeleteOps(nil, opModels...) | ||
if err != nil { | ||
return err | ||
} | ||
_, err = TransactAndCheck(m.client, ops) | ||
return err | ||
} | ||
|
||
func (m *ModelClient) DeleteOps(opModels ...OperationModel) ([]ovsdb.Operation, error) { | ||
func (m *ModelClient) DeleteOps(ops []ovsdb.Operation, opModels ...OperationModel) ([]ovsdb.Operation, error) { | ||
doWhenFound := func(model interface{}, opModel *OperationModel) (o []ovsdb.Operation, err error) { | ||
if opModel.OnModelMutations != nil { | ||
return m.mutate(model, opModel, ovsdb.MutateOperationDelete) | ||
} else { | ||
return m.delete(model, opModel) | ||
} | ||
} | ||
_, ops, err := m.buildOps(doWhenFound, nil, opModels...) | ||
_, ops, err := m.buildOps(ops, doWhenFound, nil, opModels...) | ||
return ops, err | ||
} | ||
|
||
type opModelToOpMapper func(model interface{}, opModel *OperationModel) (o []ovsdb.Operation, err error) | ||
|
||
func (m *ModelClient) buildOps(doWhenFound opModelToOpMapper, doWhenNotFound opModelToOpMapper, opModels ...OperationModel) (interface{}, []ovsdb.Operation, error) { | ||
ops := []ovsdb.Operation{} | ||
func (m *ModelClient) buildOps(ops []ovsdb.Operation, doWhenFound opModelToOpMapper, doWhenNotFound opModelToOpMapper, opModels ...OperationModel) (interface{}, []ovsdb.Operation, error) { | ||
if ops == nil { | ||
ops = []ovsdb.Operation{} | ||
} | ||
notfound := []interface{}{} | ||
for _, opModel := range opModels { | ||
if opModel.ExistingResult == nil && opModel.Model != nil { | ||
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. commit1: LGTM, same as 4.11 no conflicts from cf3a846 |
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
awesome! :) this is exactly what I need for my cherry-pick :)