Skip to content
Permalink
Browse files

Merge pull request #3797 from kinvolk/iaguis/created-at

api: add CreatedAt to v1.Pod
  • Loading branch information...
iaguis committed Sep 20, 2017
2 parents 5e83d91 + bc2d912 commit 0051bc12716379bd00f4626df27e20d8a155c5ef
Showing with 23 additions and 0 deletions.
  1. +2 −0 api/v1/json.go
  2. +13 −0 lib/pod.go
  3. +8 −0 tests/rkt_tests.go
@@ -77,6 +77,8 @@ type (
AppNames []string `json:"app_names,omitempty"`
// Apps holds current information about each app.
Apps []*App `json:"apps,omitempty"`
// The creation time of the pod.
CreatedAt *int64 `json:"created_at,omitempty"`
// The start time of the pod.
StartedAt *int64 `json:"started_at,omitempty"`
// UserAnnotations are the pod user annotations.
@@ -15,6 +15,8 @@
package rkt

import (
"errors"

"github.com/rkt/rkt/api/v1"
pkgPod "github.com/rkt/rkt/pkg/pod"
)
@@ -37,6 +39,17 @@ func NewPodFromInternalPod(p *pkgPod.Pod) (*v1.Pod, error) {
pod.StartedAt = &startedAt
}

creationTime, err := p.CreationTime()
if err != nil {
return nil, err
}

createdAt := creationTime.Unix()
if creationTime.IsZero() || createdAt <= 0 {
return nil, errors.New("invalid creation time")
}
pod.CreatedAt = &createdAt

if !p.PodManifestAvailable() {
return pod, nil
}
@@ -673,6 +673,14 @@ func parsePodInfoOutput(t *testing.T, result string, p *podInfo) {
}
}
}

if p.state == "" {
t.Fatalf("Unexpected empty state for pod")
}

if p.createdAt <= 0 {
t.Fatalf("Unexpected createdAt <= 0 for pod")
}
}

func getPodDir(t *testing.T, ctx *testutils.RktRunCtx, podID string) string {

0 comments on commit 0051bc1

Please sign in to comment.
You can’t perform that action at this time.