[WIP] PoC for multicontainer support#6739
[WIP] PoC for multicontainer support#6739savitaashture wants to merge 7 commits intoknative:masterfrom
Conversation
knative-prow-robot
left a comment
There was a problem hiding this comment.
@savitaashture: 0 warnings.
Details
In response to this:
Note:
PR has just code changes adding integration test is in progress in order to make sure changes works as expectedProposed Changes
- Adding support of multiple containers for single Knative service
Design Doc: https://docs.google.com/document/d/1XjIRnOGaq9UGllkZgYXQHuTQmhbECNAOk6TT6RNfJMw/edit?ts=5e25d093#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.
| if rev.Status.ImageDigests == nil { | ||
| rev.Status.ImageDigests = make(map[string]string) | ||
| } | ||
| rev.Status.ImageDigests[rev.Spec.Containers[i].Name] = digest |
There was a problem hiding this comment.
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.
|
|
||
| //ValidateMultiContainerPorts validates port when specified multiple containers | ||
| func ValidateMultiContainerPorts(containers []corev1.Container) *apis.FieldError { | ||
| cPort := []int32{} |
There was a problem hiding this comment.
You don't use the port number. Just use a count.
| var errs *apis.FieldError | ||
| for i := range containers { | ||
| for j := range containers[i].Ports { | ||
| cPort = append(cPort, containers[i].Ports[j].ContainerPort) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Handled port validation for both single and multi container
Thank you
| 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. |
| // 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. |
There was a problem hiding this comment.
We should put all images in this map -- not just the non-serving images.
There was a problem hiding this comment.
So do you mean
Whether if its single container or multiple container we need to fill ImageDigests and ImageDigest for backward compatibility
ex:
-
Single container
ImageDigest:digestValue
ImageDigests:
containerName:digestValue -
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) | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
It doesn't require named containers, does it? Aren't we inferring names from the indices? @savitaashture
There was a problem hiding this comment.
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
markusthoemmes
left a comment
There was a problem hiding this comment.
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!
| @@ -71,7 +71,13 @@ func (rs *RevisionSpec) GetContainer() *corev1.Container { | |||
| if rs.DeprecatedContainer != nil { | |||
There was a problem hiding this comment.
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()?
There was a problem hiding this comment.
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
| if rev.Status.ImageDigest != "" { | ||
| servingContainer.Image = rev.Status.ImageDigest | ||
| } | ||
| containers = appendContainer(containers, servingContainer) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Shouldn't userLifecycle be set just for the serving container?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I agree, all containers should "hang" until the PreStop hook finishes successfully.
|
Prow is complaining that |
Thank you @skaslev update PR by running |
40d0d8a to
98363b0
Compare
|
@savitaashture: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. |
|
The following jobs failed:
Failed non-flaky tests preventing automatic retry of pull-knative-serving-unit-tests: and 13 more. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: savitaashture The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
mattmoor
left a comment
There was a problem hiding this comment.
Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)
5ab7de6 to
e55cd76
Compare
e55cd76 to
2f91fb9
Compare
|
The following is the coverage report on the affected files.
|
|
@savitaashture: PR needs rebase. DetailsInstructions 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. |
|
@savitaashture this one is now vastly outdated? Does it serve an purpose anymore at this point? |
|
@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 |
|
@xvzf Savita is working on it, but in smaller self-contained PRs. The first of them already landed. |
|
@savitaashture if you need assistance just ping me :) |
Hi @xvzf Sure thank you |
|
Closing as per chat. |
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
Design Doc: https://docs.google.com/document/d/1XjIRnOGaq9UGllkZgYXQHuTQmhbECNAOk6TT6RNfJMw/edit?ts=5e25d093#
Release Note