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

api: add CreatedAt to v1.Pod
This commit is contained in:
Iago López Galeiras
2017-09-20 15:58:50 +02:00
committed by GitHub
3 changed files with 23 additions and 0 deletions

View File

@@ -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.

View File

@@ -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
}

View File

@@ -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 {