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
This commit is contained in:
Kubernetes Submit Queue
2016-09-15 08:50:59 -07:00
committed by GitHub
5 changed files with 17 additions and 11 deletions

View File

@@ -239,9 +239,11 @@ type VersionResponse struct {
Version *string `protobuf:"bytes,1,opt,name=version" json:"version,omitempty"`
// The name of the container runtime.
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"`
// 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"`
XXX_unrecognized []byte `json:"-"`
}

View File

@@ -65,9 +65,11 @@ message VersionResponse {
optional string version = 1;
// The name of the container runtime.
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;
// 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;
}

View File

@@ -103,7 +103,6 @@ func (ds *dockerService) CreateContainer(podSandboxID string, config *runtimeApi
Name: makeContainerName(sandboxConfig, config),
Config: &dockercontainer.Config{
// TODO: set User.
Hostname: sandboxConfig.GetHostname(),
Entrypoint: dockerstrslice.StrSlice(config.GetCommand()),
Cmd: dockerstrslice.StrSlice(config.GetArgs()),
Env: generateEnvList(config.GetEnvs()),

View File

@@ -49,7 +49,7 @@ const (
containerTypeLabelContainer = "container"
)
func NewDockerSevice(client dockertools.DockerInterface) DockerLegacyService {
func NewDockerService(client dockertools.DockerInterface) DockerLegacyService {
return &dockerService{
client: dockertools.NewInstrumentedDockerInterface(client),
}
@@ -73,17 +73,20 @@ type dockerService struct {
}
// 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()
if err != nil {
return nil, fmt.Errorf("docker: failed to get docker version: %v", err)
}
runtimeAPIVersion := kubeAPIVersion
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{
Version: &runtimeAPIVersion,
RuntimeName: &name,
RuntimeVersion: &v.Version,
RuntimeApiVersion: &v.APIVersion,
RuntimeApiVersion: &apiVersion,
}, nil
}

View File

@@ -161,15 +161,15 @@ func getNetworkNamespace(c *dockertypes.ContainerJSON) string {
// dockerFilter wraps around dockerfilters.Args and provides methods to modify
// the filter easily.
type dockerFilter struct {
f *dockerfilters.Args
args *dockerfilters.Args
}
func newDockerFilter(args *dockerfilters.Args) *dockerFilter {
return &dockerFilter{f: args}
return &dockerFilter{args: args}
}
func (f *dockerFilter) Add(key, value string) {
f.Add(key, value)
f.args.Add(key, value)
}
func (f *dockerFilter) AddLabel(key, value string) {