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 kubeArgs := containerKubeConfig.Args
if imageOCIConfig == nil { if imageOCIConfig == nil {
// HACK We should error out here, not being able to get an Image config is fatal. return nil, fmt.Errorf("empty image config for %s", containerKubeConfig.Image.Image)
// 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)
}
} }
// We got an OCI Image configuration. // We got an OCI Image configuration.
@ -98,22 +82,15 @@ func buildOCIProcessArgs(containerKubeConfig *pb.ContainerConfig, imageOCIConfig
// The kubelet command slice is prioritized. // The kubelet command slice is prioritized.
processEntryPoint = kubeCommands processEntryPoint = kubeCommands
} else { } else {
// Here the kubelet command slice is empty. // Here the kubelet command slice is empty but
if imageOCIConfig != nil { // we know that our OCI Image configuration is not empty.
// If the OCI image config has an ENTRYPOINT we // If the OCI image config has an ENTRYPOINT we use it as
// use it as our process command. // our process command.
// Otherwise we use the CMD slice if it's not // Otherwise we use the CMD slice if it's not empty.
// empty. if imageOCIConfig.Config.Entrypoint != nil {
if imageOCIConfig.Config.Entrypoint != nil { processEntryPoint = imageOCIConfig.Config.Entrypoint
processEntryPoint = imageOCIConfig.Config.Entrypoint } else if imageOCIConfig.Config.Cmd != nil {
} else if imageOCIConfig.Config.Cmd != nil { processEntryPoint = imageOCIConfig.Config.Cmd
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"}
} }
} }
@ -135,16 +112,9 @@ func buildOCIProcessArgs(containerKubeConfig *pb.ContainerConfig, imageOCIConfig
// we use the CMD slice as the process arguments. // we use the CMD slice as the process arguments.
// Otherwise, we already picked CMD as our process // Otherwise, we already picked CMD as our process
// command and we must not add the CMD slice twice. // command and we must not add the CMD slice twice.
if imageOCIConfig != nil { if imageOCIConfig.Config.Entrypoint != nil {
if imageOCIConfig.Config.Entrypoint != nil { processCmd = imageOCIConfig.Config.Cmd
processCmd = imageOCIConfig.Config.Cmd
} else {
processCmd = []string{}
}
} else { } 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{} processCmd = []string{}
} }
} }