Commit 9f0dc7fe authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #32744 from yujuhong/fix_shim

Automatic merge from submit-queue Clarify the "version" requirement in CRI and fix various bugs in dockershim This fixes #32741
parents 50eb1206 77aa4cd0
...@@ -239,9 +239,11 @@ type VersionResponse struct { ...@@ -239,9 +239,11 @@ type VersionResponse struct {
Version *string `protobuf:"bytes,1,opt,name=version" json:"version,omitempty"` Version *string `protobuf:"bytes,1,opt,name=version" json:"version,omitempty"`
// The name of the container runtime. // The name of the container runtime.
RuntimeName *string `protobuf:"bytes,2,opt,name=runtime_name,json=runtimeName" json:"runtime_name,omitempty"` RuntimeName *string `protobuf:"bytes,2,opt,name=runtime_name,json=runtimeName" json:"runtime_name,omitempty"`
// The version of the container runtime. // The version of the container runtime. The string should be
// semver-compatible.
RuntimeVersion *string `protobuf:"bytes,3,opt,name=runtime_version,json=runtimeVersion" json:"runtime_version,omitempty"` RuntimeVersion *string `protobuf:"bytes,3,opt,name=runtime_version,json=runtimeVersion" json:"runtime_version,omitempty"`
// The API version of the container runtime. // The API version of the container runtime. The string should be
// semver-compatible.
RuntimeApiVersion *string `protobuf:"bytes,4,opt,name=runtime_api_version,json=runtimeApiVersion" json:"runtime_api_version,omitempty"` RuntimeApiVersion *string `protobuf:"bytes,4,opt,name=runtime_api_version,json=runtimeApiVersion" json:"runtime_api_version,omitempty"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
} }
......
...@@ -65,9 +65,11 @@ message VersionResponse { ...@@ -65,9 +65,11 @@ message VersionResponse {
optional string version = 1; optional string version = 1;
// The name of the container runtime. // The name of the container runtime.
optional string runtime_name = 2; optional string runtime_name = 2;
// The version of the container runtime. // The version of the container runtime. The string should be
// semver-compatible.
optional string runtime_version = 3; optional string runtime_version = 3;
// The API version of the container runtime. // The API version of the container runtime. The string should be
// semver-compatible.
optional string runtime_api_version = 4; optional string runtime_api_version = 4;
} }
......
...@@ -103,7 +103,6 @@ func (ds *dockerService) CreateContainer(podSandboxID string, config *runtimeApi ...@@ -103,7 +103,6 @@ func (ds *dockerService) CreateContainer(podSandboxID string, config *runtimeApi
Name: makeContainerName(sandboxConfig, config), Name: makeContainerName(sandboxConfig, config),
Config: &dockercontainer.Config{ Config: &dockercontainer.Config{
// TODO: set User. // TODO: set User.
Hostname: sandboxConfig.GetHostname(),
Entrypoint: dockerstrslice.StrSlice(config.GetCommand()), Entrypoint: dockerstrslice.StrSlice(config.GetCommand()),
Cmd: dockerstrslice.StrSlice(config.GetArgs()), Cmd: dockerstrslice.StrSlice(config.GetArgs()),
Env: generateEnvList(config.GetEnvs()), Env: generateEnvList(config.GetEnvs()),
......
...@@ -49,7 +49,7 @@ const ( ...@@ -49,7 +49,7 @@ const (
containerTypeLabelContainer = "container" containerTypeLabelContainer = "container"
) )
func NewDockerSevice(client dockertools.DockerInterface) DockerLegacyService { func NewDockerService(client dockertools.DockerInterface) DockerLegacyService {
return &dockerService{ return &dockerService{
client: dockertools.NewInstrumentedDockerInterface(client), client: dockertools.NewInstrumentedDockerInterface(client),
} }
...@@ -73,17 +73,20 @@ type dockerService struct { ...@@ -73,17 +73,20 @@ type dockerService struct {
} }
// Version returns the runtime name, runtime version and runtime API version // Version returns the runtime name, runtime version and runtime API version
func (ds *dockerService) Version(apiVersion string) (*runtimeApi.VersionResponse, error) { func (ds *dockerService) Version(_ string) (*runtimeApi.VersionResponse, error) {
v, err := ds.client.Version() v, err := ds.client.Version()
if err != nil { if err != nil {
return nil, fmt.Errorf("docker: failed to get docker version: %v", err) return nil, fmt.Errorf("docker: failed to get docker version: %v", err)
} }
runtimeAPIVersion := kubeAPIVersion runtimeAPIVersion := kubeAPIVersion
name := dockerRuntimeName name := dockerRuntimeName
// Docker API version (e.g., 1.23) is not semver compatible. Add a ".0"
// suffix to remedy this.
apiVersion := fmt.Sprintf("%s.0", v.APIVersion)
return &runtimeApi.VersionResponse{ return &runtimeApi.VersionResponse{
Version: &runtimeAPIVersion, Version: &runtimeAPIVersion,
RuntimeName: &name, RuntimeName: &name,
RuntimeVersion: &v.Version, RuntimeVersion: &v.Version,
RuntimeApiVersion: &v.APIVersion, RuntimeApiVersion: &apiVersion,
}, nil }, nil
} }
...@@ -161,15 +161,15 @@ func getNetworkNamespace(c *dockertypes.ContainerJSON) string { ...@@ -161,15 +161,15 @@ func getNetworkNamespace(c *dockertypes.ContainerJSON) string {
// dockerFilter wraps around dockerfilters.Args and provides methods to modify // dockerFilter wraps around dockerfilters.Args and provides methods to modify
// the filter easily. // the filter easily.
type dockerFilter struct { type dockerFilter struct {
f *dockerfilters.Args args *dockerfilters.Args
} }
func newDockerFilter(args *dockerfilters.Args) *dockerFilter { func newDockerFilter(args *dockerfilters.Args) *dockerFilter {
return &dockerFilter{f: args} return &dockerFilter{args: args}
} }
func (f *dockerFilter) Add(key, value string) { func (f *dockerFilter) Add(key, value string) {
f.Add(key, value) f.args.Add(key, value)
} }
func (f *dockerFilter) AddLabel(key, value string) { func (f *dockerFilter) AddLabel(key, value string) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment