Reject duplicate init container names and report them under initContainers - #16696
arpitjain099 wants to merge 1 commit into
Conversation
…iners Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
|
Welcome @arpitjain099! It looks like this is your first PR to knative/serving 🎉 |
|
Hi @arpitjain099. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: arpitjain099 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 |
Fixes #
Proposed Changes
validateInitContainersseedsallNamesfrom the regular containers and never adds the init container names it walks past, so two init containers sharing a name are accepted.validateContainershas theelse { allNames.Insert(...) }that makes the same check work for regular containers. Issue Container names are not validated for duplicates #12260 said in its first line that this affects init containers too; PR Fix container name collision #12374 fixed the init-vs-regular half and tested that half only.validateInitContainersuseViaFieldIndex("containers", i)and the one caller does not wrap inViaField("initContainers"), so an init container fault comes back ascontainers[0].lifecycleorcontainers[0].securityContext, pointing the user at a different container than the one at fault.initContainers[0]along with the fix, and there is a new case for two init containers with the same name.The new case fails on main with
want "duplicate container name \"same\": initContainers[1].name", got "".go test ./pkg/apis/serving/...passes with the change.Release Note