-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ko-built Windows images aren't pullable/runnable #361
Comments
I briefly hacked up ko to make
edit: the image I tested with is here: |
I can confirm similar results using relative paths, although I saw a slightly different error message:
Using the skopeo command line utility I was able to copy an entrypoint image created by ko from Docker Hub to a local directory on my computer. This made it possible to un-tar the image layers and inspect the directory contents. Under
I then created a simple image for comparison using this Dockerfile: FROM mcr.microsoft.com/windows/servercore:ltsc2019
COPY my-folder var/run/ko This resulted in two top level folders being created; |
Yeah, you can also explore it online here: https://explore.ggcr.dev/?image=gcr.io%2Fimjasonh%2Fghatest2-3b797f3433e868656fc12cc06198c02c%40sha256%3Af0631af760a78fea65ca3633e03bf568c451568bae7f894d250bf9df449df01e I don't understand how It's possible that |
I ran into this recently, maybe they know? https://github.com/buildpacks/imgutil/blob/5a2568dd25b62b6f9620d7d94cb1abf2ddbe0d76/layer/windows_baselayer.go |
Here is a comparison of a configuration file generated by Ko and one generated by Docker for reference: Ko generated config file{
"architecture": "amd64",
"author": "github.com/google/ko",
"created": "2021-04-09T20:34:41.3608362Z",
"history": [
{
"created": "2020-05-07T05:09:25.0463439Z",
"created_by": "Apply image 1809-RTM-amd64"
},
{
"created": "2021-04-09T20:34:41.3608362Z",
"created_by": "Install update ltsc2019-amd64"
},
{
"author": "ko",
"created": "0001-01-01T00:00:00Z",
"created_by": "ko publish ko://github.com/tektoncd/pipeline/cmd/entrypoint",
"comment": "kodata contents, at $KO_DATA_PATH"
},
{
"author": "ko",
"created": "0001-01-01T00:00:00Z",
"created_by": "ko publish ko://github.com/tektoncd/pipeline/cmd/entrypoint",
"comment": "go build output, at ko-app/entrypoint"
}
],
"os": "windows",
"rootfs": {
"type": "layers",
"diff_ids": [
"sha256:a7ba3db29ebb3a32e6a9c912d6ab5941bd981a0c39a420e6786c70a66babb80b",
"sha256:30275bef3136de22586acb46a3a28617738e9c2d0df13e546d6b2c3119ab269d",
"sha256:1cd897584015e8248109cfd98233c0d89302a68c3ec115538460210685ed810e",
"sha256:547733b18d0a2be0d9462ea75a5284e4326c8a623522e6525635786888ec76cf"
]
},
"config": {
"Cmd": [
"c:\\windows\\system32\\cmd.exe"
],
"Entrypoint": [
"ko-app/entrypoint"
],
"Env": [
"PATH=ko-app",
"KO_DATA_PATH=var/run/ko"
]
},
"os.version": "10.0.17763.1879"
} Docker generated config file{
"architecture": "amd64",
"config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"c:\\windows\\system32\\cmd.exe"
],
"Image": "sha256:152749f71f8fd6004056d15c7fd5791563072703171eb8dbd3e66b2ee67f8287",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": null
},
"container_config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"cmd",
"/S",
"/C",
"#(nop) COPY dir:77c5636325457486302b0915a625e3205113750c5aae8dac34bb9d2db932b573 in var\\run\\ko "
],
"Image": "sha256:152749f71f8fd6004056d15c7fd5791563072703171eb8dbd3e66b2ee67f8287",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": null
},
"created": "2021-05-11T03:18:43.9711165Z",
"docker_version": "20.10.4",
"history": [
{
"created": "2020-05-07T05:09:25.0463439Z",
"created_by": "Apply image 1809-RTM-amd64"
},
{
"created": "2021-04-09T20:34:41.3608362Z",
"created_by": "Install update ltsc2019-amd64"
},
{
"created": "2021-05-11T03:18:43.9711165Z",
"created_by": "cmd /S /C #(nop) COPY dir:77c5636325457486302b0915a625e3205113750c5aae8dac34bb9d2db932b573 in var\\run\\ko "
}
],
"os": "windows",
"os.version": "10.0.17763.1879",
"rootfs": {
"type": "layers",
"diff_ids": [
"sha256:a7ba3db29ebb3a32e6a9c912d6ab5941bd981a0c39a420e6786c70a66babb80b",
"sha256:30275bef3136de22586acb46a3a28617738e9c2d0df13e546d6b2c3119ab269d",
"sha256:e6cb1711b093584dcf7a549c63815f8d50cc866b753b0c825b388e378f8c714e"
]
}
} It seems the Docker generated config file has an additional This is just an observation and I'm not sure if |
If I move the binary from
(this is with edit: I've been hacking apart ko to try to successfully build a Windows container image, diff here: main...imjasonh:windows |
I've made a bit more progress (I think), latest code at main...imjasonh:windows With this change, the ko-built image is pullable at least, but still fails to run:
This image was built from that branch with:
This builds a |
Just came across this, you might find the information in microsoft/hcsshim#853 (which includes a bunch of information from Buildpacks too) and the implementation in microsoft/hcsshim#901 useful as a reference on Windows container image layout. |
Reported in Tekton's #windows Slack channel: https://tektoncd.slack.com/archives/C020SPF0B7Y/p1620277036006500 -- copied here for posterity and to aid future discussion.
tl;dr: Images that Ko builds for Windows don't appear to be pullable, possibly due to
KO_DATA_PATH
and the/var/run/ko
directory in the tar file.It sounds like we could benefit from some Windows CI at least, to ensure that Windows images built with
ko
are runnable. We could have a GitHub Actions Windows runner pull and run a ko-built image, or after we cut a release with #339 we could build and run ko within CI to detect breakages before merging pull requests.The specific issue might require us to have Windows-specific logic in gobuild.go, to change where kodata ends up in the image.
@aiden-deloryn
I have been doing some testing with a Windows node and have encountered a problem which prevents the entrypoint image from running (and as a result the TaskRun's pod won't initialise). Describing the pod reveals the following error under Events:
After inspecting the container image, I can see that the path
/var/run/ko
is injected into the image as an environment variable calledKO_DATA_PATH
. According to the Ko documentation this path is used to bundle static assets from akodata
sub-directory into the image'sKO_DATA_PATH
directory. I'm not sure why this extra path is being appended to the beginning -\\?\C:\ProgramData\docker\tmp\hcs523070999
.As this problem occurs when processing an image layer it can also be reproduced by running
docker pull <image>
, after building the Windows image withko publish ./cmd/entrypoint --platform=windows/amd64
. Note: for testing purposes, I'm using a Ko base image override ofgithub.com/tektoncd/pipeline/cmd/entrypoint: mcr.microsoft.com/windows/servercore:ltsc2019
I haven't used Ko previously so I'm not all that familiar with it. I'm also not sure if this is a Docker issue or a Ko issue. My Ko version is 0.8.2 and Windows Docker runtime version 20.10.4 (Mirantis). I can't inspect the image using Docker because I cannot pull it. It seems either Ko is producing an incorrect image layer, or Docker is interpreting/converting the path incorrectly. Is there any way I can troubleshoot Ko further to see what's going on?
@aiden-deloryn
Your suggestion does sound plausible to me. Perhaps a relative path could be the solution (as the error seems to suggest). Maybe just removing the root path separator would be enough? (i.e.
var/run/ko
)If we need a more specific location, I've found some directories in nanoserver (smallest image) which might be suitable:
C:\ProgramData\ >>> for application data that is not user-specific
C:\Windows\Temp\ >>> for temporary files
C:\Users\ContainerUser\ >>> user's home directory
C:\Users\ContainerUser\AppData\Local\ >>> user-specific application data
C:\Users\ContainerUser\AppData\Local\Temp\ >>> user's temp directory
@adamrehn:
Looking at the implementation of
tarAddDirectories()
, it looks like the intended file permissions for the kodata directory are world readable and executable, but not writable? If static data files don't need to be writable then C:\ProgramData\ko might be the ideal candidate, since the primary benefit of opting for a temporary or user-specific directory would be that the resulting files can be modified. (Avoiding user-specific directories also sidesteps any issues around determining whether a given Windows container image uses theContainerUser
orContainerAdministrator
user by default.)The text was updated successfully, but these errors were encountered: