add get cgroupdriver from RuntimeConfig to integration
Signed-off-by: lengrongfu <lenronfu@gmail.com>
This commit is contained in:
		| @@ -121,6 +121,14 @@ type RuntimeService interface { | ||||
| 	UpdateRuntimeConfig(runtimeConfig *runtimeapi.RuntimeConfig, opts ...grpc.CallOption) error | ||||
| 	// Status returns the status of the runtime. | ||||
| 	Status(opts ...grpc.CallOption) (*runtimeapi.RuntimeStatus, error) | ||||
| 	// RuntimeConfig returns configuration information of the runtime. | ||||
| 	// A couple of notes: | ||||
| 	//   - The RuntimeConfigRequest object is not to be confused with the contents of UpdateRuntimeConfigRequest. | ||||
| 	//     The former is for having runtime tell Kubelet what to do, the latter vice versa. | ||||
| 	//   - It is the expectation of the Kubelet that these fields are static for the lifecycle of the Kubelet. | ||||
| 	//     The Kubelet will not re-request the RuntimeConfiguration after startup, and CRI implementations should | ||||
| 	//     avoid updating them without a full node reboot. | ||||
| 	RuntimeConfig(in *runtimeapi.RuntimeConfigRequest, opts ...grpc.CallOption) (*runtimeapi.RuntimeConfigResponse, error) | ||||
| } | ||||
|  | ||||
| // ImageManagerService interface should be implemented by a container image | ||||
|   | ||||
| @@ -51,11 +51,13 @@ import ( | ||||
| 	"google.golang.org/grpc" | ||||
| 	"google.golang.org/grpc/credentials/insecure" | ||||
| 	runtime "k8s.io/cri-api/pkg/apis/runtime/v1" | ||||
| 	"k8s.io/klog/v2" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| 	timeout                    = 1 * time.Minute | ||||
| 	k8sNamespace               = constants.K8sContainerdNamespace | ||||
| 	defaultCgroupSystemdParent = "/containerd-test.slice" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| @@ -208,6 +210,13 @@ func WithPodLabels(kvs map[string]string) PodSandboxOpts { | ||||
|  | ||||
| // PodSandboxConfig generates a pod sandbox config for test. | ||||
| func PodSandboxConfig(name, ns string, opts ...PodSandboxOpts) *runtime.PodSandboxConfig { | ||||
| 	var cgroupParent string | ||||
| 	runtimeConfig, err := runtimeService.RuntimeConfig(&runtime.RuntimeConfigRequest{}) | ||||
| 	if err != nil { | ||||
| 		klog.Errorf("runtime service call RuntimeConfig error %s", err.Error()) | ||||
| 	} else if runtimeConfig.GetLinux().GetCgroupDriver() == runtime.CgroupDriver_SYSTEMD { | ||||
| 		cgroupParent = defaultCgroupSystemdParent | ||||
| 	} | ||||
| 	config := &runtime.PodSandboxConfig{ | ||||
| 		Metadata: &runtime.PodSandboxMetadata{ | ||||
| 			Name: name, | ||||
| @@ -216,7 +225,9 @@ func PodSandboxConfig(name, ns string, opts ...PodSandboxOpts) *runtime.PodSandb | ||||
| 			Uid:       util.GenerateID(), | ||||
| 			Namespace: Randomize(ns), | ||||
| 		}, | ||||
| 		Linux:       &runtime.LinuxPodSandboxConfig{}, | ||||
| 		Linux: &runtime.LinuxPodSandboxConfig{ | ||||
| 			CgroupParent: cgroupParent, | ||||
| 		}, | ||||
| 		Annotations: make(map[string]string), | ||||
| 		Labels:      make(map[string]string), | ||||
| 	} | ||||
|   | ||||
| @@ -536,6 +536,15 @@ func (r *RuntimeService) Status(opts ...grpc.CallOption) (*runtimeapi.RuntimeSta | ||||
| 	return resp.Status, nil | ||||
| } | ||||
|  | ||||
| // RuntimeConfig returns the CgroupDriver of the runtime. | ||||
| func (r *RuntimeService) RuntimeConfig(in *runtimeapi.RuntimeConfigRequest, opts ...grpc.CallOption) (*runtimeapi.RuntimeConfigResponse, error) { | ||||
| 	klog.V(10).Infof("[RuntimeService] RuntimeConfig (timeout=%v)", r.timeout) | ||||
| 	ctx, cancel := getContextWithTimeout(r.timeout) | ||||
| 	defer cancel() | ||||
| 	runtimeConfig, err := r.runtimeClient.RuntimeConfig(ctx, in) | ||||
| 	return runtimeConfig, err | ||||
| } | ||||
|  | ||||
| // ContainerStats returns the stats of the container. | ||||
| func (r *RuntimeService) ContainerStats(containerID string, opts ...grpc.CallOption) (*runtimeapi.ContainerStats, error) { | ||||
| 	klog.V(10).Infof("[RuntimeService] ContainerStats (containerID=%v, timeout=%v)", containerID, r.timeout) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 lengrongfu
					lengrongfu