Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #3857 from sch00lb0y/ipshow
list: add ip of non-running pods to status output
- Loading branch information
Showing
with
22 additions
and
2 deletions.
-
+6
−1
pkg/pod/pods.go
-
+1
−0
rkt/api_service.go
-
+1
−1
rkt/status.go
-
+14
−0
tests/rkt_list_test.go
|
@@ -269,7 +269,7 @@ func getPod(dataDir string, uuid *types.UUID) (*Pod, error) { |
|
|
|
|
|
p.FileLock = l |
|
|
|
|
|
if p.isRunning() { |
|
|
if p.isRunning() || p.isExit() { |
|
|
cfd, err := p.Fd() |
|
|
if err != nil { |
|
|
return nil, errwrap.Wrap(fmt.Errorf("error acquiring pod %v dir fd", uuid), err) |
|
@@ -1199,6 +1199,11 @@ func (p *Pod) IsFinished() bool { |
|
|
return p.isExited || p.isAbortedPrepare || p.isGarbage || p.isGone |
|
|
} |
|
|
|
|
|
// isExit returns true if the pod is in exited states |
|
|
func (p *Pod) isExit() 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) { |
|
|
|
@@ -537,6 +537,7 @@ func fillPodDetails(store *imagestore.Store, p *pkgPod.Pod, v1pod *v1alpha.Pod) |
|
|
v1pod.State = v1alpha.PodState_POD_STATE_DELETING |
|
|
case pkgPod.Exited: |
|
|
v1pod.State = v1alpha.PodState_POD_STATE_EXITED |
|
|
v1pod.Networks = getNetworks(p) |
|
|
case pkgPod.Garbage, pkgPod.ExitedGarbage: |
|
|
v1pod.State = v1alpha.PodState_POD_STATE_GARBAGE |
|
|
default: |
|
|
|
@@ -212,7 +212,7 @@ func printStatus(p *pkgPod.Pod) error { |
|
|
stdout.Printf("started=%s", startedStr) |
|
|
} |
|
|
|
|
|
if state == pkgPod.Running { |
|
|
if state == pkgPod.Running || state == pkgPod.Exited { |
|
|
stdout.Printf("networks=%s", fmtNets(p.Nets)) |
|
|
} |
|
|
|
|
|
|
@@ -57,6 +57,14 @@ func TestRktList(t *testing.T) { |
|
|
// Get hash |
|
|
imageID := fmt.Sprintf("sha512-%s", imgID.hash[:12]) |
|
|
|
|
|
cmd = fmt.Sprintf("%s --insecure-options=image run-prepared %s", ctx.Cmd(), podUuid) |
|
|
nobodyUid, _ := testutils.GetUnprivilegedUidGid() |
|
|
_, status := runRkt(t, cmd, nobodyUid, 0) |
|
|
if status != 0 { |
|
|
panic(fmt.Errorf("expected exit status code 0, got %d", status)) |
|
|
} |
|
|
podInfo := getPodInfo(t, ctx, podUuid) |
|
|
ipv4 := podInfo.networks["default"].ipv4 |
|
|
// Define tests |
|
|
tests := []struct { |
|
|
cmd string |
|
@@ -99,6 +107,12 @@ func TestRktList(t *testing.T) { |
|
|
true, |
|
|
imageID, |
|
|
}, |
|
|
// Test that ip is in json output |
|
|
{ |
|
|
"list --format=json", |
|
|
true, |
|
|
ipv4, |
|
|
}, |
|
|
} |
|
|
|
|
|
// Run tests |
|
|