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
CRI changes to support in-place pod resize #111645
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ import ( | |
type ActivePodsFunc func() []*v1.Pod | ||
|
||
type runtimeService interface { | ||
UpdateContainerResources(id string, resources *runtimeapi.LinuxContainerResources) error | ||
UpdateContainerResources(id string, resources *runtimeapi.ContainerResources) error | ||
} | ||
|
||
type policyName string | ||
|
@@ -515,8 +515,10 @@ func (m *manager) updateContainerCPUSet(containerID string, cpus cpuset.CPUSet) | |
// this patch-like partial resources. | ||
return m.containerRuntime.UpdateContainerResources( | ||
containerID, | ||
&runtimeapi.LinuxContainerResources{ | ||
CpusetCpus: cpus.String(), | ||
&runtimeapi.ContainerResources{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note to self: need to carry these param changes forward to the main/containerd/containerd/integration bucket for local testing |
||
Linux: &runtimeapi.LinuxContainerResources{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mark, thanks for the quick response. Does Windows have an equivalent for Cpuset? Unless I missed something, I don't see an equivalent in WindowsContainerResources. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There isn't an equivalent for cpuset on Windows (today) |
||
CpusetCpus: cpus.String(), | ||
}, | ||
}) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -641,20 +641,22 @@ func (r *remoteRuntimeService) containerStatusV1(ctx context.Context, containerI | |
} | ||
|
||
// UpdateContainerResources updates a containers resource config | ||
func (r *remoteRuntimeService) UpdateContainerResources(containerID string, resources *runtimeapi.LinuxContainerResources) (err error) { | ||
func (r *remoteRuntimeService) UpdateContainerResources(containerID string, resources *runtimeapi.ContainerResources) (err error) { | ||
klog.V(10).InfoS("[RemoteRuntimeService] UpdateContainerResources", "containerID", containerID, "timeout", r.timeout) | ||
ctx, cancel := getContextWithTimeout(r.timeout) | ||
defer cancel() | ||
|
||
if r.useV1API() { | ||
_, err = r.runtimeClient.UpdateContainerResources(ctx, &runtimeapi.UpdateContainerResourcesRequest{ | ||
ContainerId: containerID, | ||
Linux: resources, | ||
Linux: resources.GetLinux(), | ||
Windows: resources.GetWindows(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks to me the ContainerResources object declared below is unused. I think we should specify Linux, Windows and ContainerResources{Linux, Windows} to allow for some backwards compatibliity for containerd (whose old version expect just the Linux and Windows fields, and not yet the ContainerResources field). Am I interpreting this right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIUC, originally I had a separate ContainerResources with Linux and windows - it is still in the KEP , but WindowsContainerResources was added to UCRR and made that unnecessary, and I removed it recently after @mikebrow spotted it Please see comment Did I misunderstand you? |
||
}) | ||
} else { | ||
_, err = r.runtimeClientV1alpha2.UpdateContainerResources(ctx, &runtimeapiV1alpha2.UpdateContainerResourcesRequest{ | ||
ContainerId: containerID, | ||
Linux: v1alpha2LinuxContainerResources(resources), | ||
Linux: v1alpha2LinuxContainerResources(resources.GetLinux()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We updated v1alpha2 with the new ContainerResources structure, so I think we should do the same we do above. If we don't update v1alpha2, then we can leave this as it is now IMO There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, adding.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no conversion function for v1alpha2LinuxContainerResources. diff --git a/pkg/kubelet/cri/remote/conversion.go b/pkg/kubelet/cri/remote/conversion.go
index 35539397755..120b718cbf5 100644
--- a/pkg/kubelet/cri/remote/conversion.go
+++ b/pkg/kubelet/cri/remote/conversion.go
@@ -113,6 +113,10 @@ func v1alpha2LinuxContainerResources(from *runtimeapi.LinuxContainerResources) *
return (*v1alpha2.LinuxContainerResources)(unsafe.Pointer(from))
}
+func v1alpha2WindowsContainerResources(from *runtimeapi.WindowsContainerResources) *v1alpha2.WindowsContainerResources {
+ return (*v1alpha2.WindowsContainerResources)(unsafe.Pointer(from))
+}
+
func v1alpha2ExecRequest(from *runtimeapi.ExecRequest) *v1alpha2.ExecRequest {
// If this function changes, also adapt the corresponding Exec code in
// pkg/kubelet/cri/remote/remote_runtime.go
diff --git a/pkg/kubelet/cri/remote/remote_runtime.go b/pkg/kubelet/cri/remote/remote_runtime.go
index a09879b346a..976f845e011 100644
--- a/pkg/kubelet/cri/remote/remote_runtime.go
+++ b/pkg/kubelet/cri/remote/remote_runtime.go
@@ -639,6 +639,7 @@ func (r *remoteRuntimeService) UpdateContainerResources(containerID string, reso
_, err = r.runtimeClientV1alpha2.UpdateContainerResources(ctx, &runtimeapiV1alpha2.UpdateContainerResourcesRequest{
ContainerId: containerID,
Linux: v1alpha2LinuxContainerResources(resources.GetLinux()),
+ Windows: v1alpha2WindowsContainerResources(resources.GetWindows()),
})
}
if err != nil { There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps @marosset can comment if this is needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah that looks correct. this could also take the approach of other recent CRI changes and just drop v1alpha2 support There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SG. Adding with rebase fix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like containerd has had support updating Windows resources in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually the changes I just linked use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can remove it with the main feature changes in 1.26. I've added a TODO tracking item for this. |
||
Windows: v1alpha2WindowsContainerResources(resources.GetWindows()), | ||
}) | ||
} | ||
if 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.
not a blocker but rather just to confirm, changing this parameter from
LinuxContainerResources
toContainerResources
could be decoupled from the CRI changes right? remote_runtime would just need to call UpdateContainerResources with LinuxContainerResources directly (windows would not be supported tho).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.
Does runtime call this? IIUC, runtime responds to it, and yes it does not have to change. The UpdateContainerResourcesRequest.Linux field will contain what it needs same as before. Windows runtime looks at UpdateContainerResourcesRequest.Windows.
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.
because of the way the changes went in (not changing the CRI api except for the additional status field and some additional context) the client side manager proto should only impact cri-tools implementing the manager and container runtimes doing integration by implementing a manager for 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.
I'd be good with decoupling the client side manager changes as well.. if desired..
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.
noting windows was there in the request before, but was not being used:
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.
That I understand. I was just trying to confirm the parameters here did not need to change.
Gotcha. Yeah in that case this should have very little risk. I am okay with leaving this as the current PR is.