-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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 the workload health controller #17215
Conversation
da5a915
to
93c345a
Compare
509271c
to
300b669
Compare
a66a7e5
to
b9ed172
Compare
300b669
to
95ae401
Compare
b9ed172
to
d702cad
Compare
95ae401
to
73b732c
Compare
d702cad
to
c6bae49
Compare
73b732c
to
87bc35f
Compare
c6bae49
to
16fcab1
Compare
87bc35f
to
5279d27
Compare
16fcab1
to
9594a10
Compare
5279d27
to
040875a
Compare
9594a10
to
17ee0be
Compare
040875a
to
d39340e
Compare
0d1bae6
to
b6f86ee
Compare
d39340e
to
2edb268
Compare
b6f86ee
to
8d05b6c
Compare
a5f7ec5
to
fdbf749
Compare
8d05b6c
to
7b55777
Compare
fdbf749
to
49f2f51
Compare
7b55777
to
9f56985
Compare
49f2f51
to
e590726
Compare
9f56985
to
4a88416
Compare
e590726
to
6410f76
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.
This looks great Matt!!
I left some comments inline, the biggest one being about the node mapper and whether it's better than the "naive" mapper.
internal/catalog/internal/controllers/workloadhealth/controller.go
Outdated
Show resolved
Hide resolved
internal/catalog/internal/controllers/workloadhealth/controller.go
Outdated
Show resolved
Hide resolved
internal/catalog/internal/controllers/workloadhealth/controller_test.go
Outdated
Show resolved
Hide resolved
if resource.EqualStatus(res.Status[StatusKey], newStatus, false) { | ||
return nil | ||
} | ||
|
||
_, err = rt.Client.WriteStatus(ctx, &pbresource.WriteStatusRequest{ | ||
Id: res.Id, | ||
Key: StatusKey, | ||
Status: newStatus, | ||
}) |
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.
The propagation of this logic and the tests for it makes me feel like it should be in a helper because every controller would need to do the same thing.
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.
@boxofrad I agree with Iryna. Where do you think this logic should live. It could be a method on the controller.Runtime or it could live as a helper within the resource package.
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.
Specifically, do you mean calling WriteStatus
only if it's changed?
Runtime might work well. I'm imagining the signature will be:
func (r Runtime) WriteStatus(ctx context.Context, res *pbresource.Resource, key string, status *pbresource.Status) error {
// ...
}
Is that roughly what you have in mind?
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.
Yeah that’s what I was thinking.
6410f76
to
9107f47
Compare
4a88416
to
7eb038c
Compare
6ed8ced
to
6517df1
Compare
7eb038c
to
34924a7
Compare
6517df1
to
a465a8c
Compare
internal/catalog/internal/controllers/workloadhealth/controller.go
Outdated
Show resolved
Hide resolved
a465a8c
to
7e5e873
Compare
7e5e873
to
5dc5051
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.
Looks great! I left a few more comments, but don't think they are blocking.
internal/catalog/internal/mappers/nodemapper/node_mapper_test.go
Outdated
Show resolved
Hide resolved
internal/catalog/internal/controllers/workloadhealth/controller_test.go
Outdated
Show resolved
Hide resolved
internal/catalog/internal/controllers/workloadhealth/controller.go
Outdated
Show resolved
Hide resolved
internal/catalog/internal/controllers/workloadhealth/controller.go
Outdated
Show resolved
Hide resolved
5dc5051
to
de295b1
Compare
de295b1
to
edb2b71
Compare
Description
This PR builds on #17214. It implements a workload health controller similar to the node health controller that PR introduced.
This one is a little more complex though as workload health depends on health statuses with workload owners but also with the associated nodes. The workload health controller therefore needs an extra dependency that is capable of tracking the node <-> workload associations and to map node watch events into the corresponding workloads that require reconciliation.
Testing & Reproduction steps
PR Checklist