Merge pull request #801 from runcom/not-exist-exit

server: container_remove: ignore not existent exit file
This commit is contained in:
Mrunal Patel 2017-08-29 07:58:33 -07:00 committed by GitHub
commit 662e80492c
5 changed files with 20 additions and 5 deletions

View file

@ -153,7 +153,7 @@ func main() {
app := cli.NewApp()
app.Name = "crio"
app.Usage = "crio server"
app.Version = "1.0.0-alpha.0"
app.Version = "1.0.0-beta.0"
app.Metadata = map[string]interface{}{
"config": server.DefaultConfig(),
}

View file

@ -67,7 +67,7 @@ func main() {
app := cli.NewApp()
app.Name = "crioctl"
app.Usage = "client for crio"
app.Version = "1.0.0-alpha.0"
app.Version = "1.0.0-beta.0"
app.Commands = []cli.Command{
podSandboxCommand,

View file

@ -17,6 +17,7 @@ import (
rspec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
kwait "k8s.io/apimachinery/pkg/util/wait"
)
const (
@ -591,7 +592,22 @@ func (r *Runtime) UpdateStatus(c *Container) error {
if c.state.Status == ContainerStateStopped {
exitFilePath := filepath.Join(r.containerExitsDir, c.id)
fi, err := os.Stat(exitFilePath)
var fi os.FileInfo
err = kwait.ExponentialBackoff(
kwait.Backoff{
Duration: 500 * time.Millisecond,
Factor: 1.2,
Steps: 6,
},
func() (bool, error) {
var err error
fi, err = os.Stat(exitFilePath)
if err != nil {
// wait longer
return false, nil
}
return true, nil
})
if err != nil {
logrus.Warnf("failed to find container exit file: %v", err)
c.state.ExitCode = -1

View file

@ -34,7 +34,7 @@ func (s *Server) RemoveContainer(ctx context.Context, req *pb.RemoveContainerReq
return nil, fmt.Errorf("failed to delete container %s: %v", c.ID(), err)
}
if err := os.Remove(filepath.Join(s.config.ContainerExitsDir, c.ID())); err != nil {
if err := os.Remove(filepath.Join(s.config.ContainerExitsDir, c.ID())); err != nil && !os.IsNotExist(err) {
return nil, fmt.Errorf("failed to remove container exit file %s: %v", c.ID(), err)
}

View file

@ -48,7 +48,6 @@ func (s *Server) ContainerStatus(ctx context.Context, req *pb.ContainerStatusReq
// If we defaulted to exit code -1 earlier then we attempt to
// get the exit code from the exit file again.
// TODO: We could wait in UpdateStatus for exit file to show up.
if cState.ExitCode == -1 {
err := s.Runtime().UpdateStatus(c)
if err != nil {