mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
move generate podsandbox request to platform specific
This commit is contained in:
parent
ce4de97c2e
commit
09817b320f
@ -413,10 +413,9 @@ func (m *kubeGenericRuntimeManager) updateContainerResources(pod *v1.Pod, contai
|
||||
}
|
||||
|
||||
func (m *kubeGenericRuntimeManager) updatePodSandboxResources(sandboxID string, pod *v1.Pod) error {
|
||||
podResourcesRequest := &runtimeapi.UpdatePodSandboxResourcesRequest{
|
||||
PodSandboxId: sandboxID,
|
||||
Overhead: m.convertOverheadToLinuxResources(pod),
|
||||
Resources: m.calculateSandboxResources(pod),
|
||||
podResourcesRequest := m.generateUpdatePodSandboxResourcesRequest(sandboxID, pod)
|
||||
if podResourcesRequest == nil {
|
||||
return fmt.Errorf("sandboxID %q updatePodSandboxResources failed: cannot generate resources config", sandboxID)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
@ -248,6 +248,15 @@ func (m *kubeGenericRuntimeManager) generateContainerResources(pod *v1.Pod, cont
|
||||
}
|
||||
}
|
||||
|
||||
// generateUpdatePodSandboxResourcesRequest generates platform specific (linux) podsandox resources config for runtime
|
||||
func (m *kubeGenericRuntimeManager) generateUpdatePodSandboxResourcesRequest(sandboxID string, pod *v1.Pod) *runtimeapi.UpdatePodSandboxResourcesRequest {
|
||||
return &runtimeapi.UpdatePodSandboxResourcesRequest{
|
||||
PodSandboxId: sandboxID,
|
||||
Overhead: m.convertOverheadToLinuxResources(pod),
|
||||
Resources: m.calculateSandboxResources(pod),
|
||||
}
|
||||
}
|
||||
|
||||
// calculateLinuxResources will create the linuxContainerResources type based on the provided CPU and memory resource requests, limits
|
||||
func (m *kubeGenericRuntimeManager) calculateLinuxResources(cpuRequest, cpuLimit, memoryLimit *resource.Quantity, disableCPUQuota bool) *runtimeapi.LinuxContainerResources {
|
||||
resources := runtimeapi.LinuxContainerResources{}
|
||||
|
@ -20,7 +20,7 @@ limitations under the License.
|
||||
package kuberuntime
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||
)
|
||||
@ -35,6 +35,11 @@ func (m *kubeGenericRuntimeManager) generateContainerResources(pod *v1.Pod, cont
|
||||
return nil
|
||||
}
|
||||
|
||||
// generateUpdatePodSandboxResourcesRequest generates platform specific podsandox resources config for runtime
|
||||
func (m *kubeGenericRuntimeManager) generateUpdatePodSandboxResourcesRequest(sandboxID string, pod *v1.Pod) *runtimeapi.UpdatePodSandboxResourcesRequest {
|
||||
return nil
|
||||
}
|
||||
|
||||
func toKubeContainerResources(statusResources *runtimeapi.ContainerResources) *kubecontainer.ContainerResources {
|
||||
return nil
|
||||
}
|
||||
|
@ -47,6 +47,13 @@ func (m *kubeGenericRuntimeManager) generateContainerResources(pod *v1.Pod, cont
|
||||
}
|
||||
}
|
||||
|
||||
// generateUpdatePodSandboxResourcesRequest generates platform specific podsandox resources config for runtime
|
||||
func (m *kubeGenericRuntimeManager) generateUpdatePodSandboxResourcesRequest(sandboxID string, pod *v1.Pod) *runtimeapi.UpdatePodSandboxResourcesRequest {
|
||||
return &runtimeapi.UpdatePodSandboxResourcesRequest{
|
||||
PodSandboxId: sandboxID,
|
||||
}
|
||||
}
|
||||
|
||||
// generateWindowsContainerResources generates windows container resources config for runtime
|
||||
func (m *kubeGenericRuntimeManager) generateWindowsContainerResources(pod *v1.Pod, container *v1.Container) *runtimeapi.WindowsContainerResources {
|
||||
wcr := m.calculateWindowsResources(container.Resources.Limits.Cpu(), container.Resources.Limits.Memory())
|
||||
|
Loading…
Reference in New Issue
Block a user