Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

Commit

Permalink
list: ip of non running pod is added to the json output
Browse files Browse the repository at this point in the history
  • Loading branch information
poonai committed Nov 19, 2017
1 parent ebb97a6 commit f0e735f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/pod.go
Expand Up @@ -16,13 +16,30 @@ package rkt

import (
"errors"
"fmt"
"os"

"github.com/hashicorp/errwrap"
"github.com/rkt/rkt/api/v1"
"github.com/rkt/rkt/networking/netinfo"
pkgPod "github.com/rkt/rkt/pkg/pod"
)

// NewPodFromInternalPod converts *pkgPod.Pod to *Pod
func NewPodFromInternalPod(p *pkgPod.Pod) (*v1.Pod, error) {

if p.IsExited() {
cfd, err := p.Fd()
if err != nil {
return nil, errwrap.Wrap(fmt.Errorf("error acquiring pod %v dir fd", p.UUID), err)
}
p.Nets, err = netinfo.LoadAt(cfd)
// ENOENT is ok -- assume running with --net=host
if err != nil && !os.IsNotExist(err) {
return nil, errwrap.Wrap(fmt.Errorf("error opening pod %v netinfo", p.UUID), err)
}
}

pod := &v1.Pod{
UUID: p.UUID.String(),
State: p.State(),
Expand Down
5 changes: 5 additions & 0 deletions pkg/pod/pods.go
Expand Up @@ -1200,6 +1200,11 @@ func (p *Pod) IsFinished() bool {
return p.isExited || p.isAbortedPrepare || p.isGarbage || p.isGone
}

// isExited returns true if the pod is in exited state
func (p *Pod) IsExited() bool {
return p.isExited
}

// AppExitCode returns the app's exit code.
// It returns an error if the exit code file doesn't exit or the content of the file is invalid.
func (p *Pod) AppExitCode(appName string) (int, error) {
Expand Down

0 comments on commit f0e735f

Please sign in to comment.