-
-
Notifications
You must be signed in to change notification settings - Fork 520
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
[management] Refactor peers to use store methods #2893
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
…unt-refactoring # Conflicts: # management/server/sql_store.go
…nt-refactoring # Conflicts: # management/server/sql_store.go
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
# Conflicts: # management/server/group.go # management/server/group/group.go # management/server/setupkey.go # management/server/sql_store.go # management/server/status/error.go # management/server/store.go
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
…account-refactoring
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
e8a5d16
to
9950683
Compare
Signed-off-by: bcmmbaga <[email protected]>
9950683
to
20fc8e8
Compare
Signed-off-by: bcmmbaga <[email protected]>
21f57c0
to
4abf9ad
Compare
Signed-off-by: bcmmbaga <[email protected]>
4abf9ad
to
82746d9
Compare
# Conflicts: # management/server/policy.go # management/server/posture_checks_test.go # management/server/sql_store.go # management/server/sql_store_test.go # management/server/status/error.go # management/server/store.go # management/server/testdata/extended-store.sql
# Conflicts: # management/server/sql_store_test.go # management/server/status/error.go # management/server/testdata/extended-store.sql
…unt-refactoring # Conflicts: # management/server/account.go # management/server/http/peers_handler.go # management/server/peer.go
# Conflicts: # management/server/sql_store_test.go
… user peers with empty userID Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
management/server/account.go
Outdated
unlock := am.Store.AcquireWriteLockByUID(ctx, accountID) | ||
defer unlock() |
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.
don't remove the lock just yet
management/server/ephemeral.go
Outdated
for _, p := range peers { | ||
if p.Ephemeral { | ||
count++ | ||
e.addPeer(p.AccountID, p.ID, t) |
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.
the DB call already returns ephemeral peers. No need for the if and the counter, we can go Len(peers)
|
||
peerGroups, err := h.accountManager.GetPeerGroups(r.Context(), accountID, peer.ID) | ||
if err != nil { | ||
util.WriteError(r.Context(), err, w) | ||
return | ||
} | ||
groupMinimumInfo := toGroupsInfo(peerGroups) |
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.
I wonder if it makes sense here to keep get getAllGroups approach. As the method is getAllPeers, we will probably also need close to all groups. So I would keep it as one call
err = am.Store.ExecuteInTransaction(ctx, func(transaction Store) error { | ||
groups, err = transaction.GetAccountGroups(ctx, LockingStrengthShare, accountID) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
peers, err = transaction.GetAccountPeers(ctx, LockingStrengthShare, accountID) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
settings, err = transaction.GetAccountSettings(ctx, LockingStrengthShare, accountID) | ||
return err | ||
}) |
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.
Not sure how much effect this transaction will have but should not hurt either
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.
I was waiting for #2957 to measure the performance, but I am already planning to continue passing the account object instead of db calls, since all the methods calling this have access to the account object
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
# Conflicts: # management/server/peer.go
Signed-off-by: bcmmbaga <[email protected]>
Quality Gate failedFailed conditions See analysis details on SonarQube Cloud Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE |
Describe your changes
Remove calls to get and save whole account in peers operations.
Issue ticket number and link
Checklist