-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add support to clean Np indexers based on account #262
Conversation
Anandkumar26
commented
Jun 26, 2023
•
edited
Loading
edited
- When CPA is deleted, it will notify a local event to np controller.
- As part of processing local event, np controller will clear entries corresponding to the account from appliedToSGIndexer, addrSGIndexer, cloudRuleIndexer and networkPolicyIndexer.
- Remove AT/AG groups from retryQueue for the account.
- Remove groups from pendingDeleteGroups based on account.
baaca9d
to
c8f1255
Compare
|
||
case *crdv1alpha1.CloudProviderAccount: | ||
cpa := event.Object.(*crdv1alpha1.CloudProviderAccount) | ||
return r.RemoveIndexerObjectsByAccount(types.NamespacedName{Name: cpa.Name, Namespace: cpa.Namespace}.String()) |
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.
nit remove
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.
Done
19e54f5
to
e791440
Compare
} | ||
for i := range atSgs { | ||
if atSgs[i] == nil { | ||
continue |
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.
Why would this be nil?
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.
While testing out namespace deletion, I observed a crash saying interface is nil
.
I observed it while traversing agSgs.
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.
When we retrieve objects using by Index, the length of the objects returned can be non-zero, yet while accessing the obj(interface), the obj(interface) can be nil.
I tried this by deleting an object in the indexer and got all the objects using Byindex immediately.
one of the object returned was nil.
So while retrieving objects by Index, we should check if the interface can be converted to a required object and then proceed.
850b245
to
26a5a3e
Compare
// Remove AG group from retryQueue and pendingDeleteGroups. | ||
uName := getGroupUniqueName(agSg.id.CloudResourceID.String(), true) | ||
uGroupName := getGroupUniqueName(agSg.id.Name, true) | ||
r.retryQueue.Remove(uName) |
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.
This wont work. In case of delete, we remove the item from indexer first, and then put in retry queue. So, you wont find the item for lookup in retry queue. You might have to iterate over items in the queue and delete all matching account-id.
74e17c7
to
5a046db
Compare
} | ||
|
||
// Remove AT and AG group from retryQueue. | ||
for _, item := range r.retryQueue.items { |
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.
What about pending queue.. I see you are removing from retryQueue only.
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.
In PendingGroup, we only store the GroupMember, so we wont be able to delete an entry based on account.
5a046db
to
5cb2c92
Compare
- When CPA is deleted, it will notify a local event to np controller. - As part of processing local event, np controller will clear entries corresponding to the account from appliedToSGIndexer, addrSGIndexer, cloudRuleIndexer and networkPolicyIndexer. - Remove AT/AG group from retryQueue based on account - Remove groups from pendingDeleteGroups based on account Signed-off-by: Anand Kumar <[email protected]>
5cb2c92
to
2331c0d
Compare
|
||
for _, item := range r.pendingDeleteGroups.items { | ||
group, ok := item.PendingItem.(*pendingGroup) | ||
if ok && group.account == namespacedName { |
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.
nit: Rename to accountID for next PR, to be consistent with Retry Queue
/nephe-test-e2e-agentless |
/nephe-test-e2e-aws |
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.
/LGTM