-
Notifications
You must be signed in to change notification settings - Fork 364
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
chore: consolidate k8s informers code & fix Makefile mocks #7455
Conversation
✅ Deploy Preview for determined-ui ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
func (i *informer) run() { | ||
ctx, cancel := context.WithCancel(context.TODO()) | ||
i.syslog.Debugf("%s informer is starting", i.name) | ||
for { | ||
select { | ||
case event := <-i.resultChan: | ||
if event.Type == watch.Error { | ||
i.syslog.Warnf("%s informer emitted error %+v", i.name, event) | ||
continue | ||
} | ||
i.cb(event) | ||
cancel() | ||
case <-ctx.Done(): | ||
panic(fmt.Sprintf("%s informer stopped unexpectedly: %s", i.name, ctx.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.
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.
reverted because informers crash with this implementation
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 shouldn't be calling cancel in the informer run loop.
i would've just made run()
take a context like run(ctx context.Context)
, pass context.TODO()
for now in the pods actor, and then in tests, at the top of each test
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
and use that context in the run
calls in the test
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
4bdfb33
to
bde62bf
Compare
8b501c2
to
0bb844b
Compare
Description
After removing the actor system from the k8s informers code, refactor the pod/node/event/preemption informer code to remove redundancies & consolidate (if possible) to fewer functions. (This PR would reduce that code by 40%, yay!)
Each informer defines its own "callback function", but now these callback functions are standardized to accept
watch.Event
s (vs other struct types). This additionally standardizes therun()
function.Since each informer constructor calls on/returns different types, the
newInformer()
- type functions could not be combined. (The exception is withpod-Informer
andpreemption-Informer
, both of which deal with pod lists).Also -- this PR adds code to generate the Pod/EventInterface mocks.
Test Plan
Test in the a similar manner as #7182 and #7256.
Commentary (optional)
Checklist
docs/release-notes/
.See Release Note for details.
Ticket
DET-9686