server: Remove Image Config hack

Now that the image package has fixes to support docker images v2s1,
we can remove our buildOCIProcessARgs() hack for empty image configs
and simplify this routine.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Samuel Ortiz 2017-04-04 12:00:58 +02:00 committed by Antonio Murdaca
parent a0071de607
commit c89cc876d2
No known key found for this signature in database
GPG key ID: B2BEAD150DE936B9

View file

@ -71,23 +71,7 @@ func buildOCIProcessArgs(containerKubeConfig *pb.ContainerConfig, imageOCIConfig
kubeArgs := containerKubeConfig.Args
if imageOCIConfig == nil {
// HACK We should error out here, not being able to get an Image config is fatal.
// When https://github.com/kubernetes-incubator/cri-o/issues/395 is fixed
// we'll remove that one and return an error here.
if containerKubeConfig.Metadata != nil {
logrus.Errorf("empty image config for %s", containerKubeConfig.Metadata.Name)
// HACK until https://github.com/kubernetes-incubator/cri-o/issues/395 is fixed.
// If the container is kubeadm's dummy, imageOCIConfig is nil, and both
// kubeCommands and kubeArgs are empty. So we set processArgs to /pause as the
// dummy container is just a pause one.
// (See https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/master/templates.go)
if containerKubeConfig.Metadata.Name == "dummy" {
return []string{podInfraCommand}, nil
}
} else {
logrus.Errorf("empty image config for %s", containerKubeConfig.Image.Image)
}
return nil, fmt.Errorf("empty image config for %s", containerKubeConfig.Image.Image)
}
// We got an OCI Image configuration.
@ -98,22 +82,15 @@ func buildOCIProcessArgs(containerKubeConfig *pb.ContainerConfig, imageOCIConfig
// The kubelet command slice is prioritized.
processEntryPoint = kubeCommands
} else {
// Here the kubelet command slice is empty.
if imageOCIConfig != nil {
// If the OCI image config has an ENTRYPOINT we
// use it as our process command.
// Otherwise we use the CMD slice if it's not
// empty.
if imageOCIConfig.Config.Entrypoint != nil {
processEntryPoint = imageOCIConfig.Config.Entrypoint
} else if imageOCIConfig.Config.Cmd != nil {
processEntryPoint = imageOCIConfig.Config.Cmd
}
} else {
// We neither have a kubelet command not an image OCI config.
// Missing an image OCI config will no longer be supported after
// https://github.com/kubernetes-incubator/cri-o/issues/395 is fixed.
processEntryPoint = []string{"/bin/sh", "-c"}
// Here the kubelet command slice is empty but
// we know that our OCI Image configuration is not empty.
// If the OCI image config has an ENTRYPOINT we use it as
// our process command.
// Otherwise we use the CMD slice if it's not empty.
if imageOCIConfig.Config.Entrypoint != nil {
processEntryPoint = imageOCIConfig.Config.Entrypoint
} else if imageOCIConfig.Config.Cmd != nil {
processEntryPoint = imageOCIConfig.Config.Cmd
}
}
@ -135,16 +112,9 @@ func buildOCIProcessArgs(containerKubeConfig *pb.ContainerConfig, imageOCIConfig
// we use the CMD slice as the process arguments.
// Otherwise, we already picked CMD as our process
// command and we must not add the CMD slice twice.
if imageOCIConfig != nil {
if imageOCIConfig.Config.Entrypoint != nil {
processCmd = imageOCIConfig.Config.Cmd
} else {
processCmd = []string{}
}
if imageOCIConfig.Config.Entrypoint != nil {
processCmd = imageOCIConfig.Config.Cmd
} else {
// Missing an image OCI config will no longer
// be supported after https://github.com/kubernetes-incubator/cri-o/issues/395
// is fixed.
processCmd = []string{}
}
}