-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Handle Unhealthy devices #57266
Handle Unhealthy devices #57266
Conversation
@vikaschoudhary16: GitHub didn't allow me to request PR reviews from the following users: RenaudWasTaken, tengqm, ScorpioCPH. Note that only kubernetes members can review this PR, and authors cannot review their own PRs. In response to this:
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. |
ee8267d
to
72d3ff2
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.
Thanks a lot for your work! Some quick comments.
for _, name := range deletedResources { | ||
if name != resourceName { | ||
continue | ||
} else { |
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.
nit: can we remove else
statement? as we have called continue
in the above if
statement.
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 part is changed now.
healthyDevices map[string]sets.String | ||
|
||
// unhealthyDevices contains all of the unhealthy devices and their exported device IDs. | ||
unhealthyDevices map[string]sets.String |
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'm just wondering is there any benefits we keep unhealthyDevices
in cache here. Maybe we can make more discussions about this :)
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.
Kubelet needs to update node status taking into account unhealthy devices also(in the capacity). If we dont store unhealthy devices here in device manager, i am not sure how kubelet will sync this info. Would love to hear any suggestions?
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 the main benefit is to surface unhealthy device information more clearly through node status to facilitate monitoring and problem detection.
pkg/kubelet/kubelet_node_status.go
Outdated
@@ -545,6 +545,7 @@ func (kl *Kubelet) setNodeAddress(node *v1.Node) error { | |||
func (kl *Kubelet) setNodeStatusMachineInfo(node *v1.Node) { | |||
// Note: avoid blindly overwriting the capacity in case opaque | |||
// resources are being advertised. | |||
//glog.Info("Error getting machine info: %v", 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.
nit: is this a error info?
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.
Thanks for pointing out. Left by mistake.
72d3ff2
to
157272a
Compare
157272a
to
53a6203
Compare
/test pull-kubernetes-unit |
53a6203
to
fc59f7c
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.
Thanks a lot for the change! Please see inline comments.
pkg/kubelet/cm/container_manager.go
Outdated
@@ -72,7 +72,7 @@ type ContainerManager interface { | |||
|
|||
// GetDevicePluginResourceCapacity returns the amount of device plugin resources available on the node | |||
// and inactive device plugin resources previously registered on the node. |
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.
Could you update the comment to cope with the change?
healthyDevices map[string]sets.String | ||
|
||
// unhealthyDevices contains all of the unhealthy devices and their exported device IDs. | ||
unhealthyDevices map[string]sets.String |
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 the main benefit is to surface unhealthy device information more clearly through node status to facilitate monitoring and problem detection.
} | ||
} | ||
for _, dev := range deleted { | ||
m.allDevices[resourceName].Delete(dev.ID) | ||
if dev.Health == pluginapi.Healthy { |
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 dev health state reported here may not be consistent with the cached state. Maybe simply do:
m.healthyDevices[resourceName].Delete(dev.ID)
m.unhealthyDevices[resourceName].Delete(dev.ID)
pkg/kubelet/kubelet_node_status.go
Outdated
@@ -594,13 +596,15 @@ func (kl *Kubelet) setNodeStatusMachineInfo(node *v1.Node) { | |||
} | |||
} | |||
|
|||
devicePluginCapacity, removedDevicePlugins := kl.containerManager.GetDevicePluginResourceCapacity() | |||
devicePluginCapacity, allocatable, removedDevicePlugins := kl.containerManager.GetDevicePluginResourceCapacity() |
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 we just assign to devicePluginAllocatable here directly?
@@ -453,9 +487,9 @@ func (m *ManagerImpl) readCheckpoint() error { | |||
m.podDevices.fromCheckpointData(data.PodDeviceEntries) | |||
m.allocatedDevices = m.podDevices.devices() | |||
for resource, devices := range data.RegisteredDevices { | |||
m.allDevices[resource] = sets.NewString() | |||
m.healthyDevices[resource] = sets.NewString() |
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.
Could you add a TODO comment on considering to also checkpoint unhealthy device information?
} else { | ||
capacityCount := capacity[v1.ResourceName(resourceName)] | ||
unhealthyCount := *resource.NewQuantity(int64(devices.Len()), resource.DecimalSI) | ||
capacityCount.Add(unhealthyCount) |
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.
What if resource doesn't exist in capacity yet? Would we get a segfault here? Can we add some unit test for this?
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.
Test is already there: https://github.com/vikaschoudhary16/kubernetes/blob/dc541fa0365de94d1c201baa74bce84d20bd9553/pkg/kubelet/cm/deviceplugin/manager_test.go#L203-L211
Looks like it wont crash. Just take a look here:
https://play.golang.org/p/pi1bI3caJRL
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.
Interesting to know. I guess the map lookup just returns struct with zero values when the key doesn't exist.
These documents will need to be updated:
It looks we need to start tracking the API changes we introduce so that we can document them. |
c3d1832
to
dc541fa
Compare
/retest |
Update node capacity with sum of both healthy and unhealthy devices. Node allocatable reflect only healthy devices.
dc541fa
to
e9cf3f1
Compare
/retest |
1 similar comment
/retest |
@jiayingz ping |
/lgtm |
ping @dchen1107 @derekwaynecarr |
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
Nice job. /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: derekwaynecarr, jiayingz, RenaudWasTaken, vikaschoudhary16 Associated issue: #57241 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
Update node capacity with sum of both healthy and unhealthy devices.
Node allocatable reflect only healthy devices.
What this PR does / why we need it:
Currently node capacity only reflects healthy devices. Unhealthy devices are ignored totally while updating node status. This PR handles unhealthy devices while updating node status.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #57241
Special notes for your reviewer:
Release note:
/cc @tengqm @ConnorDoyle @jiayingz @vishh @jeremyeder @sjenning @resouer @ScorpioCPH @lichuqiang @RenaudWasTaken @balajismaniam
/sig node