Skip to content

Conversation

@kiashok
Copy link
Contributor

@kiashok kiashok commented Jul 6, 2022

This PR addresses windows images that are broken when created using the "shell form" entrypoint/cmd in Dockerfile. Associated bug - #5067
The approach taken to fix this bug is as discussed by @kevpar here - #6479 (comment)

Docker uses non-OCI field called ArgsEscaped to address how the image 'ENTRYPOINT' and 'CMD' are interpreted on windows. This PR adds support for ArgsEscaped in containerd without changes to the OCI spec and also adds changes to handle cases when image ENTRYPOINT and CMD can be overriden by 'Command' and 'Args' specified in the podspec.

The fix in this PR does the following:

  • Reads the ArgsEscaped value from the image got from docker without making OCI spec changes (In file image.go)
  • Image ENTRYPOINT and CMD fields can be overriden by the container 'Command' and 'Args' fields specified through the podspec. But the ArgsEscaped field should really only affect the behavior of the image values, and not the overall evaluation of args for the container. Therefore, we need to evaluate if the first arg in our list is coming from image entrypoint/cmd and only if it is coming from the image, we should we treat the first arg as already escaped. (in file spec.go spec_windows.go)

Regression tests have also been added to this PR.

@k8s-ci-robot
Copy link

Hi @kiashok. Thanks for your PR.

I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@kiashok kiashok marked this pull request as draft July 7, 2022 16:48
@jterry75
Copy link
Contributor

jterry75 commented Jul 7, 2022

I dont do any CRI plugin work anymore so I will defer to @kevpar / @dcantah here. But thank you for picking up this work. It would be nice to see CRI support for ArgsEscaped images working on Kube+CriContainerd

@kiashok kiashok marked this pull request as ready for review July 7, 2022 21:31
@kiashok kiashok changed the title Add ArgsEscaped support in upstream containerd Add ArgsEscaped support for CRI Jul 21, 2022
@kevpar kevpar self-assigned this Aug 3, 2022
@dcantah
Copy link
Member

dcantah commented Aug 19, 2022

I really think for full testing sanity we should host an image that is built with docker that would set ArgsEscaped, and then have a test in the CRI /integration suite that launches a container and verifies we're all good.

@dcantah
Copy link
Member

dcantah commented Aug 19, 2022

I think the Project Checks are failing because you're using github.com/pkg/errors in a spot here and it was removed as a direct dependency

@dcantah
Copy link
Member

dcantah commented Aug 19, 2022

PR description is great but please add some description to the commit message as well describing the need for this change and what it fixes

@dcantah dcantah self-assigned this Aug 19, 2022
@dcantah dcantah added this to the 1.7 milestone Aug 19, 2022
Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

Thank you! I see a lot of work here. IMO this change may best be done after the merge of opencontainers/image-spec#892 till then this could proto on a branch with that change merged, which would mean a lot less code necessary, wouldn't have to revert some of Maksym's recent changes that moved get spec to the client.. wouldn't need to unmarshal twice to get the extended (deprecated docker) field....

@dcantah
Copy link
Member

dcantah commented Aug 19, 2022

I think the reason was that PR had been stalled for awhile and wasn't sure if it'd be done in time for 1.7. Would it be undesirable to use the double unmarshal to get the ArgsEscaped field in the meantime until we have that in imagespec, and we can do a follow-up change?

For the reverting Maksym's changes bit, which part of this change was that?

@dcantah
Copy link
Member

dcantah commented Aug 24, 2022

@mikebrow pingaroo on the above. Question: given we don't vendor an exact tag of the spec here today already, am I right in assuming we could re-vendor image-spec from the latest in main once that change is merged? If it's highly preferred to wait for that to land we can try and drive that forward ASAP. If that doesn't seem to be making progress in time for 1.7, could we move forward with what's here for now and retrofit after?

@mikebrow
Copy link
Member

@mikebrow pingaroo on the above. Question: given we don't vendor an exact tag of the spec here today already, am I right in assuming we could re-vendor image-spec from the latest in main once that change is merged? If it's highly preferred to wait for that to land we can try and drive that forward ASAP. If that doesn't seem to be making progress in time for 1.7, could we move forward with what's here for now and retrofit after?

nod.. but let's track the OCI pr for a bit... esp. with the linux args escaped news...

@marosset
Copy link
Contributor

marosset commented Oct 5, 2022

opencontainers/image-spec#892 merged :)

Copy link
Contributor

@jterry75 jterry75 left a comment

Choose a reason for hiding this comment

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

Great start. Left some comments.

@kiashok kiashok closed this Nov 10, 2022
@kiashok kiashok reopened this Nov 10, 2022
@kiashok
Copy link
Contributor Author

kiashok commented Nov 23, 2022

Great start. Left some comments.

Hi @jterry75 , I addressed the comments. Could you please let me know if they look ok? Thanks a lot!

@dmcgowan dmcgowan added the status/needs-discussion Needs discussion and decision from maintainers label Nov 29, 2022
@kiashok
Copy link
Contributor Author

kiashok commented Jan 17, 2023

Hi @dcantah , would you be able to take a second look at the changes when you have some time please? Thanks!

@dcantah
Copy link
Member

dcantah commented Jan 17, 2023

@kiashok Yep! I'll try and get to this tomorrow evening

@kiashok
Copy link
Contributor Author

kiashok commented Jan 17, 2023

@kiashok Yep! I'll try and get to this tomorrow evening

Thanks Danny!

@dcantah
Copy link
Member

dcantah commented Jan 18, 2023

Today's lookin a little slammed.. 🫠 I'll definitely get to this sometime this week @kiashok (please ping if I don't)

@kiashok
Copy link
Contributor Author

kiashok commented Jan 18, 2023

Today's lookin a little slammed.. 🫠 I'll definitely get to this sometime this week @kiashok (please ping if I don't)

Sure Danny no worries, thanks a lot! :)

@dcantah
Copy link
Member

dcantah commented Jan 25, 2023

@kiashok I'll try and get a final pass sometime this week. Thanks for looking at the feedback!

@kiashok
Copy link
Contributor Author

kiashok commented Jan 26, 2023

@kiashok I'll try and get a final pass sometime this week. Thanks for looking at the feedback!

@kiashok I'll try and get a final pass sometime this week. Thanks for looking at the feedback!

Thanks a lot for looking into this @dcantah!
Addressed the lint errors hit in the second commit

This commit adds supports for the ArgsEscaped
value for the image got from the dockerfile.
It is used to evaluate and process the image
entrypoint/cmd and container entrypoint/cmd
options got from the podspec.

Signed-off-by: Kirtana Ashok <[email protected]>
@kiashok
Copy link
Contributor Author

kiashok commented Feb 9, 2023

@mxpv could you please take a look at the new changes and see if they look good?

Also, the CI failures seem to be unrelated to the change

@kiashok kiashok closed this by deleting the head repository Feb 23, 2023
@kiashok kiashok reopened this Feb 23, 2023
@dmcgowan dmcgowan removed this from the 1.7 milestone Mar 2, 2023
@kiashok
Copy link
Contributor Author

kiashok commented Mar 2, 2023

Looks like I accidentally deleted the fork that had the branch with the changes in this PR. Addressed the comments that @dmcgowan left this morning and wanted to submit new changes and realized this. Since am unable to update this PR with the new changes, I closed this PR and created a new one here - #8198. Apologies for this!

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

Labels

area/cri Container Runtime Interface (CRI) needs-ok-to-test status/needs-discussion Needs discussion and decision from maintainers

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.