Skip to content
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

Merged
merged 1 commit into from
Jul 7, 2023

Conversation

Anandkumar26
Copy link
Contributor

@Anandkumar26 Anandkumar26 commented Jun 26, 2023

  • 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.

@Anandkumar26 Anandkumar26 force-pushed the account-delete branch 3 times, most recently from baaca9d to c8f1255 Compare June 26, 2023 11:00

case *crdv1alpha1.CloudProviderAccount:
cpa := event.Object.(*crdv1alpha1.CloudProviderAccount)
return r.RemoveIndexerObjectsByAccount(types.NamespacedName{Name: cpa.Name, Namespace: cpa.Namespace}.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Anandkumar26 Anandkumar26 force-pushed the account-delete branch 4 times, most recently from 19e54f5 to e791440 Compare June 28, 2023 15:11
}
for i := range atSgs {
if atSgs[i] == nil {
continue
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@Anandkumar26 Anandkumar26 force-pushed the account-delete branch 3 times, most recently from 850b245 to 26a5a3e Compare June 30, 2023 08:45
// Remove AG group from retryQueue and pendingDeleteGroups.
uName := getGroupUniqueName(agSg.id.CloudResourceID.String(), true)
uGroupName := getGroupUniqueName(agSg.id.Name, true)
r.retryQueue.Remove(uName)
Copy link
Contributor

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.

@Anandkumar26 Anandkumar26 force-pushed the account-delete branch 2 times, most recently from 74e17c7 to 5a046db Compare July 6, 2023 15:37
}

// Remove AT and AG group from retryQueue.
for _, item := range r.retryQueue.items {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

https://github.com/antrea-io/nephe/pull/262/files#diff-e370a727c5b2564b58693dfd2ff881f7df935871c0c0c806047c6613c4549c97R246

- 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]>

for _, item := range r.pendingDeleteGroups.items {
group, ok := item.PendingItem.(*pendingGroup)
if ok && group.account == namespacedName {
Copy link
Contributor

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

@reachjainrahul
Copy link
Contributor

/nephe-test-e2e-agentless

@reachjainrahul
Copy link
Contributor

/nephe-test-e2e-aws

Copy link
Contributor

@reachjainrahul reachjainrahul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/LGTM

@reachjainrahul reachjainrahul merged commit 627bb86 into main Jul 7, 2023
@reachjainrahul reachjainrahul deleted the account-delete branch July 7, 2023 20:15
@reachjainrahul reachjainrahul added this to the Nephe v0.6.0 release milestone Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants