-
Notifications
You must be signed in to change notification settings - Fork 52
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 TG garbage collector #580
Conversation
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.
Reviewed this PR and overall LGTM
defer func() { | ||
tgGc.lock.Unlock() | ||
}() | ||
tgGc.lock.Lock() |
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.
Can you add some comments here for the reason we need to do Lock and 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.
ok
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.
updated
pkg/deploy/stack_deployer.go
Outdated
tgGcFn := NewTgGcFn(tgGcSynth) | ||
tgGc = &TgGc{ | ||
lock: sync.Mutex{}, | ||
log: log.Named("gc"), |
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.
log.Named("tgGc") ?
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.
usually log names are lower case, can do "tg-gc" or "tg.gc"
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.
Would we ever garbage collect services? I think this would be the only GC
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 think we should not use GC at all. It will be a problem in future - global lock will cause contention and need carefully lock/unlock otherwise we will deadlock route reconciliations. This solution is a little pain relief from doing full TG clean up on each reconciliation loop.
We should have a better mechanism to identify TGs when we create brand new TG or when we replace old one and deletion is required. In that case we dont need locks, since problem will be properly partitioned by single-threaded owners - reconcilers.
} | ||
succ := 0 | ||
for _, res := range results { | ||
if res.Err == 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.
Do we need to print res.Err
or do errors.Join(res.Err) and return it with TgGcResult{}?
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 really, mostly errors happen when TG is in state that cannot be deleted yet. It pollutes logs.
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 think critical errors needs to be logged in SynthesizeUnusedDelete, or need to wrap them into some "NonOk" types and do type check here.
svcBuilder := gateway.NewLatticeServiceBuilder(log, k8sClient, brTgBuilder) | ||
|
||
tgGcOnce.Do(func() { | ||
// TODO: need to refactor TG synthesizer. Remove stack from constructor |
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.
Is this TODO a future issue?
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.
We should revisit synthesizers, the concept of abstract stack that we build and how it's actually implemented is questionable.
Overall LGTM, love the use of goroutines here. |
Note:
Address performance issue for unused target group cleanup. Implemented background garbage collector, that runs every X seconds. Might need to tune timers after.
e2e tests pass:
close #552