Skip to content
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

agent:image: Support different pause image in the guest for guest pull #9369

Merged
merged 1 commit into from Apr 8, 2024

Conversation

ChengyuZhu6
Copy link
Member

@ChengyuZhu6 ChengyuZhu6 commented Mar 28, 2024

Support different pause images in the guest for guest-pull, such as k8s pause image (registry.k8s.io/pause) and openshift pause image (quay.io/bpradipt/okd-pause).

The primary distinction between the k8s pause image and the OKD pause image lies in the arguments specified in the config.json file:

For the k8s pause image, the arguments are set as follows:

"args": [
    "/pause"
],

Conversely, for the OKD pause image, the arguments are different:

"args": [
    "/usr/bin/pod"
],

Fixes: #9225 -- part III

@katacontainersbot katacontainersbot added the size/medium Average sized task label Mar 28, 2024
@ChengyuZhu6
Copy link
Member Author

@littlejawa Could you please have a test using the okd-pause-image? Unfortunately, I don’t have the setup to test okd-pause-image myself. However, I’ve verified the code with the k8s pause image (registry.k8s.io/pause:3.9), and it works correctly.

src/agent/src/image.rs Outdated Show resolved Hide resolved
src/agent/src/image.rs Outdated Show resolved Hide resolved
.context("load image config file")?;

let image_oci_process = image_oci.process.ok_or_else(|| {
anyhow!("The image config file does not contain a process specification.")
Copy link
Contributor

Choose a reason for hiding this comment

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

And here: "The guest pause image config does not contain a process specification. Please check the pause image" to be consistent with the message below when args.len() checker fails.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

// Ensure that the args vector is not empty before accessing its elements.
let args = image_oci_process.args;
// Check the number of arguments.
if args.len() != 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

For the registry.k8s.io/pause and quay.io/bpradipt/okd-pause images there is only one args (the pause executable file). However, is it always the case? It seems not unlikely to pass additional arguments to the pause executable so that args.len() >= 1.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I have fixed it.

@wainersm
Copy link
Contributor

wainersm commented Apr 1, 2024

Hi @ChengyuZhu6 , I'm not exactly an expert on the subject but I think I understood this change, so I left just a couple of comments but some might not make sense (please ignore if the case).

@ChengyuZhu6 ChengyuZhu6 force-pushed the sandbox-image branch 8 times, most recently from 2b41b7e to 1bf4b52 Compare April 2, 2024 14:14
@ChengyuZhu6
Copy link
Member Author

Hi @ChengyuZhu6 , I'm not exactly an expert on the subject but I think I understood this change, so I left just a couple of comments but some might not make sense (please ignore if the case).

@wainersm thanks for your comments! I've actions your comments. Please double check when you get a chance.

@fidencio
Copy link
Member

fidencio commented Apr 5, 2024

@ChengyuZhu6, I was able to verify your patches on a single node OCP cluster, that used the OCP's pause image by default, and it works as expected. Nice work!

info!(sl(), "pause_rootfs {:?}", pause_rootfs);

copy_if_not_exists(&guest_pause_config, &pause_bundle.join(CONFIG_JSON))?;
for pause_arg in args {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @ChengyuZhu6 !

Thanks for addressing my comments but I'm afraid I confused you, sorry.

It should not raise if len(args) > 1 as it you did before, however, we still want to copy only args[0] (which is the pause binary file).

Let's use a hypothetical config.json below, where len(args) > 1:

{
	"ociVersion": "1.0.0",
	"process": {
		"terminal": true,
		"user": {
			"uid": 65535,
			"gid": 65535
		},
		"args": [
			"/usr/bin/pod",
                        "arg1",
                        "arg2"
		],
		"env": [
			"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
			"TERM=xterm"
		],

arg1 and arg2 are really arguments to /usr/bin/pod binary, it will fail if it tries to copy these arguments :D

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, apologies for the misunderstanding. Thanks for bringing this.

Support different pause images in the guest for guest-pull, such as k8s
pause image (registry.k8s.io/pause) and openshift pause image (quay.io/bpradipt/okd-pause).

Fixes: kata-containers#9225 -- part III

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
@ChengyuZhu6
Copy link
Member Author

@wainersm @fidencio Would you mind providing a re-review on this PR ?

@ChengyuZhu6
Copy link
Member Author

/test

Copy link
Contributor

@littlejawa littlejawa left a comment

Choose a reason for hiding this comment

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

lgtm
Thanks @ChengyuZhu6

@fidencio
Copy link
Member

fidencio commented Apr 8, 2024

LGTM, I will wait for @wainersm approval!

Copy link
Contributor

@wainersm wainersm left a comment

Choose a reason for hiding this comment

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

Thanks once again @ChengyuZhu6 !

@wainersm wainersm merged commit fba1d39 into kata-containers:main Apr 8, 2024
298 of 303 checks passed
@ChengyuZhu6 ChengyuZhu6 deleted the sandbox-image branch April 8, 2024 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test size/medium Average sized task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimize guest pull feature
5 participants