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

Add default PATH Env variable to opts, if image inspect doesn't inclu… #372

Merged
merged 2 commits into from
Sep 21, 2021

Conversation

HassanAlsamahi
Copy link
Contributor

@HassanAlsamahi HassanAlsamahi commented Sep 18, 2021

fix #356
Adding the PATH environmental variable to the opts passed to the container, if the image inspect is missing the PATH environment variable.

It was tested with:

  • registry.fedoraproject.org/fedora:rawhide
  • ubuntu:latest
  • centos:latest

and it worked as expected.

Please let me know if you have any thoughts, concerns or modifications.

…de PATH

Signed-off-by: HassanAlsamahi <hassanalsamahi12@gmail.com>
@@ -336,6 +336,16 @@ func runAction(clicontext *cli.Context) error {
opts = append(opts, oci.WithProcessCwd(wd))
}

for ind, env := range ensuredImage.ImageConfig.Env {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks, but CI failing

=== RUN   TestRunCustomRootfs
334
    run_test.go:97: assertion failed: 
335
        Command:  /usr/local/bin/nerdctl --namespace=nerdctl-test run --rm --rootfs /tmp/rootfs1612200801 /bin/cat /proc/self/environ
336
        ExitCode: 2
337
        Error:    exit status 2
338
        Stdout:   
339
        Stderr:   panic: runtime error: invalid memory address or nil pointer dereference
340
        [signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0xda9239]
341
        
342
        goroutine 1 [running]:
343
        main.runAction(0xc000109dc0)
344
        	/go/src/github.com/containerd/nerdctl/cmd/nerdctl/run.go:339 +0x759
345
        github.com/urfave/cli/v2.(*Command).Run(0x186e4c0, 0xc000109000)
346

https://github.com/containerd/nerdctl/pull/372/checks?check_run_id=3641485262#step:5:333

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've fixed the issue, please check.

@AkihiroSuda AkihiroSuda added this to the v0.12.0 milestone Sep 18, 2021
Signed-off-by: HassanAlsamahi <hassanalsamahi12@gmail.com>
@@ -667,6 +667,15 @@ func generateRootfsOpts(ctx context.Context, client *containerd.Client, cliconte
containerd.WithNewSnapshot(id, ensured.Image),
containerd.WithImageStopSignal(ensured.Image, "SIGTERM"),
)
for ind, env := range ensured.ImageConfig.Env {
Copy link
Member

Choose a reason for hiding this comment

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

loop omited when len(ensured.ImageConfig.Env)=0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I missed this case, I guess I'll need to check on the ENV slice length first before entering the loop....I'll fix it and push the changes, thanks

Copy link
Member

Choose a reason for hiding this comment

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

No need to omit the loop. When the slice is empty, the loop just becomes a nop.

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda merged commit ca81e3a into containerd:master Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PATH should be set automatically when the image config lacks PATH
3 participants