-
Couldn't load subscription status.
- Fork 881
stage1: propagate app exit code to rkt exit code #2198
Conversation
CHANGELOG.md
Outdated
|
|
||
| #### New features and UX changes | ||
|
|
||
| - Propagate app exit status to rkt's exit status ([#HEHE](https://github.com/coreos/rkt/pull/HEHE). |
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.
;)
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.
Now you know.
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.
:)
5c2e16b to
52d36b4
Compare
| echo "${status#*=}" > "/rkt/status/$app" | ||
| if [ "${status#*=}" != 0 ] ; then | ||
| ${SYSCTL} exit ${status#*=} | ||
| fi |
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.
Can you add a comment?
# The command "systemctl exit $status" is available since systemd-v227. On older
# systemd, the command will fail and rkt will just exit with return code 0.
52d36b4 to
6e8f834
Compare
|
Updated. |
| err := child.Wait() | ||
| status := getExitStatus(err) | ||
| if status != expectedStatus { | ||
| t.Fatalf("rkt terminated with unexpected status %d, expected %d\nOutput:\n%s", status, expectedStatus, child.Collect()) |
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 don't think there is a point in running Collect() here. For this to work, Capture() needs to be called first. So this will most likely print no output at all.
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.
Hm, it looks like it is following what is being done in this function below. Nevermind then.
20c2312 to
616a03c
Compare
|
Will this work with kvm flavor (assuming that there is systemd 229)? |
|
@krnowak I assume the command |
|
We'll recheck when we update to v229. Any other concerns? |
| // Currently we have systemd v222 in the coreos flavor which doesn't | ||
| // include the exit status propagation code. | ||
| // TODO(iaguis): we should expect 5 as the exit status when we update to v229 | ||
| waitOrFail(t, child, 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.
Would this break tests with tests/aws.sh on Fedora-Rawhide with the host flavor (it should have the last systemd)?
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
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'd like if tests/aws.sh could test the host flavor on all versions of Fedora... this would require something like...?
if systemdVersion() >= 227 {
waitOrFail(t, child, 5)
} else {
waitOrFail(t, child, 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.
That would be nice but detecting the stage1 systemd version from the tests seems a bit overkill...
a8dd956 to
616a03c
Compare
|
This is not finished yet, it works with the src flavor because we copy all the generated unit files to stage1 but it doesn't work otherwise. I need to figure out which services/targets are needed. |
8eb9348 to
9e6e9d2
Compare
|
PTAL. |
|
Just one question otherwise LFAD (or fixup the commit message) - the |
Yes, |
stage1/init/common/pod.go
Outdated
|
|
||
| if err = writeShutdownService(p); err != nil { | ||
| return errwrap.Wrap(errors.New("failed to write shutdown service"), err) | ||
| } |
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.
Shouldn't this be in PodToSystemd() instead of appToSystemd()? In a pod with several apps, the shutdown service should still be written only one time.
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're very right, no need to write it over and over again.
9e6e9d2 to
977396d
Compare
If the version of the systemd running in stage1 is >=v227, the command "systemctl exit STATUS" will set the exit status of the container. See https://lists.freedesktop.org/archives/systemd-devel/2015-October/034509.html: * The "systemctl exit" command now optionally takes an additional parameter that sets the exit code to return from the systemd manager when exiting. This is only relevant when running the systemd user instance, or when running the system instance in a container. If not, we will continue with the previous logic, so we can merge this now and benefit from it when we actually update to v229.
Modify functions that wait for rkt to expect a particular exit code instead of only success and fail.
977396d to
8671c92
Compare
Depending on stage1's systemd version, we call "halt" or "exit". In the host flavor, we need to parse the output of "systemctl --version" because there's not systemd version information in stage1.
8671c92 to
a65b232
Compare
|
LGTM |
stage1: propagate app exit code to rkt exit code
|
mikel from samsung is hitting this issue today when he has a service file that requires So when will we import v229? |
If the version of the systemd running in stage1 is >=v227, the command
"systemctl exit STATUS" will set the exit status of the container. See
https://lists.freedesktop.org/archives/systemd-devel/2015-October/034509.html:
additional parameter that sets the exit code to return from
the systemd manager when exiting. This is only relevant when
running the systemd user instance, or when running the
system instance in a container.
If not, we will continue with the previous logic, so we can merge this now
and benefit from it when we actually update to v229.
Closes #1783