-
Notifications
You must be signed in to change notification settings - Fork 243
Add support for command
/args
fields in container
components
#5768
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 support for command
/args
fields in container
components
#5768
Conversation
Skipping CI for Draft Pull Request. |
✅ Deploy Preview for odo-docusaurus-preview canceled.
|
--no-supervisord
experimental flag to "odo dev"
--no-supervisord
experimental flag to "odo dev"--no-supervisord
experimental flag to odo dev
2b3d7c3
to
b46d279
Compare
cb0f061
to
02853b7
Compare
fbb4a9d
to
e1e9224
Compare
--no-supervisord
experimental flag to odo dev
command
/args
fields in container
components, via a --no-supervisord
experimental flag to odo dev
command
/args
fields in container
components, via a --no-supervisord
experimental flag to odo dev
command
/args
fields in container
components, via a --no-supervisord
flag to odo dev
e1e9224
to
899ac0e
Compare
…aiting for 1 sec Now that the command is run via a goroutine, there might be some situations where we were checking the status just before the goroutine had a chance to start.
…andAndGetOutput Rely on the same logic in ExecuteCommand
As commented out in [1], we don't store anymore the debug port value in the ENV file. [1] redhat-developer#5768 (comment)
Did this happen right after running |
Is this timeout hardcoded in odo? |
I think it is the PushTimeout you can set in preferences |
84c9ea6
to
520e3b3
Compare
Okay, I see - thanks. |
It looks like my failure is not related to this PR. I'm debugging the problem, but it looks like something related to SBO
Even tho the application is defined correctly
It is still a problem. |
This package no longer depends on Devfile-related packages.
This boolean is tied to the given retry schedule, so it makes sense for it to be passed with the schedule.
Kudos, SonarCloud Quality Gate passed!
|
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.
The code lgtm, thank you for patiently working on this!
// An error is returned for non-exec Devfile commands. | ||
func devfileCommandToRemoteCmdDefinition(devfileCmd devfilev1.Command) (remotecmd.CommandDefinition, error) { | ||
if devfileCmd.Exec == nil { | ||
return remotecmd.CommandDefinition{}, errors.New(" only Exec commands are supported") |
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.
return remotecmd.CommandDefinition{}, errors.New(" only Exec commands are supported") | |
return remotecmd.CommandDefinition{}, errors.New("only Exec commands are supported") |
envVars[e.Name] = e.Value | ||
} | ||
|
||
return remotecmd.CommandDefinition{ |
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.
💯
/override ci/prow/unit |
@feloy: Overrode contexts on behalf of feloy: ci/prow/unit, ci/prow/v4.10-integration-e2e In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
…dhat-developer#5768) * Introduce new 'pkg/remotecmd' package This package allows to execute commands in remote packages and exposes an interface for managing processes associated to given Devfile commands. * Rely on 'pkg/libdevfile' as much as possible for Devfile command execution This requires passing a handler at the odo side, which in turns uses the 'pkg/remotecmd' package to run commands in remote containers. * Switch to running without Supervisord as PID 1 in containers To do this, the idea is to start the container component: 1- using the command/args defined in the Devfile 2- using whatever was defined in the container image if there is no command/args defined in the Devfile Then, once the container is started, we would execute the Devfile commands directly in the container component, just like a simple 'kubectl exec' command would do. Since this is a long-running command (and potentially never ending), we would need to run it in the background, i.e. in a side goroutine. Point 2) above requires implementing a temporary hack (as discussed in [1]), without us having to wait for [2] to be merged on the Devfile side. This temporary hack overrides the container entrypoint with "tail -f /dev/null" if the component defines no command or args (in which case we should have used whatever is defined in the image, per the specification). [1] redhat-developer#5768 (comment) [2] devfile/registry#102 * Rename K8s adapter struct 'client' field into 'kubeClient', as suggested in review * Rename sync adapter struct 'client' fields to better distinguish between them * Make sure messages displayed to users running 'odo dev' are the same * Update temporary hack log message Co-authored-by: Philippe Martin <[email protected]> * Make sure to handle process output line by line, for performance purposes * Handle remote process output and errors in the Devfile command handler The implementation in kubeexec.go should remain as generic as possible * Keep retrying remote process status until timeout, rather than just waiting for 1 sec Now that the command is run via a goroutine, there might be some situations where we were checking the status just before the goroutine had a chance to start. * Handle remote process output and errors in the Devfile command handler The implementation in kubeexec.go should remain as generic as possible * Update kubeexec StopProcessForCommand implementation such that it relies on /proc to kill the parent children processes * Ignore missing children file in getProcessChildren * Unit-test methods in kubexec.go * Fix missing logs when build command does not pass when running 'odo dev' Also add integration test case * Fix spinner status when commands passed to exec_handler do not pass * Make sure to check process status right after stopping it The process just stopped might take longer to exit (it might have caught the signal and is performing additional cleanup) * Keep retrying remote process status until timeout, rather than just waiting for 1 sec Now that the command is run via a goroutine, there might be some situations where we were checking the status just before the goroutine had a chance to start. * Fix potential deadlock when reading output from remotecmd#ExecuteCommandAndGetOutput Rely on the same logic in ExecuteCommand * Add more unit tests * Remove block that used to check debug port from env info As commented out in [1], we don't store anymore the debug port value in the ENV file. [1] redhat-developer#5768 (comment) * Rename 'getCommandFromFlag' into 'getCommandByName', as suggested in review * Make remotecmd package more generic This package no longer depends on Devfile-related packages. * Fix comments in libdevfile.go * Move errorIfTimeout struct field as parameter of RetryWithSchedule This boolean is tied to the given retry schedule, so it makes sense for it to be passed with the schedule. * Expose a single ExecuteCommand function that returns both stdout and stderr Co-authored-by: Philippe Martin <[email protected]>
What type of PR is this:
/kind bug
What does this PR do / why we need it:
As discussed in #5648 (comment), the goal of this PR is to support
command
andargs
fields defined in container components by leveraging the fact thatodo dev
is a long-running client-side command.At this time, Supervisord requires to override the container entrypoint, which is not compliant with the Devfile specification. Per the Devfile specification, we should use any
command
orargs
defined in the container component, or whatever command or entrypoint is available in the container image.So the approach implemented here is to no longer run containers with Supervisord.
Instead, the pod is now created without the
copy-supervisord
init container, and the container component is created either with thecommand
orargs
defined in the Devfile, or by not specifying any command, which means Kubernetes/OpenShift will use whatever is defined in the image.Then subsequent
run
ordebug
Devfile commands are executed right away in the running container, in a separate goroutine:/opt/odo/.odo_devfile_cmd_*.pid
At the moment, most container images used in Devfile stacks define terminating commands, which requires defining explicit commands and/or args if we want to use them with the changes here.
See devfile/registry#102 and devfile/api#679
Because devfile/registry#102 is not merged yet on the Devfile side and to avoid being blocked by this, we decided [1] to implement a temporary hack that sets the container command to
tail -f /dev/null
if none was explicitly defined.[1] #5768 (comment)
Which issue(s) this PR fixes:
Fixes #5648
PR acceptance criteria:
Unit test
Integration test
Documentation
How to test changes / Special notes to the reviewer:
odo dev
should work as before, except that:tail -f /dev/null
if not set in the Devfile (purpose of the temporary hack depicted above)