mirror of
https://github.com/rkt/rkt.git
synced 2026-03-13 09:40:21 +08:00
Merge pull request #3797 from kinvolk/iaguis/created-at
api: add CreatedAt to v1.Pod
This commit is contained in:
@@ -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.
|
||||
|
||||
13
lib/pod.go
13
lib/pod.go
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user