-
Notifications
You must be signed in to change notification settings - Fork 303
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
Use NEG CRs for NEG Garbage Collection #1197
Conversation
Hi @swetharepakula. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
0e4ecdc
to
a219968
Compare
pkg/neg/manager.go
Outdated
@@ -370,6 +377,62 @@ func (manager *syncerManager) garbageCollectNEG() error { | |||
return nil | |||
} | |||
|
|||
// garbageCollectNEGWithCRD uses the NEG CRs and the svcPortMap to determine which NEGs | |||
// need to be garbage collected. NEGs that have a corresponding CR with a deletion | |||
// timestamp, don't exist in the svcPortMap or don't have a corresponding NEG in the |
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.
Complete the sentence ?
pkg/neg/manager.go
Outdated
} | ||
for _, cr := range deletionCandidates { | ||
cr.Finalizers = []string{} | ||
if cr.GetDeletionTimestamp().IsZero() { |
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.
probably need to send a delete call
pkg/neg/manager.go
Outdated
} | ||
if _, ok := deletionCandidates[neg.Name]; ok { | ||
if err := manager.ensureDeleteNetworkEndpointGroup(neg.Name, key.Zone); err != nil { | ||
return fmt.Errorf("failed to delete NEG %s in %s: %s", neg.Name, key.Zone, 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.
cannot return here.
Instead it should record an event to the NEG CR if it is there
// need to be garbage collected. NEGs that have a corresponding CR with a deletion | ||
// timestamp, don't exist in the svcPortMap or don't have a corresponding NEG in the | ||
// will all be garbage collected | ||
func (manager *syncerManager) garbageCollectNEGWithCRD() error { |
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.
Assumption is that NEG CR exists then NEG must not be fully GCed.
Try to report event to NEG CR if NEG cannot be GCed.
Case 1: NEG CR with deletion timestamp + Manager PortInfo Map does not have key
- Delete NEG
- Remove Finalizer
Case 2: NEG CR has deletion timestamp + Manager PortInfo Map has the key
- Don't Remove Finalizer until it becomes to Case 1
Case 3: NEG CR does not have deletion timestamp + Manager PortInfoMap does not have key (controller is down when the service or annotation is removed)
- Delete NEG
- Delete NEG CR
- Remove Finalzier
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.
func A: Delete NEG
func B: Delete NEG CR (Delete and remove Finalzier)
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.
For each deletion candidate (bool shouldDeleteNEG):
- if shouldDeleteNEG, then try delete NEG
- Delete NEG CR
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.
Deletion candidate:
case 1: shouldDeleteNEG = true
case 2: shouldDeleteNEG= false
case 3: shouldDeleteNEG = true
pkg/neg/manager.go
Outdated
} | ||
|
||
var errList []error | ||
for key, neg := range negList { |
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.
one corner to watch out:
cluster A -> try to create NEG foo. (NEG foo belongs cluster B)
when service or annotation got updated, and cluster A wants to GC NEG foo. Will it GC NEG foo?
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.
check description or initialized condition
65add2b
to
49c862c
Compare
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 overall
just nits.
pkg/neg/manager.go
Outdated
defer manager.mu.Unlock() | ||
for _, portInfoMap := range manager.svcPortMap { | ||
for _, portInfo := range portInfoMap { | ||
// only keep in deletionCandidates if neg does not exist in svcPortMap |
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.
add a comment regarding the 2 corner cases:
- NEG CR has deletionTimestamp but svcPortMap has the svc
- NEG CR does not have deletionTImeStamp but svcPortMap does not has the svc.
- Add finalizer to NEG CRs to ensure CR exists until NEG is deleted during GC - When neg crd is enabled, GC will use neg crs, otherwise will fallback to regular GC using the naming to determine which NEGs are to be deleted
49c862c
to
0fb2ea4
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: freehan, swetharepakula The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
during GC
to regular GC using the naming to determine which NEGs are to be
deleted