Skip to content

Commit b27c303

Browse files
committed
update cri-api runtime interface and cri-client add new method
1 parent 8f11574 commit b27c303

File tree

5 files changed

+80
-29
lines changed

5 files changed

+80
-29
lines changed

staging/src/k8s.io/cri-api/pkg/apis/services.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ type PodSandboxManager interface {
8282
ListPodSandbox(ctx context.Context, filter *runtimeapi.PodSandboxFilter) ([]*runtimeapi.PodSandbox, error)
8383
// PortForward prepares a streaming endpoint to forward ports from a PodSandbox, and returns the address.
8484
PortForward(ctx context.Context, request *runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error)
85+
// UpdatePodSandboxResources synchronously updates the PodSandboxConfig with
86+
// the pod-level resource configuration. This method is called _after_ the
87+
// Kubelet reconfigures the pod-level cgroups.
88+
// This request is treated as best effort, and failure will not block the
89+
// Kubelet with proceeding with a resize.
90+
UpdatePodSandboxResources(ctx context.Context, request *runtimeapi.UpdatePodSandboxResourcesRequest) (*runtimeapi.UpdatePodSandboxResourcesResponse, error)
8591
}
8692

8793
// ContainerStatsManager contains methods for retrieving the container

staging/src/k8s.io/cri-api/pkg/apis/testing/fake_runtime_service.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,3 +794,16 @@ func (r *FakeRuntimeService) RuntimeConfig(_ context.Context) (*runtimeapi.Runti
794794

795795
return &runtimeapi.RuntimeConfigResponse{Linux: r.FakeLinuxConfiguration}, nil
796796
}
797+
798+
// UpdatePodSandboxResources returns the container resource in the FakeRuntimeService.
799+
func (r *FakeRuntimeService) UpdatePodSandboxResources(context.Context, *runtimeapi.UpdatePodSandboxResourcesRequest) (*runtimeapi.UpdatePodSandboxResourcesResponse, error) {
800+
r.Lock()
801+
defer r.Unlock()
802+
803+
r.Called = append(r.Called, "UpdatePodSandboxResources")
804+
if err := r.popError("UpdatePodSandboxResources"); err != nil {
805+
return nil, err
806+
}
807+
808+
return &runtimeapi.UpdatePodSandboxResourcesResponse{}, nil
809+
}

staging/src/k8s.io/cri-client/pkg/fake/fake_runtime.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,8 @@ func (f *RemoteRuntime) RuntimeConfig(ctx context.Context, req *kubeapi.RuntimeC
366366

367367
return resp, nil
368368
}
369+
370+
// UpdatePodSandboxResources synchronously updates the PodSandboxConfig.
371+
func (f *RemoteRuntime) UpdatePodSandboxResources(ctx context.Context, req *kubeapi.UpdatePodSandboxResourcesRequest) (*kubeapi.UpdatePodSandboxResourcesResponse, error) {
372+
return f.RuntimeService.UpdatePodSandboxResources(ctx, req)
373+
}

staging/src/k8s.io/cri-client/pkg/remote_runtime.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,23 @@ func (r *remoteRuntimeService) portForwardV1(ctx context.Context, req *runtimeap
610610
return resp, nil
611611
}
612612

613+
// UpdatePodSandboxResources synchronously updates the PodSandboxConfig with
614+
// the pod-level resource configuration.
615+
func (r *remoteRuntimeService) UpdatePodSandboxResources(ctx context.Context, req *runtimeapi.UpdatePodSandboxResourcesRequest) (*runtimeapi.UpdatePodSandboxResourcesResponse, error) {
616+
r.log(10, "[RemoteRuntimeService] UpdatePodSandboxResources", "PodSandboxId", req.PodSandboxId, "timeout", r.timeout)
617+
ctx, cancel := context.WithTimeout(ctx, r.timeout)
618+
defer cancel()
619+
620+
resp, err := r.runtimeClient.UpdatePodSandboxResources(ctx, req)
621+
if err != nil {
622+
r.logErr(err, "UpdatePodSandboxResources from runtime service failed", "podSandboxID", req.PodSandboxId)
623+
return nil, err
624+
}
625+
r.log(10, "[RemoteRuntimeService] UpdatePodSandboxResources Response", "podSandboxID", req.PodSandboxId)
626+
627+
return resp, nil
628+
}
629+
613630
// UpdateRuntimeConfig updates the config of a runtime service. The only
614631
// update payload currently supported is the pod CIDR assigned to a node,
615632
// and the runtime service just proxies it down to the network plugin.

test/e2e_node/criproxy/proxy_runtime_service.go

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,36 @@ import (
3434
)
3535

3636
const (
37-
Version = "Version"
38-
RunPodSandbox = "RunPodSandbox"
39-
StopPodSandbox = "StopPodSandbox"
40-
RemovePodSandbox = "RemovePodSandbox"
41-
PodSandboxStatus = "PodSandboxStatus"
42-
ListPodSandbox = "ListPodSandbox"
43-
CreateContainer = "CreateContainer"
44-
StartContainer = "StartContainer"
45-
StopContainer = "StopContainer"
46-
RemoveContainer = "RemoveContainer"
47-
ListContainers = "ListContainers"
48-
ContainerStatus = "ContainerStatus"
49-
UpdateContainerResources = "UpdateContainerResources"
50-
ReopenContainerLog = "ReopenContainerLog"
51-
ExecSync = "ExecSync"
52-
Exec = "Exec"
53-
Attach = "Attach"
54-
PortForward = "PortForward"
55-
ContainerStats = "ContainerStats"
56-
ListContainerStats = "ListContainerStats"
57-
PodSandboxStats = "PodSandboxStats"
58-
ListPodSandboxStats = "ListPodSandboxStats"
59-
UpdateRuntimeConfig = "UpdateRuntimeConfig"
60-
Status = "Status"
61-
CheckpointContainer = "CheckpointContainer"
62-
GetContainerEvents = "GetContainerEvents"
63-
ListMetricDescriptors = "ListMetricDescriptors"
64-
ListPodSandboxMetrics = "ListPodSandboxMetrics"
65-
RuntimeConfig = "RuntimeConfig"
37+
Version = "Version"
38+
RunPodSandbox = "RunPodSandbox"
39+
StopPodSandbox = "StopPodSandbox"
40+
RemovePodSandbox = "RemovePodSandbox"
41+
PodSandboxStatus = "PodSandboxStatus"
42+
ListPodSandbox = "ListPodSandbox"
43+
CreateContainer = "CreateContainer"
44+
StartContainer = "StartContainer"
45+
StopContainer = "StopContainer"
46+
RemoveContainer = "RemoveContainer"
47+
ListContainers = "ListContainers"
48+
ContainerStatus = "ContainerStatus"
49+
UpdateContainerResources = "UpdateContainerResources"
50+
ReopenContainerLog = "ReopenContainerLog"
51+
ExecSync = "ExecSync"
52+
Exec = "Exec"
53+
Attach = "Attach"
54+
PortForward = "PortForward"
55+
ContainerStats = "ContainerStats"
56+
ListContainerStats = "ListContainerStats"
57+
PodSandboxStats = "PodSandboxStats"
58+
ListPodSandboxStats = "ListPodSandboxStats"
59+
UpdateRuntimeConfig = "UpdateRuntimeConfig"
60+
Status = "Status"
61+
CheckpointContainer = "CheckpointContainer"
62+
GetContainerEvents = "GetContainerEvents"
63+
ListMetricDescriptors = "ListMetricDescriptors"
64+
ListPodSandboxMetrics = "ListPodSandboxMetrics"
65+
RuntimeConfig = "RuntimeConfig"
66+
UpdatePodSandboxResources = "UpdatePodSandboxResources"
6667
)
6768

6869
// AddInjector inject the error or delay to the next call to the RuntimeService.
@@ -407,6 +408,15 @@ func (p *RemoteRuntime) UpdateRuntimeConfig(ctx context.Context, req *runtimeapi
407408
return &runtimeapi.UpdateRuntimeConfigResponse{}, nil
408409
}
409410

411+
// UpdatePodSandboxResources synchronously updates the PodSandboxConfig.
412+
func (p *RemoteRuntime) UpdatePodSandboxResources(ctx context.Context, req *runtimeapi.UpdatePodSandboxResourcesRequest) (*runtimeapi.UpdatePodSandboxResourcesResponse, error) {
413+
if err := p.runInjectors(UpdatePodSandboxResources); err != nil {
414+
return nil, err
415+
}
416+
417+
return p.runtimeService.UpdatePodSandboxResources(ctx, req)
418+
}
419+
410420
// Status returns the status of the runtime.
411421
func (p *RemoteRuntime) Status(ctx context.Context, req *runtimeapi.StatusRequest) (*runtimeapi.StatusResponse, error) {
412422
if err := p.runInjectors(Status); err != nil {

0 commit comments

Comments
 (0)