Order ContainerStatuses the same as spec.Containers#7866
Order ContainerStatuses the same as spec.Containers#7866knative-prow-robot merged 10 commits intoknative:masterfrom
Conversation
knative-prow-robot
left a comment
There was a problem hiding this comment.
@taragu: 0 warnings.
Details
In response to this:
/lint
Fixes #7658
Proposed Changes
- Order ContainerStatuses so it has the same order as spec.Containers
Release Note
Order ContainerStatuses so it has the same order as spec.Containers
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.
|
/cc @dprotaso |
pkg/reconciler/revision/revision.go
Outdated
| for _, container := range rev.Spec.Containers { | ||
| containerIndexMap := map[string]int{} | ||
| for i, container := range rev.Spec.Containers { | ||
| containerIndexMap[container.Name] = i |
There was a problem hiding this comment.
one possible approach: since Go allows concurrently writing to an array from multiple goroutines as long as each individual element is only accessed from one, could we directly store to rev.Status.ContainerStatus[i] = .. in this loop (obviously making sure to do i := i and pre-create the array with the right size)?
That way we can lose this map, the channel stuff and the second loop - and any errors could be returned normally via the digestGrp.Wait().
pkg/reconciler/revision/revision.go
Outdated
| image: container.Image, | ||
| digestError: err, | ||
| } | ||
| rev.Status.MarkContainerHealthyFalse(v1.ReasonContainerMissing, |
There was a problem hiding this comment.
think this is racey unfortunately cos we can fail in parallel, probably need to do this after the loop
There was a problem hiding this comment.
That was my suggestion to @savitaashture in the other PR to just use sync.Once, though won't help with return.
There was a problem hiding this comment.
cant we just do something like
err := digestGrp.Wait();
if err != nil {
rev.Status.MarkContainerHealthyFalse(v1.ReasonContainerMissing, err)
}
return err
?
There was a problem hiding this comment.
now that we're filling everything in line, probably no reason why not.
There was a problem hiding this comment.
We can't do this because the Mark function takes a container image too. We'd need a special error type to do that.
There was a problem hiding this comment.
Yah, that (special error type) is what I was suggesting in #7866 (comment). Though sync.Once would work too if necc.
pkg/reconciler/revision/revision.go
Outdated
| v1.RevisionContainerMissingMessage( | ||
| container.Image, err.Error())) | ||
| return err | ||
| failedContainerImage = container.Image |
There was a problem hiding this comment.
this still races I think (there's still only one failedContainerImage potentially written by multiple goroutines), but I think we could just build and return an error containing the v1.RevisionContainerMissingMessage which we can unwrap at the bottom.
|
/retest |
pkg/reconciler/revision/revision.go
Outdated
| image: container.Image, | ||
| digestError: err, | ||
| } | ||
| return fmt.Errorf(v1.RevisionContainerMissingMessage(container.Image, err.Error())) |
There was a problem hiding this comment.
| return fmt.Errorf(v1.RevisionContainerMissingMessage(container.Image, err.Error())) | |
| return errors.New(v1.RevisionContainerMissingMessage(container.Image, err.Error())) |
Order ContainerStatuses so it has the same order as spec.Containers
1f66322 to
19ffa32
Compare
pkg/reconciler/revision/revision.go
Outdated
| }) | ||
| if err := digestGrp.Wait(); err != nil { | ||
| rev.Status.MarkContainerHealthyFalse(v1.ReasonContainerMissing, err.Error()) | ||
| rev.Status.ContainerStatuses = make([]v1.ContainerStatuses, 0) |
There was a problem hiding this comment.
why do we need to do this?
There was a problem hiding this comment.
The TestContainerErrorMsg e2e test was failing because if we don't clear this out, we will try to create image cache so the config will fail with a different message
There was a problem hiding this comment.
- why not nil?
- you can do this differently by using local variable for the list and only assigning it if
err != nil.
|
The following is the coverage report on the affected files.
|
|
/lgtm |
|
/approve |
|
/retest |
|
The following jobs failed:
Failed non-flaky tests preventing automatic retry of pull-knative-serving-integration-tests: |
markusthoemmes
left a comment
There was a problem hiding this comment.
Very nice refactoring! Thanks!
/lgtm
/approve
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dprotaso, markusthoemmes, taragu The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest |
1 similar comment
|
/retest |
/lint
Fixes #7658
Proposed Changes
Release Note