Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rkt: Append tag to the returned image name. #23205

Merged
merged 1 commit into from
Mar 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkg/kubelet/container/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ type Container struct {
// The name of the container, which should be the same as specified by
// api.Container.
Name string
// The image name of the container.
// The image name of the container, this also includes the tag of the image,
// the expected form is "NAME:TAG".
Image string
// Hash of the container, used for comparison. Optional for containers
// not managed by kubelet.
Expand Down Expand Up @@ -261,7 +262,8 @@ type ContainerStatus struct {
FinishedAt time.Time
// Exit code of the container.
ExitCode int
// Name of the image.
// Name of the image, this also includes the tag of the image,
// the expected form is "NAME:TAG".
Image string
// ID of the image.
ImageID string
Expand Down
15 changes: 8 additions & 7 deletions pkg/kubelet/rkt/rkt.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ const (
authDir = "auth.d"
dockerAuthTemplate = `{"rktKind":"dockerAuth","rktVersion":"v1","registries":[%q],"credentials":{"user":%q,"password":%q}}`

defaultImageTag = "latest"
defaultRktAPIServiceAddr = "localhost:15441"
defaultNetworkName = "rkt.kubernetes.io"

Expand Down Expand Up @@ -982,9 +981,10 @@ func (r *Runtime) convertRktPod(rktpod *rktapi.Pod) (*kubecontainer.Pod, error)
}

kubepod.Containers = append(kubepod.Containers, &kubecontainer.Container{
ID: buildContainerID(&containerID{rktpod.Id, app.Name}),
Name: app.Name,
Image: app.Image.Name,
ID: buildContainerID(&containerID{rktpod.Id, app.Name}),
Name: app.Name,
// By default, the version returned by rkt API service will be "latest" if not specified.
Image: fmt.Sprintf("%s:%s", app.Image.Name, app.Image.Version),
Hash: containerHash,
Created: podCreated,
State: appStateToContainerState(app.State),
Expand Down Expand Up @@ -1459,9 +1459,10 @@ func populateContainerStatus(pod rktapi.Pod, app rktapi.App, runtimeApp appcsche
CreatedAt: creationTime,
StartedAt: creationTime,
ExitCode: int(app.ExitCode),
Image: app.Image.Name,
ImageID: "rkt://" + app.Image.Id, // TODO(yifan): Add the prefix only in api.PodStatus.
Hash: hashNum,
// By default, the version returned by rkt API service will be "latest" if not specified.
Image: fmt.Sprintf("%s:%s", app.Image.Name, app.Image.Version),
ImageID: "rkt://" + app.Image.Id, // TODO(yifan): Add the prefix only in api.PodStatus.
Hash: hashNum,
// TODO(yifan): Note that now all apps share the same restart count, this might
// change once apps don't share the same lifecycle.
// See https://github.com/appc/spec/pull/547.
Expand Down
33 changes: 17 additions & 16 deletions pkg/kubelet/rkt/rkt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ func makeRktPod(rktPodState rktapi.PodState,
Name: appNames[i],
State: appStates[i],
Image: &rktapi.Image{
Id: imgIDs[i],
Name: imgNames[i],
Id: imgIDs[i],
Name: imgNames[i],
Version: "latest",
Manifest: mustMarshalImageManifest(
&appcschema.ImageManifest{
ACKind: appcschema.ImageManifestKind,
Expand Down Expand Up @@ -372,15 +373,15 @@ func TestGetPods(t *testing.T) {
{
ID: kubecontainer.BuildContainerID("rkt", "uuid-4002:app-1"),
Name: "app-1",
Image: "img-name-1",
Image: "img-name-1:latest",
Hash: 1001,
Created: 100000,
State: "running",
},
{
ID: kubecontainer.BuildContainerID("rkt", "uuid-4002:app-2"),
Name: "app-2",
Image: "img-name-2",
Image: "img-name-2:latest",
Hash: 1002,
Created: 100000,
State: "exited",
Expand Down Expand Up @@ -432,15 +433,15 @@ func TestGetPods(t *testing.T) {
{
ID: kubecontainer.BuildContainerID("rkt", "uuid-4002:app-1"),
Name: "app-1",
Image: "img-name-1",
Image: "img-name-1:latest",
Hash: 1001,
Created: 100000,
State: "running",
},
{
ID: kubecontainer.BuildContainerID("rkt", "uuid-4002:app-2"),
Name: "app-2",
Image: "img-name-2",
Image: "img-name-2:latest",
Hash: 1002,
Created: 100000,
State: "exited",
Expand All @@ -455,31 +456,31 @@ func TestGetPods(t *testing.T) {
{
ID: kubecontainer.BuildContainerID("rkt", "uuid-4003:app-11"),
Name: "app-11",
Image: "img-name-11",
Image: "img-name-11:latest",
Hash: 10011,
Created: 90000,
State: "exited",
},
{
ID: kubecontainer.BuildContainerID("rkt", "uuid-4003:app-22"),
Name: "app-22",
Image: "img-name-22",
Image: "img-name-22:latest",
Hash: 10022,
Created: 90000,
State: "exited",
},
{
ID: kubecontainer.BuildContainerID("rkt", "uuid-4004:app-11"),
Name: "app-11",
Image: "img-name-11",
Image: "img-name-11:latest",
Hash: 10011,
Created: 100000,
State: "running",
},
{
ID: kubecontainer.BuildContainerID("rkt", "uuid-4004:app-22"),
Name: "app-22",
Image: "img-name-22",
Image: "img-name-22:latest",
Hash: 10022,
Created: 100000,
State: "running",
Expand Down Expand Up @@ -591,7 +592,7 @@ func TestGetPodStatus(t *testing.T) {
State: kubecontainer.ContainerStateRunning,
CreatedAt: time.Unix(100000, 0),
StartedAt: time.Unix(100000, 0),
Image: "img-name-1",
Image: "img-name-1:latest",
ImageID: "rkt://img-id-1",
Hash: 1001,
RestartCount: 7,
Expand All @@ -602,7 +603,7 @@ func TestGetPodStatus(t *testing.T) {
State: kubecontainer.ContainerStateExited,
CreatedAt: time.Unix(100000, 0),
StartedAt: time.Unix(100000, 0),
Image: "img-name-2",
Image: "img-name-2:latest",
ImageID: "rkt://img-id-2",
Hash: 1002,
RestartCount: 7,
Expand Down Expand Up @@ -648,7 +649,7 @@ func TestGetPodStatus(t *testing.T) {
State: kubecontainer.ContainerStateRunning,
CreatedAt: time.Unix(90000, 0),
StartedAt: time.Unix(90000, 0),
Image: "img-name-1",
Image: "img-name-1:latest",
ImageID: "rkt://img-id-1",
Hash: 1001,
RestartCount: 7,
Expand All @@ -659,7 +660,7 @@ func TestGetPodStatus(t *testing.T) {
State: kubecontainer.ContainerStateExited,
CreatedAt: time.Unix(90000, 0),
StartedAt: time.Unix(90000, 0),
Image: "img-name-2",
Image: "img-name-2:latest",
ImageID: "rkt://img-id-2",
Hash: 1002,
RestartCount: 7,
Expand All @@ -671,7 +672,7 @@ func TestGetPodStatus(t *testing.T) {
State: kubecontainer.ContainerStateRunning,
CreatedAt: time.Unix(100000, 0),
StartedAt: time.Unix(100000, 0),
Image: "img-name-1",
Image: "img-name-1:latest",
ImageID: "rkt://img-id-1",
Hash: 1001,
RestartCount: 10,
Expand All @@ -682,7 +683,7 @@ func TestGetPodStatus(t *testing.T) {
State: kubecontainer.ContainerStateExited,
CreatedAt: time.Unix(100000, 0),
StartedAt: time.Unix(100000, 0),
Image: "img-name-2",
Image: "img-name-2:latest",
ImageID: "rkt://img-id-2",
Hash: 1002,
RestartCount: 10,
Expand Down