-
Notifications
You must be signed in to change notification settings - Fork 612
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
Add default PATH Env variable to opts, if image inspect doesn't inclu… #372
Conversation
…de PATH Signed-off-by: HassanAlsamahi <hassanalsamahi12@gmail.com>
cmd/nerdctl/run.go
Outdated
@@ -336,6 +336,16 @@ func runAction(clicontext *cli.Context) error { | |||
opts = append(opts, oci.WithProcessCwd(wd)) | |||
} | |||
|
|||
for ind, env := range ensuredImage.ImageConfig.Env { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Signed-off-by: HassanAlsamahi <hassanalsamahi12@gmail.com>
7876cb6
to
707bd0d
Compare
@@ -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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
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:
and it worked as expected.
Please let me know if you have any thoughts, concerns or modifications.