Skip to content

Add ImageDigests for multi container support#7373

Merged
knative-prow-robot merged 13 commits intoknative:masterfrom
savitaashture:imageDigest
Apr 20, 2020
Merged

Add ImageDigests for multi container support#7373
knative-prow-robot merged 13 commits intoknative:masterfrom
savitaashture:imageDigest

Conversation

@savitaashture
Copy link
Copy Markdown
Contributor

Fixes:
Parts of #5822 #3384

Proposed Changes

  • Added new field ImageDigests for multicontainer
  • Modified reconcileDigest to support multiple containers

Pending:

Need to update new field ImageDigests to doc after the PR merge

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Mar 24, 2020
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 24, 2020
Copy link
Copy Markdown
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@savitaashture: 0 warnings.

Details

In response to this:

Fixes:
Parts of #5822 #3384

Proposed Changes

  • Added new field ImageDigests for multicontainer
  • Modified reconcileDigest to support multiple containers

Pending:

Need to update new field ImageDigests to doc after the PR merge

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@knative-prow-robot knative-prow-robot added the area/API API objects and controllers label Mar 24, 2020
Comment thread pkg/apis/serving/v1/revision_types.go Outdated
@@ -136,6 +136,13 @@ type RevisionStatus struct {
// may be empty if the image comes from a registry listed to skip resolution.
// +optional
ImageDigest string `json:"imageDigest,omitempty"`
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.

Mark this as deprecated, add a todo to remove in 2 releases?

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.

We don't remove stuff from the API, I think?

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.

🤷‍♂ we did before

Copy link
Copy Markdown
Contributor Author

@savitaashture savitaashture Mar 25, 2020

Choose a reason for hiding this comment

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

While discussing during POC we decided like we will keep existing one to not to break the functionality and along with ImageDigest we will add new field called ImageDigests to support multiple containers

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.

I am not suggesting we remove it now. But in N knative releases (N=2, I think) this stops being of interest. So we if we rename it deprecatedImageDigest and a todo to remove it in future (0.16 I guess) it should be alright.

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.

Please note that this also forces clients that link against the API types to be updated. This immediately breaks any code (not only in two versions). E.g. see the kn client failure in https://storage.googleapis.com/knative-prow/pr-logs/pull/knative_client/801/pull-knative-client-unit-tests/1255135293493743616/build-log.txt:

Running tests with 'go test -v  -race -mod=vendor ./... '
# knative.dev/client/pkg/serving
pkg/serving/config_changes.go:305:24: baseRevision.Status.ImageDigest undefined (type "knative.dev/serving/pkg/apis/serving/v1".RevisionStatus has no field or method ImageDigest)
pkg/serving/config_changes.go:306:51: baseRevision.Status.ImageDigest undefined (type "knative.dev/serving/pkg/apis/serving/v1".RevisionStatus has no field or method ImageDigest)
# knative.dev/client/pkg/serving [knative.dev/client/pkg/serving.test]
pkg/serving/config_changes.go:305:24: baseRevision.Status.ImageDigest undefined (type "knative.dev/serving/pkg/apis/serving/v1".RevisionStatus has no field or method ImageDigest)
pkg/serving/config_changes.go:306:51: baseRevision.Status.ImageDigest undefined (type "knative.dev/serving/pkg/apis/serving/v1".RevisionStatus has no field or method ImageDigest)
pkg/serving/config_changes_test.go:128:17: revision.Status.ImageDigest undefined (type "knative.dev/serving/pkg/apis/serving/v1".RevisionStatus has no field or method ImageDigest)

This raises the question of what "deprecation" should mean. Only on the API (yaml) level or also on the code level ? Currently renaming fields to a Deprecated prefix is just a sledge-hammer for any client using a code dependency (also, this is not necessarily needed, or ?) and is, despite the naming, not a "deprecation" but a breaking change.

Comment thread pkg/apis/serving/v1/revision_types.go Outdated
// +optional
ImageDigest string `json:"imageDigest,omitempty"`

// ImageDigests holds the resolved digest for the image specified
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.

The comment needs pluralization.

return rev
}

func testRevisionForMultipleContainer() *v1.Revision {
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.

can we call regular testRevision here and just annotate podspec?
remove duplicate boilerplate.

Comment thread pkg/reconciler/revision/revision.go Outdated
// revision status should not contains imageDigests field in these scenario
// 1. If flag is disabled
// 2. If flag enabled but applied revision has single container
if cfgs.Defaults.EnableMultiContainer && len(rev.Spec.Containers) > 1 {
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.

Why wouldn't we switch to the map basically always? Even if the MC is disabled. The map will just have a single entry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes if MC is disabled map will have just one entry.

But as per the current behavior the revision status don't have ImageDigests field
In that case if we don't add that particular condition even if MC disabled revision will have ImageDigests field .

So in order to keep consistency with current behavior of revision status added this logic

Let me know allowing ImageDigests field even if MC disabled is okay then i will update code

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.

Yeah, I think it is totally fine to have this map populated as source of truth always going forward.

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.

I agree, let's add it always.

Comment thread pkg/reconciler/revision/revision_test.go Outdated
Comment thread pkg/reconciler/revision/revision_test.go Outdated
Comment thread pkg/reconciler/revision/revision_test.go Outdated
@knative-prow-robot knative-prow-robot added the area/test-and-release It flags unit/e2e/conformance/perf test issues for product features label Mar 25, 2020
Copy link
Copy Markdown
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

Copy link
Copy Markdown
Contributor

@vagababov vagababov left a comment

Choose a reason for hiding this comment

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

/lgtm

Comment thread pkg/reconciler/revision/revision.go Outdated
rev.Status.ImageDigests = make(map[string]string, len(rev.Spec.Containers))
}
for _, container := range rev.Spec.Containers {
digest, err := c.resolver.Resolve(container.Image,
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.

Do we want to do this asyncronously?
I remember @markusthoemmes having problem with each taking 10s?

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.

na, my issues was entirely separate. This is fine usually. I suppose we could run them in parallel though?

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.

yeah, that's what I meant in go routines.

Copy link
Copy Markdown
Contributor Author

@savitaashture savitaashture Mar 27, 2020

Choose a reason for hiding this comment

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

Modified
Thank you @markusthoemmes @vagababov

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 25, 2020
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 27, 2020
Comment thread pkg/reconciler/revision/revision.go Outdated
Comment thread pkg/reconciler/revision/revision.go Outdated
Comment thread pkg/reconciler/revision/revision.go Outdated
Comment thread pkg/reconciler/revision/revision.go Outdated
Comment thread pkg/reconciler/revision/revision_test.go Outdated
Comment thread pkg/reconciler/revision/revision.go Outdated
}
close(digests)
for v := range digests {
if len(rev.Spec.Containers) == 1 || v.isServingContainer {
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.

I could see len==1 case be specialcased, but
🤷‍♂

Copy link
Copy Markdown
Contributor Author

@savitaashture savitaashture Mar 28, 2020

Choose a reason for hiding this comment

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

Sorry i think i don't understand your comment fully
Do you mean len(rev.Spec.Containers) == 1 should be handled as special case?
or do you mean we should handled same way like v.isServingContainer ?

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.

In theory, since we don't need to do any of the parallel stuff. But in practice probably doesn't matter.

@savitaashture
Copy link
Copy Markdown
Contributor Author

/retest

Copy link
Copy Markdown
Contributor

@markusthoemmes markusthoemmes left a comment

Choose a reason for hiding this comment

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

One more comment on the upgrade path

Comment thread pkg/reconciler/revision/revision.go Outdated
Comment thread pkg/reconciler/revision/revision.go Outdated
@savitaashture
Copy link
Copy Markdown
Contributor Author

savitaashture commented Apr 6, 2020

Thank you @markusthoemmes @vagababov
Addressed all the review comments and ready for another round of review
Please take a look at it

Comment thread pkg/reconciler/revision/revision.go
Copy link
Copy Markdown
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

Copy link
Copy Markdown
Member

@dprotaso dprotaso left a comment

Choose a reason for hiding this comment

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

It's probably worth talking about the ContainerStatus as the WG meeting/slack to get alignment.

Comment thread pkg/apis/serving/v1/revision_types.go Outdated
Comment thread pkg/apis/serving/v1/revision_types.go Outdated
Comment thread pkg/apis/serving/v1alpha1/revision_types.go
Comment thread pkg/reconciler/revision/revision.go Outdated
Comment thread pkg/reconciler/revision/revision.go Outdated
Comment thread pkg/reconciler/revision/revision.go Outdated
if v.digestError != nil {
rev.Status.MarkContainerHealthyFalse(v1.ReasonContainerMissing,
v1.RevisionContainerMissingMessage(
v.image, v.digestError.Error()))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Now I wonder if individual digest resolution errors should appear in each ContainerStatus

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would think so
because instead of giving single failure information for more than one images it would be better to give failure error respective to that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let's leave it for a separate PR/issue

Copy link
Copy Markdown
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

Comment thread pkg/apis/serving/v1alpha1/revision_conversion.go Outdated
Comment thread pkg/apis/serving/v1alpha1/revision_conversion.go Outdated
@savitaashture
Copy link
Copy Markdown
Contributor Author

@dprotaso @mattmoor @vagababov @markusthoemmes PR is ready for another round of review
Please take a look
Thank you

Copy link
Copy Markdown
Contributor

@vagababov vagababov left a comment

Choose a reason for hiding this comment

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

It's mostly good by me as before.

Comment thread pkg/apis/serving/v1alpha1/revision_types.go Outdated
@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on the affected files.
Say /test pull-knative-serving-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/revision/revision.go 93.9% 98.1% 4.2

Copy link
Copy Markdown
Member

@dprotaso dprotaso left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve
/hold

holding because of the nit - if you want to do it in a separate PR feel free to drop it

if v.isServingContainer {
rev.Status.DeprecatedImageDigest = v.digestValue
}
rev.Status.ContainerStatuses = append(rev.Status.ContainerStatuses, v1.ContainerStatuses{
Copy link
Copy Markdown
Member

@dprotaso dprotaso Apr 20, 2020

Choose a reason for hiding this comment

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

nit: can we have the order of the containers in the status be the same as the spec?

Copy link
Copy Markdown
Contributor Author

@savitaashture savitaashture Apr 20, 2020

Choose a reason for hiding this comment

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

Hi @dprotaso I feel it will be little bit messy because we don't have any comparison element between spec and status in order to have the ordering of the status same like spec

Copy link
Copy Markdown
Member

@dprotaso dprotaso Apr 20, 2020

Choose a reason for hiding this comment

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

I was thinking of using the container name - so the first container in the spec would be the first container in the status etc.

If you want to do it in another PR or create a good first issue (for someone else) feel free to unblock this PR with an /unhold

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay I have created an issue to handle that in another PR
#7658

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 20, 2020
@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 20, 2020
@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprotaso, savitaashture

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 20, 2020
@savitaashture
Copy link
Copy Markdown
Contributor Author

/unhold

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 20, 2020
@knative-test-reporter-robot
Copy link
Copy Markdown

The following jobs failed:

Test name Triggers Retries
pull-knative-serving-integration-tests pull-knative-serving-integration-tests 1/3
pull-knative-serving-unit-tests 0/3

Failed non-flaky tests preventing automatic retry of pull-knative-serving-unit-tests:

pkg/reconciler/autoscaling/kpa.TestControllerSynchronizesCreatesAndDeletes

@savitaashture
Copy link
Copy Markdown
Contributor Author

/test pull-knative-serving-unit-tests

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/API API objects and controllers area/test-and-release It flags unit/e2e/conformance/perf test issues for product features cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants