classes/image-oci-umoci: Handle mutliple entrypoint arguments
PATCH 1/1 classes/image-oci-umoci: Handle mutliple entrypoint arguments
The entrypoint to a container is actually an array of the command with arguments to run, not just as single scalar. To handle this in umoci, the --config.entrypoint is passed multiple times in a single invocation, so implement that in the image class
--- classes/image-oci-umoci.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
classes/image-oci-umoci.inc +1 -1
@@ -99,7 +99,7 @@ IMAGE_CMD:oci() { bbnote "OCI: image subarch is set to: ${OCI_IMAGE_SUBARCH}, but umoci does not" bbnote " expose variants. use sloci instead if this is important" fi - umoci config --image $image_name:${OCI_IMAGE_TAG} --config.entrypoint ${OCI_IMAGE_ENTRYPOINT} + umoci config --image $image_name:${OCI_IMAGE_TAG} ${@" ".join("--config.entrypoint %s" % s for s in d.getVar("OCI_IMAGE_ENTRYPOINT").split())} if [ -n "${OCI_IMAGE_ENTRYPOINT_ARGS}" ]; then umoci config --image $image_name:${OCI_IMAGE_TAG} --config.cmd "${OCI_IMAGE_ENTRYPOINT_ARGS}" fi
Signature · 1 line
2.34.1
PATCH v2 1/1 classes/image-oci-umoci: Handle mutliple entrypoint arguments
The entrypoint to a container is actually an array of the executable to run and the arguments to pass to it. It is useful to be able to specify the entire list as the entrypoint when creating containers so that then entrypoint can be encoded with argument, e.g.
ENTRYPOINT ["/usr/bin/python3", "my-script"]
The current way that image-oci-umoci.bbclass handles this is equivalent to:
ENTRYPOINT ["/usr/bin/python3"]
CMD ["my-script"]But this is undesirable as it means if the user passes arguments when running the container, it will override the "my-script" argument and the arguments will instead get passed to the python interpreter, which may not be desired.
Instead, pass all the entry point arguments to umoci in a single invocation using multiple --config.entrypoint arguments, which correctly make the list as described above. The entire ENTRYPOINT list will start with OCI_IMAGE_ENTRYPOINT, then have OCI_IMAGE_ENRTYPOINT_ARGS split by spaces concatenated after it.
--- classes/image-oci-umoci.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
classes/image-oci-umoci.inc +4 -4
@@ -99,10 +99,10 @@ IMAGE_CMD:oci() { bbnote "OCI: image subarch is set to: ${OCI_IMAGE_SUBARCH}, but umoci does not" bbnote " expose variants. use sloci instead if this is important" fi - umoci config --image $image_name:${OCI_IMAGE_TAG} --config.entrypoint ${OCI_IMAGE_ENTRYPOINT} - if [ -n "${OCI_IMAGE_ENTRYPOINT_ARGS}" ]; then - umoci config --image $image_name:${OCI_IMAGE_TAG} --config.cmd "${OCI_IMAGE_ENTRYPOINT_ARGS}" - fi + umoci config --image $image_name:${OCI_IMAGE_TAG} \ + --config.entrypoint "${OCI_IMAGE_ENTRYPOINT}" \ + ${@" ".join("--config.entrypoint %s" % s for s in d.getVar("OCI_IMAGE_ENTRYPOINT_ARGS").split())} + umoci config --image $image_name:${OCI_IMAGE_TAG} --author ${OCI_IMAGE_AUTHOR_EMAIL} # make a tar version of the image direcotry
Signature · 1 line
2.34.1
Quoted 36 lines · Joshua Watt
The entrypoint to a container is actually an array of the executable to run and the arguments to pass to it. It is useful to be able to specify the entire list as the entrypoint when creating containers so that then entrypoint can be encoded with argument, e.g.
ENTRYPOINT ["/usr/bin/python3", "my-script"]The current way that image-oci-umoci.bbclass handles this is equivalent to:
ENTRYPOINT ["/usr/bin/python3"] CMD ["my-script"]But this is undesirable as it means if the user passes arguments when running the container, it will override the "my-script" argument and the arguments will instead get passed to the python interpreter, which may not be desired.
Instead, pass all the entry point arguments to umoci in a single invocation using multiple --config.entrypoint arguments, which correctly make the list as described above. The entire ENTRYPOINT list will start with
OCI_IMAGE_ENTRYPOINT, then haveOCI_IMAGE_ENRTYPOINT_ARGSsplit by spaces concatenated after it.Signed-off-by Joshua Watt <[email protected]>--- classes/image-oci-umoci.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)classes/image-oci-umoci.inc +0
-0@@ -99,10 +99,10 @@ IMAGE_CMD:oci() { bbnote "OCI: image subarch is set to: ${OCI_IMAGE_SUBARCH}, but umoci does not"
classes/image-oci-umoci.inc IMAGE_CMD:oci() { · line 105
Quoted 10 lines
classes/image-oci-umoci.inc +4
-4bbnote " expose variants. use sloci instead if this is important" fi - umoci config --image $image_name:${OCI_IMAGE_TAG} --config.entrypoint ${OCI_IMAGE_ENTRYPOINT} - if [ -n "${OCI_IMAGE_ENTRYPOINT_ARGS}" ]; then - umoci config --image $image_name:${OCI_IMAGE_TAG} --config.cmd "${OCI_IMAGE_ENTRYPOINT_ARGS}" - fi + umoci config --image $image_name:${OCI_IMAGE_TAG} \ + --config.entrypoint "${OCI_IMAGE_ENTRYPOINT}" \ + ${@" ".join("--config.entrypoint %s" % s for s in d.getVar("OCI_IMAGE_ENTRYPOINT_ARGS").split())} +
This is super close to what I badly tried to describe. I realize I could have
just done a patch to be clear, but it was a bit late and I just
wanted to get something out.
Do you think something like the following would meet your use case :
classes/image-oci-umoci.inc +0 -0
@@ -99,9 +99,10 @@ IMAGE_CMD:oci() { bbnote "OCI: image subarch is set to: ${OCI_IMAGE_SUBARCH},
but umoci does not"
bbnote " expose variants. use sloci instead if this is important"
fi
- umoci config --image $image_name:${OCI_IMAGE_TAG}
--config.entrypoint ${OCI_IMAGE_ENTRYPOINT}
+ umoci config --image $image_name:${OCI_IMAGE_TAG} \
+ ${@" ".join("--config.entrypoint %s" % s for s in
d.getVar("OCI_IMAGE_ENTRYPOINT").split())}
if [ -n "${OCI_IMAGE_ENTRYPOINT_ARGS}" ]; then- umoci config --image $image_name:${OCI_IMAGE_TAG} --config.cmd
"${OCI_IMAGE_ENTRYPOINT_ARGS}"
+ umoci config --image $image_name:${OCI_IMAGE_TAG} ${@"
".join("--config.cmd %s" % s for s in
d.getVar("OCI_IMAGE_ENTRYPOINT_ARGS").split())}
fi
That way you aren't forced to split your multi argument entrypoint over two variables, and
we can still have arguments in that ARGS variable available to be clobbered on container
start, etc.
I realize this is probably where you would have started if not for concerns about backward compatibility, etc.
But looking at it more, it is easier to just convert both variables to the repeated call to umoci. We are
leaving the variables themselves the same with space separated arguments/entrypoint, so that is enough
backward compatibility for me.
Bruce
Quoted 16 lines
classes/image-oci-umoci.inc +0
-1umoci config --image $image_name:${OCI_IMAGE_TAG} --author ${OCI_IMAGE_AUTHOR_EMAIL} # make a tar version of the image direcotry --2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#8362): https://lists.yoctoproject.org/g/meta-virtualization/message/8362
Mute This Topic: https://lists.yoctoproject.org/mt/101942798/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end - "Use the force Harry" - Gandalf, Star Trek II
Quoted 84 lines · Bruce Ashfield
Quoted 36 lines · Joshua Watt
The entrypoint to a container is actually an array of the executable to run and the arguments to pass to it. It is useful to be able to specify the entire list as the entrypoint when creating containers so that then entrypoint can be encoded with argument, e.g.
ENTRYPOINT ["/usr/bin/python3", "my-script"]The current way that image-oci-umoci.bbclass handles this is equivalent to:
ENTRYPOINT ["/usr/bin/python3"] CMD ["my-script"]But this is undesirable as it means if the user passes arguments when running the container, it will override the "my-script" argument and the arguments will instead get passed to the python interpreter, which may not be desired.
Instead, pass all the entry point arguments to umoci in a single invocation using multiple --config.entrypoint arguments, which correctly make the list as described above. The entire ENTRYPOINT list will start with
OCI_IMAGE_ENTRYPOINT, then haveOCI_IMAGE_ENRTYPOINT_ARGSsplit by spaces concatenated after it.Signed-off-by Joshua Watt <[email protected]>--- classes/image-oci-umoci.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)classes/image-oci-umoci.inc +0
-0@@ -99,10 +99,10 @@ IMAGE_CMD:oci() { bbnote "OCI: image subarch is set to: ${OCI_IMAGE_SUBARCH}, but umoci does not"classes/image-oci-umoci.inc IMAGE_CMD:oci() { · line 105
Quoted 10 lines
classes/image-oci-umoci.inc +4
-4bbnote " expose variants. use sloci instead if this is important" fi - umoci config --image $image_name:${OCI_IMAGE_TAG} --config.entrypoint ${OCI_IMAGE_ENTRYPOINT} - if [ -n "${OCI_IMAGE_ENTRYPOINT_ARGS}" ]; then - umoci config --image $image_name:${OCI_IMAGE_TAG} --config.cmd "${OCI_IMAGE_ENTRYPOINT_ARGS}" - fi + umoci config --image $image_name:${OCI_IMAGE_TAG} \ + --config.entrypoint "${OCI_IMAGE_ENTRYPOINT}" \ + ${@" ".join("--config.entrypoint %s" % s for s in d.getVar("OCI_IMAGE_ENTRYPOINT_ARGS").split())} +This is super close to what I badly tried to describe. I realize I could have
just done a patch to be clear, but it was a bit late and I just
wanted to get something out.Do you think something like the following would meet your use case :
classes/image-oci-umoci.inc +0
-0@@ -99,9 +99,10 @@ IMAGE_CMD:oci() { bbnote "OCI: image subarch is set to: ${OCI_IMAGE_SUBARCH},but umoci does not"
bbnote " expose variants. use sloci instead if this is important"
ficlasses/image-oci-umoci.inc +2
-2- umoci config --image $image_name:${OCI_IMAGE_TAG} --config.entrypoint ${OCI_IMAGE_ENTRYPOINT} + umoci config --image $image_name:${OCI_IMAGE_TAG} \ + ${@" ".join("--config.entrypoint %s" % s for s ind.getVar("OCI_IMAGE_ENTRYPOINT").split())}
if [ -n "${OCI_IMAGE_ENTRYPOINT_ARGS}" ]; then- umoci config --image $image_name:${OCI_IMAGE_TAG} --config.cmd
"${OCI_IMAGE_ENTRYPOINT_ARGS}"
+ umoci config --image $image_name:${OCI_IMAGE_TAG} ${@"
".join("--config.cmd %s" % s for s in
d.getVar("OCI_IMAGE_ENTRYPOINT_ARGS").split())}
fiThat way you aren't forced to split your multi argument entrypoint over two variables, and
we can still have arguments in that ARGS variable available to be clobbered on container
start, etc.
Quoted 7 lines
I realize this is probably where you would have started if not for concerns about backward compatibility, etc.
But looking at it more, it is easier to just convert both variables to the repeated call to umoci. We are
leaving the variables themselves the same with space separated arguments/entrypoint, so that is enough
backward compatibility for me.
Ah, yes. That is even better.
I like how you can set both entrypoint and command as lists this way.
Quoted 26 lines
Bruce
Quoted 8 lines
classes/image-oci-umoci.inc +0
-1umoci config --image $image_name:${OCI_IMAGE_TAG} --author ${OCI_IMAGE_AUTHOR_EMAIL} # make a tar version of the image direcotry --2.34.1
Quoted 8 lines
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#8362): https://lists.yoctoproject.org/g/meta-virtualization/message/8362
Mute This Topic: https://lists.yoctoproject.org/mt/101942798/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=---
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
Quoted 97 lines · Joshua Watt
Quoted 84 lines · Bruce Ashfield
Quoted 36 lines · Joshua Watt
The entrypoint to a container is actually an array of the executable to run and the arguments to pass to it. It is useful to be able to specify the entire list as the entrypoint when creating containers so that then entrypoint can be encoded with argument, e.g.
ENTRYPOINT ["/usr/bin/python3", "my-script"]The current way that image-oci-umoci.bbclass handles this is equivalent to:
ENTRYPOINT ["/usr/bin/python3"] CMD ["my-script"]But this is undesirable as it means if the user passes arguments when running the container, it will override the "my-script" argument and the arguments will instead get passed to the python interpreter, which may not be desired.
Instead, pass all the entry point arguments to umoci in a single invocation using multiple --config.entrypoint arguments, which correctly make the list as described above. The entire ENTRYPOINT list will start with
OCI_IMAGE_ENTRYPOINT, then haveOCI_IMAGE_ENRTYPOINT_ARGSsplit by spaces concatenated after it.Signed-off-by Joshua Watt <[email protected]>--- classes/image-oci-umoci.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)classes/image-oci-umoci.inc +0
-0@@ -99,10 +99,10 @@ IMAGE_CMD:oci() { bbnote "OCI: image subarch is set to: ${OCI_IMAGE_SUBARCH}, but umoci does not"classes/image-oci-umoci.inc IMAGE_CMD:oci() { · line 105
Quoted 10 lines
classes/image-oci-umoci.inc +4
-4bbnote " expose variants. use sloci instead if this is important" fi - umoci config --image $image_name:${OCI_IMAGE_TAG} --config.entrypoint ${OCI_IMAGE_ENTRYPOINT} - if [ -n "${OCI_IMAGE_ENTRYPOINT_ARGS}" ]; then - umoci config --image $image_name:${OCI_IMAGE_TAG} --config.cmd "${OCI_IMAGE_ENTRYPOINT_ARGS}" - fi + umoci config --image $image_name:${OCI_IMAGE_TAG} \ + --config.entrypoint "${OCI_IMAGE_ENTRYPOINT}" \ + ${@" ".join("--config.entrypoint %s" % s for s in d.getVar("OCI_IMAGE_ENTRYPOINT_ARGS").split())} +This is super close to what I badly tried to describe. I realize I could have
just done a patch to be clear, but it was a bit late and I just
wanted to get something out.Do you think something like the following would meet your use case :
classes/image-oci-umoci.inc +0
-0@@ -99,9 +99,10 @@ IMAGE_CMD:oci() { bbnote "OCI: image subarch is set to: ${OCI_IMAGE_SUBARCH},but umoci does not"
bbnote " expose variants. use sloci instead if this is important"
ficlasses/image-oci-umoci.inc +2
-2- umoci config --image $image_name:${OCI_IMAGE_TAG} --config.entrypoint ${OCI_IMAGE_ENTRYPOINT} + umoci config --image $image_name:${OCI_IMAGE_TAG} \ + ${@" ".join("--config.entrypoint %s" % s for s ind.getVar("OCI_IMAGE_ENTRYPOINT").split())}
if [ -n "${OCI_IMAGE_ENTRYPOINT_ARGS}" ]; then- umoci config --image $image_name:${OCI_IMAGE_TAG} --config.cmd
"${OCI_IMAGE_ENTRYPOINT_ARGS}"
+ umoci config --image $image_name:${OCI_IMAGE_TAG} ${@"
".join("--config.cmd %s" % s for s in
d.getVar("OCI_IMAGE_ENTRYPOINT_ARGS").split())}
fiThat way you aren't forced to split your multi argument entrypoint over two variables, and
we can still have arguments in that ARGS variable available to be clobbered on container
start, etc.Quoted 7 lines
I realize this is probably where you would have started if not for concerns about backward compatibility, etc.
But looking at it more, it is easier to just convert both variables to the repeated call to umoci. We are
leaving the variables themselves the same with space separated arguments/entrypoint, so that is enough
backward compatibility for me.Ah, yes. That is even better.
Quoted 1 line
I like how you can set both entrypoint and command as lists this way.
I can make the commit here, and add your signed-off-by, since we can take your reply as you being ok with this change, derived from your patches.
Bruce
Quoted 27 lines
Quoted 27 lines
Bruce
Quoted 8 lines
classes/image-oci-umoci.inc +0
-1umoci config --image $image_name:${OCI_IMAGE_TAG} --author ${OCI_IMAGE_AUTHOR_EMAIL} # make a tar version of the image direcotry --2.34.1
Quoted 8 lines
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#8362): https://lists.yoctoproject.org/g/meta-virtualization/message/8362
Mute This Topic: https://lists.yoctoproject.org/mt/101942798/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=---
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end - "Use the force Harry" - Gandalf, Star Trek II
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 99 lines · Bruce Ashfield via lists.yoctoproject.org
Quoted 97 lines · Joshua Watt
Quoted 84 lines · Bruce Ashfield
Quoted 36 lines · Joshua Watt
The entrypoint to a container is actually an array of the executable to run and the arguments to pass to it. It is useful to be able to specify the entire list as the entrypoint when creating containers so that then entrypoint can be encoded with argument, e.g.
ENTRYPOINT ["/usr/bin/python3", "my-script"]The current way that image-oci-umoci.bbclass handles this is equivalent to:
ENTRYPOINT ["/usr/bin/python3"] CMD ["my-script"]But this is undesirable as it means if the user passes arguments when running the container, it will override the "my-script" argument and the arguments will instead get passed to the python interpreter, which may not be desired.
Instead, pass all the entry point arguments to umoci in a single invocation using multiple --config.entrypoint arguments, which correctly make the list as described above. The entire ENTRYPOINT list will start with
OCI_IMAGE_ENTRYPOINT, then haveOCI_IMAGE_ENRTYPOINT_ARGSsplit by spaces concatenated after it.Signed-off-by Joshua Watt <[email protected]>--- classes/image-oci-umoci.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)classes/image-oci-umoci.inc +0
-0@@ -99,10 +99,10 @@ IMAGE_CMD:oci() { bbnote "OCI: image subarch is set to: ${OCI_IMAGE_SUBARCH}, but umoci does not"classes/image-oci-umoci.inc IMAGE_CMD:oci() { · line 105
Quoted 10 lines
classes/image-oci-umoci.inc +4
-4bbnote " expose variants. use sloci instead if this is important" fi - umoci config --image $image_name:${OCI_IMAGE_TAG} --config.entrypoint ${OCI_IMAGE_ENTRYPOINT} - if [ -n "${OCI_IMAGE_ENTRYPOINT_ARGS}" ]; then - umoci config --image $image_name:${OCI_IMAGE_TAG} --config.cmd "${OCI_IMAGE_ENTRYPOINT_ARGS}" - fi + umoci config --image $image_name:${OCI_IMAGE_TAG} \ + --config.entrypoint "${OCI_IMAGE_ENTRYPOINT}" \ + ${@" ".join("--config.entrypoint %s" % s for s in d.getVar("OCI_IMAGE_ENTRYPOINT_ARGS").split())} +This is super close to what I badly tried to describe. I realize I could have
just done a patch to be clear, but it was a bit late and I just
wanted to get something out.Do you think something like the following would meet your use case :
classes/image-oci-umoci.inc +0
-0@@ -99,9 +99,10 @@ IMAGE_CMD:oci() { bbnote "OCI: image subarch is set to: ${OCI_IMAGE_SUBARCH},but umoci does not"
bbnote " expose variants. use sloci instead if this is important"
ficlasses/image-oci-umoci.inc +2
-2- umoci config --image $image_name:${OCI_IMAGE_TAG} --config.entrypoint ${OCI_IMAGE_ENTRYPOINT} + umoci config --image $image_name:${OCI_IMAGE_TAG} \ + ${@" ".join("--config.entrypoint %s" % s for s ind.getVar("OCI_IMAGE_ENTRYPOINT").split())}
if [ -n "${OCI_IMAGE_ENTRYPOINT_ARGS}" ]; then- umoci config --image $image_name:${OCI_IMAGE_TAG} --config.cmd
"${OCI_IMAGE_ENTRYPOINT_ARGS}"
+ umoci config --image $image_name:${OCI_IMAGE_TAG} ${@"
".join("--config.cmd %s" % s for s in
d.getVar("OCI_IMAGE_ENTRYPOINT_ARGS").split())}
fiThat way you aren't forced to split your multi argument entrypoint over two variables, and
we can still have arguments in that ARGS variable available to be clobbered on container
start, etc.Quoted 7 lines
I realize this is probably where you would have started if not for concerns about backward compatibility, etc.
But looking at it more, it is easier to just convert both variables to the repeated call to umoci. We are
leaving the variables themselves the same with space separated arguments/entrypoint, so that is enough
backward compatibility for me.Ah, yes. That is even better.
Quoted 6 lines
Quoted 1 line
I like how you can set both entrypoint and command as lists this way.
I can make the commit here, and add your signed-off-by, since we can take your reply as you being ok with this change, derived from your patches.
My version of this is on master-next. I passed creation and skopeo copy to dockerhub, pull and run, so it appears to be sane :)
Bruce
Quoted 39 lines
Bruce
Quoted 17 lines
Quoted 17 lines
Bruce
Quoted 10 lines
classes/image-oci-umoci.inc +0
-1umoci config --image $image_name:${OCI_IMAGE_TAG} --author ${OCI_IMAGE_AUTHOR_EMAIL} # make a tar version of the image direcotry --2.34.1
Quoted 4 lines
Quoted 4 lines
--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#8365): https://lists.yoctoproject.org/g/meta-virtualization/message/8365
Mute This Topic: https://lists.yoctoproject.org/mt/101942798/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/leave/6693017/1050810/978058475/xyzzy [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end - "Use the force Harry" - Gandalf, Star Trek II