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
Support multiple postStart events attached to one container component #1081
Conversation
Allow multiple postStart lifecycle bindings attached to a single container component. If a DevWorkspace contains postStart commands 'command1' and 'command2', the operator will add a lifecycle binding to the container similar to lifecycle: postStart: exec: command: - "/bin/sh" - "-c" - | cd command1.workingDir command2.commandLine cd command2.workingDir command2.commandLine Signed-off-by: Angel Misevski <amisevsk@redhat.com>
Redirect stdout and stderr to /tmp/poststart-stdout.txt and /tmp/poststart-stderr.txt in the workspace, as postStart events do not log anything unless they fail. Signed-off-by: Angel Misevski <amisevsk@redhat.com>
Signed-off-by: Angel Misevski <amisevsk@redhat.com>
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1081 +/- ##
==========================================
+ Coverage 50.50% 50.53% +0.03%
==========================================
Files 82 82
Lines 7360 7359 -1
==========================================
+ Hits 3717 3719 +2
+ Misses 3358 3355 -3
Partials 285 285
... and 1 file with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
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 have tested with Che on an OpenShift cluster and it worked as expected! 👍
I had 5 commands + the editor startup script:
lifecycle:
postStart:
exec:
command:
- /bin/sh
- -c
- |
{
cd ${PROJECT_SOURCE}/src/test/java/com/redhat/cloudnative
badcommand
cd ${PROJECT_SOURCE}/does/not/exist
cat InventoryResourceTest.java
cd ${PROJECT_SOURCE}/src/test/java/com/redhat/cloudnative
cat InventoryResourceTest.java
nohup /checode/entrypoint-volume.sh > /checode/entrypoint-logs.txt 2>&1 &
echo "ping"
echo "pong"
} 1>/tmp/poststart-stdout.txt 2>/tmp/poststart-stderr.txt
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.
Code looks good to me, tested around on OpenShift 4.12 as well. Great work @amisevsk 👍
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: amisevsk, AObuchow, l0rd The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What does this PR do?
Updates how postStart events are handled to allow multiple postStart events to run on one container
This includes a few changes:
0
. We can potentially work around this withset -e
if necessaryThe new format for postStart commands (as a lifecycle hook) is
What issues does this PR fix or reference?
Closes: #1011
Related:
Is it tested? How?
Testing with `code-latest`
The following workspace should start normally, except with a file `post-start.log` in the project directoryBig devworkspace I used to test multiple combinations
The following workspace should
$PROJECT_SOURCE/output-to-file.log
$HOME/multi-line-command.log
that shows it slept for 5 seconds/tmp/poststart-stderr.txt
/tmp/poststart-stdout.txt
, including the long-running background task (which should log increasing numbers)PR Checklist
/test v8-devworkspace-operator-e2e, v8-che-happy-path
to trigger)v8-devworkspace-operator-e2e
: DevWorkspace e2e testv8-che-happy-path
: Happy path for verification integration with Che