-
Couldn't load subscription status.
- Fork 881
stage1: set TERM temp, keepEnv merge in "rkt run" #1962
Conversation
|
The bug was filed in intelsdi-x#28. Please file issues that are relevant to upstream on the coreos/rkt project next time. The patch needs to be rebased on upstream/master. I think the logic in append_env() is wrong because it appends the variable in the env file each time "rkt enter" is executed. After several "rkt enter", I get: Instead of patching appexec.c, you could patch enter.c to exec appexec with an alternative env file for this case. |
|
We are not using IMO |
|
Maybe another parameter in |
Good idea, it seems cleaner this way. |
|
Argh...wasn't aware of that, that I should file issue twice. Instead of hacking in appexec, I propose set "keep env" like "inherit env" and "set env" before appexec (all envs in PrepareConfig). Then, if appexec is used during "enter" or "run" set $TERM is just temporary. |
e419d67 to
fc8c40b
Compare
rkt/run.go
Outdated
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.
It can be problem here, but I'm not sure - IIRC LISTEND_FDS and LISTEN_PID are way to pass file descriptors from "internal systemd to application" rather than "external' (host) systemd.
What should work for "common" env variables, I think will not work for "socket activation" variables.
Your variables has to go through all layers like that.
# running
systemd(host) -> rkt(binary) -> init -> systemd(internal) -> appexec -> app
# entering
rkt(binary) -> enter -> ssh(kvm)/nsenter -> appexec -> app
what I'm worried about is the LISTEN_* values are copied to early. Deeper analysis is needed.
Maybe we should, had list names of variables (without values) and each layer is responsible for passing it down (sometimes thorough file and sometimes just by inheriting and sometimes by send_env in ssh options) and then if some layer like "internal systemd" can override what it wants (but it sounds a bit like code duplication).
15756d3 to
de57589
Compare
|
yep, LISTEND_FDS and LISTEN_PID should be coupled with inner systemd. IMHO additional common keep_env file for all apps should be more clear - it s created during run, and read only in entering |
|
Thanks for updating it. It will need to be rebased on the last master. @vcaputo do you have some time to review this? |
de57589 to
184503a
Compare
|
My only issue with this patch is that we should differentiate:
for run we should have: "app env set" + "run env set" IIUC, this change merge variables from "run" and "enter" set and IMO in some corner case can broke service under systemd eg, some can get unexpected we should call |
could be enhancement issue related with
Well, I'm not a systemd expert, neither know that TERM could impact on systemd. If yes, there shouldn't be a problem change it quickly and don't load TERM during
|
184503a to
5fc5462
Compare
stage1/appexec/appexec.c
Outdated
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.
you forget to move argv offset according the number of options from optind and when you do this (with handling of '--'), you can as well handle -e NAME_OF_VARIABLE to fill the keepEnv table with variables that should be passed:
so it at the end:
run-> unit.service -> ExecStart =appexec -e LISTEN_FDS -e LISTEN_PID ...- 'enter' ->
appexec -e TERM
just an idea, but looks better, more clean, and more extensible solution - only if you have time for this 😸
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.
And what with my original idea of possibility to also pass new values for variables? I mean something like -e TERM as "set value of TERM variable basing on current environ value (pass it)" and -e TERM=value as "set particular value for TERM variable"?
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.
setenv("TERM", term, 1); is called immediately after the char *term = getenv("TERM"); here, and before the load_env() / clearenv(). It seems to be a no-op, and not what we want.
5fc5462 to
8fe17e7
Compare
|
20f674d to
cb6667e
Compare
stage1/appexec/appexec.c
Outdated
| size_t n_gids; | ||
|
|
||
| exit_if(argc < 7, | ||
| "Usage: %s /path/to/root /work/directory /env/file uid gid[,gid...] /to/exec [args ...]", argv[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.
Please document the new parameter -e in the usage.
|
Can you rebase on master to fix the conflict? |
stage1/appexec/appexec.c
Outdated
| */ | ||
| static void load_env(const char *env_file, const char *keep_env_file, int entering) | ||
| { | ||
| char *term = getenv("TERM"); /* usefull to keep during entering. */ |
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.
useful
Keep additional $TERM before clear envs in appexec - needed to proper work after entering. Additional flag in appexec "-e" for check entering or run. Add additional keep_env file for socket activation. Now appexec doesn't modify env_file, instead it create kee_env_file once, during run command. Related to issue #28
cb6667e to
6f8d271
Compare
Two additional tests for check TERM env during entering. Document a new optional flag '-e' in appexec.
6f8d271 to
d314c59
Compare
|
Tested socket activation and that LGTM. |
stage1: set TERM temp, keepEnv merge in "rkt run"
|
Merged manually to remove mention of internal issue number in commit messagee. |
Pass additional TERM to env. Needed to proper work after entering
Related to issue #28