Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion pkg/apis/serving/v1/revision_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,32 @@ type RevisionStatus struct {
// +optional
LogURL string `json:"logUrl,omitempty"`

// ImageDigest holds the resolved digest for the image specified
// DeprecatedImageDigest holds the resolved digest for the image specified
// within .Spec.Container.Image. The digest is resolved during the creation
Comment thread
dprotaso marked this conversation as resolved.
// of Revision. This field holds the digest value regardless of whether
// a tag or digest was originally specified in the Container object. It
// may be empty if the image comes from a registry listed to skip resolution.
// If multiple containers specified then DeprecatedImageDigest holds the digest
// for serving container.
// DEPRECATED Use ImageDigests instead.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is that "ImageDigests" field ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// TODO(savitaashture) Remove deprecatedImageDigest.
// ref https://kubernetes.io/docs/reference/using-api/deprecation-policy for deprecation.
// +optional
DeprecatedImageDigest string `json:"imageDigest,omitempty"`

// ContainerStatuses is a slice of images present in .Spec.Container[*].Image
// to their respective digests and their container name.
// The digests are resolved during the creation of Revision.
// ContainerStatuses holds the container name and image digests
// for both serving and non serving containers.
// ref: http://bit.ly/image-digests
// +optional
ContainerStatuses []ContainerStatuses `json:"containerStatuses,omitempty"`
}

// ContainerStatuses holds the information of container name and image digest value
type ContainerStatuses struct {
Name string `json:"name,omitempty"`
ImageDigest string `json:"imageDigest,omitempty"`
}

Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/serving/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions pkg/apis/serving/v1alpha1/revision_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ func (source *RevisionStatus) ConvertTo(ctx context.Context, sink *v1.RevisionSt
source.Status.ConvertTo(ctx, &sink.Status, v1.IsRevisionCondition)
sink.ServiceName = source.ServiceName
sink.LogURL = source.LogURL
sink.DeprecatedImageDigest = source.DeprecatedImageDigest
sink.ContainerStatuses = make([]v1.ContainerStatuses, len(source.ContainerStatuses))
for i := range source.ContainerStatuses {
source.ContainerStatuses[i].ConvertTo(ctx, &sink.ContainerStatuses[i])
}
}

// ConvertTo helps implement apis.Convertible
func (source *ContainerStatuses) ConvertTo(ctx context.Context, sink *v1.ContainerStatuses) {
sink.Name = source.Name
sink.ImageDigest = source.ImageDigest
}

Expand Down Expand Up @@ -111,5 +121,15 @@ func (sink *RevisionStatus) ConvertFrom(ctx context.Context, source v1.RevisionS
source.Status.ConvertTo(ctx, &sink.Status, v1.IsRevisionCondition)
sink.ServiceName = source.ServiceName
sink.LogURL = source.LogURL
sink.DeprecatedImageDigest = source.DeprecatedImageDigest
sink.ContainerStatuses = make([]ContainerStatuses, len(source.ContainerStatuses))
for i := range sink.ContainerStatuses {
sink.ContainerStatuses[i].ConvertFrom(ctx, &source.ContainerStatuses[i])
}
}

// ConvertFrom helps implement apis.Convertible
func (sink *ContainerStatuses) ConvertFrom(ctx context.Context, source *v1.ContainerStatuses) {
sink.Name = source.Name
sink.ImageDigest = source.ImageDigest
}
10 changes: 6 additions & 4 deletions pkg/apis/serving/v1alpha1/revision_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ func TestRevisionConversion(t *testing.T) {
Status: "True",
}},
},
ServiceName: "foo-bar",
LogURL: "http://logger.io",
ServiceName: "foo-bar",
LogURL: "http://logger.io",
ContainerStatuses: []ContainerStatuses{},
},
},
}, {
Expand Down Expand Up @@ -232,8 +233,9 @@ func TestRevisionConversionForMultiContainer(t *testing.T) {
Status: "True",
}},
},
ServiceName: "foo-bar",
LogURL: "http://logger.io",
ServiceName: "foo-bar",
LogURL: "http://logger.io",
ContainerStatuses: []ContainerStatuses{},
},
}
beta := &v1beta1.Revision{}
Expand Down
22 changes: 21 additions & 1 deletion pkg/apis/serving/v1alpha1/revision_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,32 @@ type RevisionStatus struct {
// +optional
LogURL string `json:"logUrl,omitempty"`

// ImageDigest holds the resolved digest for the image specified
// DeprecatedImageDigest holds the resolved digest for the image specified
// within .Spec.Container.Image. The digest is resolved during the creation
// of Revision. This field holds the digest value regardless of whether
// a tag or digest was originally specified in the Container object. It
// may be empty if the image comes from a registry listed to skip resolution.
// If multiple containers specified then DeprecatedImageDigest holds the digest
// for serving container.
// DEPRECATED Use ImageDigests instead.
// TODO(savitaashture) Remove deprecatedImageDigest.
// ref https://kubernetes.io/docs/reference/using-api/deprecation-policy for deprecation.
// +optional
DeprecatedImageDigest string `json:"imageDigest,omitempty"`
Comment thread
savitaashture marked this conversation as resolved.

// ContainerStatuses is a slice of images present in .Spec.Container[*].Image
// to their respective digests and their container name.
// The digests are resolved during the creation of Revision.
// ContainerStatuses holds the container name and image digests
// for both serving and non serving containers.
// ref: http://bit.ly/image-digests
// +optional
ContainerStatuses []ContainerStatuses `json:"containerStatuses,omitempty"`
}

// ContainerStatuses holds the information of container name and image digest value
type ContainerStatuses struct {
Name string `json:"name,omitempty"`
ImageDigest string `json:"imageDigest,omitempty"`
}

Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/serving/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 33 additions & 29 deletions pkg/reconciler/revision/queueing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,37 @@ const (
testQueueImage = "queueImage"
)

func testRevision() *v1.Revision {
func getPodSpec() corev1.PodSpec {
return corev1.PodSpec{
// corev1.Container has a lot of setting. We try to pass many
// of them here to verify that we pass through the settings to
// derived objects.
Containers: []corev1.Container{{
Image: "gcr.io/repo/image",
Command: []string{"echo"},
Args: []string{"hello", "world"},
WorkingDir: "/tmp",
Env: []corev1.EnvVar{{
Name: "EDITOR",
Value: "emacs",
}},
LivenessProbe: &corev1.Probe{
TimeoutSeconds: 42,
},
ReadinessProbe: &corev1.Probe{
Handler: corev1.Handler{
HTTPGet: &corev1.HTTPGetAction{
Path: "health",
},
},
TimeoutSeconds: 43,
},
TerminationMessagePath: "/dev/null",
}},
}
}

func testRevision(podSpec corev1.PodSpec) *v1.Revision {
rev := &v1.Revision{
ObjectMeta: metav1.ObjectMeta{
SelfLink: "/apis/serving/v1/namespaces/test/revisions/test-rev",
Expand All @@ -77,33 +107,7 @@ func testRevision() *v1.Revision {
UID: "test-rev-uid",
},
Spec: v1.RevisionSpec{
PodSpec: corev1.PodSpec{
// corev1.Container has a lot of setting. We try to pass many
// of them here to verify that we pass through the settings to
// derived objects.
Containers: []corev1.Container{{
Image: "gcr.io/repo/image",
Command: []string{"echo"},
Args: []string{"hello", "world"},
WorkingDir: "/tmp",
Env: []corev1.EnvVar{{
Name: "EDITOR",
Value: "emacs",
}},
LivenessProbe: &corev1.Probe{
TimeoutSeconds: 42,
},
ReadinessProbe: &corev1.Probe{
Handler: corev1.Handler{
HTTPGet: &corev1.HTTPGetAction{
Path: "health",
},
},
TimeoutSeconds: 43,
},
TerminationMessagePath: "/dev/null",
}},
},
PodSpec: podSpec,
TimeoutSeconds: ptr.Int64(60),
},
}
Expand Down Expand Up @@ -230,7 +234,7 @@ func TestNewRevisionCallsSyncHandler(t *testing.T) {

eg := errgroup.Group{}

rev := testRevision()
rev := testRevision(getPodSpec())
servingClient := fakeservingclient.Get(ctx)

h := NewHooks()
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/revision/resources/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ func makePodSpec(rev *v1.Revision, loggingConfig *logging.Config, tracingConfig
userContainer.TTY = false

// Prefer imageDigest from revision if available
if rev.Status.ImageDigest != "" {
userContainer.Image = rev.Status.ImageDigest
if rev.Status.DeprecatedImageDigest != "" {
userContainer.Image = rev.Status.DeprecatedImageDigest
}

if userContainer.TerminationMessagePolicy == "" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/revision/resources/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ func TestMakePodSpec(t *testing.T) {
withContainerConcurrency(1),
func(revision *v1.Revision) {
revision.Status = v1.RevisionStatus{
ImageDigest: "busybox@sha256:deadbeef",
DeprecatedImageDigest: "busybox@sha256:deadbeef",
}
container(revision.Spec.GetContainer(),
withTCPReadinessProbe(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/revision/resources/imagecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

// MakeImageCache makes an caching.Image resources from a revision.
func MakeImageCache(rev *v1.Revision) *caching.Image {
image := rev.Status.ImageDigest
image := rev.Status.DeprecatedImageDigest
Comment thread
savitaashture marked this conversation as resolved.
if image == "" {
image = rev.Spec.GetContainer().Image
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/revision/resources/imagecache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestMakeImageCache(t *testing.T) {
},
},
Status: v1.RevisionStatus{
ImageDigest: "busybox@sha256:deadbeef",
DeprecatedImageDigest: "busybox@sha256:deadbeef",
},
},
want: &caching.Image{
Expand Down
Loading