Skip to content

[WIP] PoC for multicontainer support#6739

Closed
savitaashture wants to merge 7 commits intoknative:masterfrom
savitaashture:wippoc
Closed

[WIP] PoC for multicontainer support#6739
savitaashture wants to merge 7 commits intoknative:masterfrom
savitaashture:wippoc

Conversation

@savitaashture
Copy link
Copy Markdown
Contributor

Fixes #5822 #3384

Note:
PR has just code changes adding integration test is in progress in order to make sure changes works as expected

Proposed Changes

Release Note

None

@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 5, 2020
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Feb 5, 2020
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 5, 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 #5822 #3384

Note:
PR has just code changes adding integration test is in progress in order to make sure changes works as expected

Proposed Changes

Release Note

None

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 Feb 5, 2020
Comment thread pkg/reconciler/revision/revision.go Outdated
if rev.Status.ImageDigests == nil {
rev.Status.ImageDigests = make(map[string]string)
}
rev.Status.ImageDigests[rev.Spec.Containers[i].Name] = digest
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 wonder if we should make this "image-as-passed -> digest" rather than "containerName -> digest". That'd even deduplicate things on the degenerate case of having one image used multiple times. We should probably also only resolve those once to not have a race if you've juuuust pushed an update as we've been resolving and to guarantee the same version.

Comment thread pkg/reconciler/revision/resources/imagecache.go Outdated
Comment thread pkg/apis/serving/v1/revision_defaults.go Outdated
Comment thread pkg/apis/serving/k8s_validation.go Outdated
Comment thread pkg/apis/serving/k8s_validation.go Outdated
Comment thread pkg/apis/serving/k8s_validation.go Outdated
Comment thread pkg/apis/serving/k8s_validation.go Outdated

//ValidateMultiContainerPorts validates port when specified multiple containers
func ValidateMultiContainerPorts(containers []corev1.Container) *apis.FieldError {
cPort := []int32{}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You don't use the port number. Just use a count.

Comment thread pkg/apis/serving/k8s_validation.go Outdated
var errs *apis.FieldError
for i := range containers {
for j := range containers[i].Ports {
cPort = append(cPort, containers[i].Ports[j].ContainerPort)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This seems to be doing two checks here:

  • Multiple ports on a single container
  • Multiple containers with a ports specified

However, validateContainerPorts already validates if multiple ports are specified per container and does so with a different error message.

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.

Handled port validation for both single and multi container

Thank you

Comment thread pkg/apis/serving/k8s_validation.go Outdated
Comment thread pkg/apis/serving/v1/revision_types.go Outdated
ImageDigest string `json:"imageDigest,omitempty"`
// ImageDigests holds the resolved digest for the image specified
// within .Spec.Container.Image. The digest is resolved during the creation
// of Revision. This will be filled if there are multiple container specified.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We should fill this in all cases.

Comment thread pkg/apis/serving/v1/revision_types.go Outdated
// ImageDigests holds the resolved digest for the image specified
// within .Spec.Container.Image. The digest is resolved during the creation
// of Revision. This will be filled if there are multiple container specified.
// ImageDigests holds the digest for all the .Spec.Container.Image which are non serving.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We should put all images in this map -- not just the non-serving images.

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.

So do you mean

Whether if its single container or multiple container we need to fill ImageDigests and ImageDigest for backward compatibility
ex:

  1. Single container
    ImageDigest: digestValue
    ImageDigests:
    containerName: digestValue

  2. Multiple container (consider 2 container)
    ImageDigest: digestValue
    ImageDigests:
    servingContainerName: digestValue
    nonServingContainerName: digestValue

func validate(container corev1.Container, volumes sets.String) *apis.FieldError {
if equality.Semantic.DeepEqual(container, corev1.Container{}) {
return apis.ErrMissingField(apis.CurrentField)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Related to this change, but tangential: we should expand the list of reservedContainerNames in case we need to add more system sidecars later. Perhaps something with a prefix of knative-serving-system-*?

This is potentially breaking, but given that this requires named containers means that the risk of breaking only goes up after this lands.

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.

It doesn't require named containers, does it? Aren't we inferring names from the indices? @savitaashture

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 user don't provide name for sidecar container we inferring names from the indices
https://github.com/knative/serving/pull/6739/files#diff-daca68b8123c709e8127c6c834c5c023R56

Comment thread pkg/reconciler/revision/revision.go Outdated
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.

Mostly code hygiene stuff, but that makes me go in and question code flow the most so I figured I might as well leave comments about it. Very nice looking so far!

Comment thread pkg/reconciler/revision/revision.go Outdated
Comment thread pkg/reconciler/revision/resources/deploy.go Outdated
Comment thread pkg/reconciler/revision/resources/deploy.go Outdated
Comment thread pkg/reconciler/revision/resources/deploy.go Outdated
Comment thread pkg/reconciler/revision/revision.go Outdated
Comment thread pkg/reconciler/revision/reconcile_resources.go Outdated
@@ -71,7 +71,13 @@ func (rs *RevisionSpec) GetContainer() *corev1.Container {
if rs.DeprecatedContainer != nil {
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.

Have we had a look through all of our code to triage if this is okay for all places this helper is used? On a cursory look it seems okay but maybe we should rename to GetServingContainer()?

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 also thought initially but dint change it because its used in lot of places
But if that is okay to change then i will rename it

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.

@dgerd might have an opinion.

Comment thread pkg/apis/serving/k8s_validation.go Outdated
Comment thread pkg/apis/serving/k8s_validation.go Outdated
Comment thread pkg/apis/serving/k8s_validation.go Outdated
Comment thread pkg/apis/serving/k8s_validation.go Outdated
Comment thread pkg/apis/serving/k8s_validation.go
if rev.Status.ImageDigest != "" {
servingContainer.Image = rev.Status.ImageDigest
}
containers = appendContainer(containers, servingContainer)
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.

Calling appendContainer() here results in O(n^2) time complexity. Probably not an issue since the number of containers are expected to be small.

Can container name uniqueness be done during validation and skipped here?
Alternatively can we use a map here instead of iterating over containers checking for name collisions?

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.

name check validation not added to check name uniqueness
rather validation added because container name will be unique so it will be easy to decide whether containers need to be appended or not
I mean the logic of appendContainer is to append the containers only if there is change in name.

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 is that even needed here? Haven't we made sure there are no name-clashes in validation? If not, we should add that there.

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.

Modified thank you 👍

return podSpec, nil
func makeContainer(container *corev1.Container, rev *v1alpha1.Revision) corev1.Container {
container.VolumeMounts = append(container.VolumeMounts, varLogVolumeMount)
container.Lifecycle = userLifecycle
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.

Shouldn't userLifecycle be set just for the serving container?

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.

The purpose of userLifecycle is to run PreStop hook and which helps to block the user-container from exiting before the queue-proxy is ready
So IMO it should be applicable for all the containers?
Because even serving containers serve the request but serving container may depends on sidecar container and in any case if the sidecar exit then there will be failure in functionality.

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, all containers should "hang" until the PreStop hook finishes successfully.

@skaslev
Copy link
Copy Markdown
Contributor

skaslev commented Feb 7, 2020

Prow is complaining that ./hack/update-codegen.sh hasn't been run after making changes to the apis (the new ImageDigests field in RevisionStatus).

@savitaashture
Copy link
Copy Markdown
Contributor Author

Prow is complaining that ./hack/update-codegen.sh hasn't been run after making changes to the apis (the new ImageDigests field in RevisionStatus).

Thank you @skaslev update PR by running ./hack/update-codegen.sh

@knative-prow-robot
Copy link
Copy Markdown
Contributor

knative-prow-robot commented Feb 26, 2020

@savitaashture: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-knative-serving-build-tests-go114 c396b9b link /test pull-knative-serving-build-tests-go114
pull-knative-serving-integration-tests-go114 c396b9b link /test pull-knative-serving-integration-tests-go114

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

@knative-test-reporter-robot
Copy link
Copy Markdown

The following jobs failed:

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

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

pkg/apis/serving.TestPodSpecValidation
pkg/apis/serving.TestPodSpecValidation/with_volume_name_collision
pkg/apis/serving.TestPodSpecValidation/too_many_containers
pkg/apis/serving.TestPodSpecValidation/extra_field
pkg/apis/serving.TestContainerValidation
pkg/apis/serving.TestContainerValidation/has_more_than_one_ports_with_valid_names
pkg/apis/serving.TestContainerValidation/has_more_than_one_unnamed_port
pkg/apis/serving/v1.TestRevisionDefaulting

and 13 more.

@knative-prow-robot knative-prow-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. area/test-and-release It flags unit/e2e/conformance/perf test issues for product features and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 29, 2020
@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: savitaashture
To complete the pull request process, please assign mattmoor
You can assign the PR to them by writing /assign @mattmoor in a comment when ready.

The full list of commands accepted by this bot can be found 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

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/reconciler/revision/table_test.go
Comment thread pkg/reconciler/revision/table_test.go
@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/apis/serving/k8s_validation.go 99.1% 99.2% 0.1
pkg/apis/serving/v1alpha1/revision_lifecycle.go 89.3% 88.5% -0.9
pkg/reconciler/revision/reconcile_resources.go 92.8% 92.7% -0.1
pkg/reconciler/revision/revision.go 93.8% 94.6% 0.8

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 16, 2020
@knative-prow-robot
Copy link
Copy Markdown
Contributor

@savitaashture: PR needs rebase.

Details

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.

@markusthoemmes
Copy link
Copy Markdown
Contributor

@savitaashture this one is now vastly outdated? Does it serve an purpose anymore at this point?

@xvzf
Copy link
Copy Markdown

xvzf commented Apr 27, 2020

@markusthoemmes This is actually kind of important, if the creator of this PR doesn't respond and it is on the timeline, I'd start working on it

@markusthoemmes
Copy link
Copy Markdown
Contributor

@xvzf Savita is working on it, but in smaller self-contained PRs. The first of them already landed.

@xvzf
Copy link
Copy Markdown

xvzf commented Apr 27, 2020

@savitaashture if you need assistance just ping me :)

@savitaashture
Copy link
Copy Markdown
Contributor Author

@savitaashture if you need assistance just ping me :)

Hi @xvzf Sure thank you
Yes as @markusthoemmes said we divided a feature into small sub tasks which are covered as part of these PRs
#7167
#7245
#7373
#7661
#7866
#7801

@markusthoemmes
Copy link
Copy Markdown
Contributor

Closing as per chat.

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

Labels

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. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Sidecar Processes