21 Commits

Author SHA1 Message Date
Philippe Martin
f276d0d77b Watch for new pods when logs --follow (#6914)
* Watch for new pods when logs --follow

* Fix integration tests

* Implement --follow for podman platform

* Add integration test
2023-06-28 14:21:04 +02:00
Philippe Martin
6bc30110ba Display outputs when executing odo run (#6865)
* Change NewRunHandler params with Options

* Pass an options to RunHandler to show logs

* Hide spinner and std output since outputs are displayed

* Integration tests with failing command

* Fix outputs

* use raw terminal and local standard i/o streams

* Fix podman i/o

* Fix stdout/err

* Test if in/out are terminal

* command reference doc
2023-06-12 10:45:31 -04:00
Philippe Martin
330b724753 Add an odo run command to manually execute command during odo dev (#6857)
* Add a run command

* Check command name passed as arg

* Check platform is available

* Add a Run method to the DevClient

* Run command on cluster

* Add test with run command on cluster

* Implement and test run on podman

* Enhance test to check that command has been executed in container

* Fix `odo help` test

* Refactor common code for podman/cluster

* Test Apply commands on Kubernetes/Images

* Test  a msg is displayed when executing odo run without odo dev

* Review

* makes GetRunningPodFromSelector return only Running pods on Podman
2023-06-02 09:33:21 -04:00
Armel Soro
4bab9285fb Allow to cancel execution of odo dev at any phase (e.g. if build command is taking long) (#6736)
* Add test cases simulating build or run commands that take very long

* Pass a context around to relevant functions and methods

This will allow to handle cancellations and timeouts and deadlines as needed

* Pass the context to Podman exec command too

* fixup! Add test cases simulating build or run commands that take very long
2023-04-20 17:12:28 +00:00
Philippe Martin
2beda42c01 Do not output log to stdout (#6473) 2023-01-06 08:50:23 -05:00
Armel Soro
5660093167 Use go-cmp instead of reflect.DeepEqual to compare unit test results (#6343) 2022-11-24 07:24:32 -05:00
Armel Soro
918a4e97fb Make 'pkg/logs' platform-agnostic (#6251)
* Panic if platform for Exec is not supported yet

This will make the error more visible,
instead of hiding it.

* Use a consistent receiver name in 'pkg/kclient.Client#DeploymentWatcher'

* Make 'pkg/logs/LogsClient' rely on the generic 'platform.Client'

Co-authored-by: Philippe Martin <phmartin@redhat.com>

* Make 'pkg/component#Log' function rely on the generic 'platform.Client'

Co-authored-by: Philippe Martin <phmartin@redhat.com>

* Make the 'execHandler' in 'pkg/component' rely on the generic 'platform.Client'

Co-authored-by: Philippe Martin <phmartin@redhat.com>

* Move 'matchOwnerReferenceWithResources' unit tests from 'pkg/logs' to 'pkg/kclient'

Those tests are specific to the Kubernetes implementation.

Co-authored-by: Philippe Martin <phmartin@redhat.com>
2022-11-01 10:59:17 -04:00
Philippe Martin
014021d73a Make exec package agnostic of platform (#6217)
* Make exec pkg agnostic of platform

* Move ExtractProjectToComponent to sync package

* Parthvi's review
2022-10-21 04:50:25 -04:00
Philippe Martin
f78096d264 Refactor remotecmd (#6169)
* Remove kclient from interface / signatures

* Create Exec package

* Call ExecuteCommand with client

* Call ExecuteCommand with client from sync package

* Fix order of dependencies
2022-09-27 09:38:54 +02:00
Chris Laprun
412f588e59 refactor: simplify execution of devfile commands (#3596)
* refactor: simplify execution of devfile commands

Fixes #3518

* fix: remove mistakenly re-added PlatformAdapter interface

* refactor: move catalog list output to where it's actually needed

This simplifies the package organization by avoiding to import catalog-
related packages in the lower-level machine output package.

* feat: add LoggingClient method on ComponentAdapter interface

* refactor: rename all receivers similarly

* fix: typo

* refactor: ComponentAdapter implements ExecClient, simplify Execute

* fix: typo

* refactor: introduce GenericAdapter to share more code

* chore: remove now unneeded methods

* fix: update from master

* fix: improper code to ExecuteCommand

* fix: properly initialize Client in adapters

* fix: update tests

* chore: add docs [skip ci]

* refactor: expose component info factory methods

* feat: add ExplicitSpinner function

* refactor: simplify adapters using NewMachineEventLoggingClient factory

* refactor: introduce command concept following the composite pattern

Still needs a lot of work to accommodate composite-support changes

* refactor: re-implement command execution using composite commands

* refactor: re-organize command implementations in multiple files

* doc: document New and command

* fix: typo

* fix: change var name

* fix: improper check for composite command

* clean-up: unneeded code

* refactor: rename ExecuteDevfileCommandSynchronously more appropriately

* chore: re-add some tests

* fix: init the ComponentInfoFactories after the GenericAdapter is created

This is needed because the previous implementation resulted in the
componentInfo and supervisorComponentInfo variables capturing
uninitialized adapters and thus causing errors.

* chore: add documentation

* fix: use Errorf instead of Wrapf since there is no error to wrap

* fix: infinite loop

* fix: do not report an error if the supervisor container is not found

* fix: only start the supervisor if we found its container

* fix: remove redundant check

* fix: supervisor commands now use proper component info

Introduced newSupervisor*Command to encapsulate supervisor command
details.

* fix: do not add to composite if supervisor command is nil

* fix: supervisor start/stop should be more like regular simple commands

* fix: add newline at the end of output

* doc: add documentation

[skip ci]

* refactor: rename createFrom to createCommandFrom

* refactor: make sourcePath a const and move it where it's used

* fix: comment out failing tests

See #3685

* fix: typo

* doc: clarify simpleCommand's behavior with respect to commands

[skip ci]

* feat: do not show spinner if message is empty

* fix: do not show spinner for stop command

* fix: remove unneeded fmt.Sprintf call

* chore: update after rebase
2020-08-06 22:17:15 -04:00
John Collier
120c348651 Add support for composite commands on Kubernetes (#3551)
* Add validation for composite commands

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Composite command exec shell

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Prevent NPE

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Implement composite command execution

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Move composite command func to exec package

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Fix error handling for parallel execution

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Unit tests for composite commands

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Add some comments

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Comment for mock client

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Remove unused code

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Clean up

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Add integration test for composite commands

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Fix broken integration test

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Don't allow composite run commands at this time

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Use util.ConcurrentTask to run parallel commands

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Integration test for parallel composite commands

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Disable composite run command

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Address review comments

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Address review comments

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Fix string comparison

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Add unit tests for command help funcs

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Remove unused function

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Fix NPE

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Fix NPE

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Verify group before checking kind

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Address review comments

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Test case for nested parallel composite command

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* More composite command integration tests

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Fix comments

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Cleanup

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Update tests

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Fix test

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Fix spinner on parallel commands

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Fix spinner on parallel exec

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Add missing arg

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Fix merge conflict with odo test

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Integration test for composite test commands

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Fix string comparison bug with composite commands

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Clean up post-rebase

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Prevent indirect self-reference of composite commands

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Use proper devfile

Signed-off-by: John Collier <John.J.Collier@ibm.com>
2020-07-23 06:29:22 +02:00
Stephanie Cao
5c2c609145 Support environment variables in command (#3537)
* set env variables

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* undo the change from other branches

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* add integraton tests

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* add more tests

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* add unit tests for debug command

Signed-off-by: Stephanie <stephanie.cao@ibm.com>
2020-07-21 04:12:44 -04:00
Stephanie Cao
81adbcc24f Odo test cmd for devfile 2.0 (#3400)
* first commit to save change

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* able to run odo test

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* add test in adapters

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* test works

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* add integration test

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* fix integration test

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* address code review comments

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* remove comments

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* add more tests

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* fix some typo

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* remove content added by mistake

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* update error message, and the integration test

* address review comments

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* simplify the error return

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* test command should have 0 args

Signed-off-by: Stephanie <stephanie.cao@ibm.com>

* add test in the docker test description

* modify trivis.yaml file

Signed-off-by: Stephanie <stephanie.cao@ibm.com>
2020-07-16 20:09:05 -04:00
Jonathan West
e28812a34d Push support: Event notification support for build and application status for IDE integration for devfile scenarios (#3003)
* Add machine readable event logging support

* Add machine readable event logging support

* Add machine readable event logging support

* Add machine readable event logging support

* Add machine readable event logging support

* Add machine readable event logging support

* Add machine readable event logging support

* Remove --devfile

* Remove incorrect constraint

* Add odo push -o json example

* Rebase and add debug action logging to new methods
2020-06-23 05:25:48 +02:00
Mrinal Das
fd349dee65 Adds debug command for devfiles (#3059)
* Adds debug command for devfiles

* Fixes comments and variable names

* Adds devfile debug test on kubernetes cluster

* Fixes adapter code for debug

Signed-off-by: mik-dass <mrinald7@gmail.com>

* Converts v1 debug test devfile to v2

* Moves container arg and command overriding to a new function

* Simplifies conditions in test

* Modifies execDevfile for kubernetes component adapter

* Simplies error checking logic in TestUpdateContainersWithSupervisord

* Removes unnecessary else if conditions

* Installs socat before running tests on kubernetes cluster
2020-06-19 09:29:44 -04:00
Charlie Drage
e5df06fb68 Fix unsafe data race in ExecuteCommand (#3310)
**What type of PR is this?**

/kind bug

**What does does this PR do / why we need it**:

Fixes a potential flake with regards to when writing to cmdOutput at the
same time that log.ErrorF(...) is reading from it.

**Which issue(s) this PR fixes**:

Closes https://github.com/openshift/odo/issues/2828

**How to test changes / Special notes to the reviewer**:

N/A, honestly not too sure
2020-06-12 11:47:31 -04:00
Aditi Sharma
5f71123d43 Add Support for Devfile V2 (#3216)
* Add Devfile Parser V2, Update Common Structs (#3188)

* Add Devfile Parser for Version 2.0.0

Added Devfile V2 Go Structures
Added converter for v2 ro common types

Signed-off-by: adisky <adsharma@redhat.com>

* Add example V2 devfile

added example nodejs V2 devfile

* Add Common Types as V2

Add common types as v2
Add Converter from common to v1

* Updated example devfile with group

* Fixes command.go and kubernetes adapter (#3194)

Signed-off-by: mik-dass <mrinald7@gmail.com>

* Fixes utils of k8s adapter (#3195)

* Update Command Logic to use groups (#3196)

* Updates create logic to v2 (#3200)

* Fixes utils of docker docker adapter (#3198)

Signed-off-by: mik-dass <mrinald7@gmail.com>

* Update Docker and Kubernetes adapter to use groups (#3206)

* Update Docker and Kubernetes adapter to use groups

* Update Some Validation

Incorporate some review comments for commands Map
Update Some Validation logic

* Updated Logs for V2 (#3208)

Fixed interface implementation for v2
Updated logs
refactored commands.go

* Avoid String Pointers (#3209)

While converting v1 to v2 types, string pointers are prone to cause
null pointer error. This PR updates struct fields from string
pointers to string

* Update commands check

* Fixes lower and upper case for commands (#3219)

* Fixes type of project and components for devfile v1 (#3228)

* Update testing utils (#3220)


* Update command tests

Updated Command tests to v2
Removed some cases like command type validation, that will be
validated by schema only.

* Fix common adapters tests

All devfile.adapters.common unit tests are fixed

* Add tests for Mismatched type

Fix devfile.adapters.Kubernetes.Component unit tests

* Add TestCase for default command

* Design proposal: Event notification support for build and application status for IDE integration for devfile scenarios (#2550) (#3177)

* Add event notification proposal

[skip ci]

* Update event-notification.md

* Update event-notification.md

* Update event-notification.md

* Update event-notification.md

* Update event-notification.md

* Update event-notification.md

* Update event-notification.md

* Update event-notification.md

* Fix Integration tests for devfile v2 (#3236)

* Fix Integration tests

Correct volume structure
Fix supervisord binary insertion for docker
Insert command and args in build container fr docker

* Fix Integration tests

Revert commands, args removal
Add commands, args in v2 common structs
Fix duplicate volume error

* Fixes unit tests (#3240)

Signed-off-by: mik-dass <mrinald7@gmail.com>

* Add devfiles V2 examples (#3253)

Add devfiles v2 examples for springboot and nodejs

* Fix regression by sparse checkout dir PR (#3258)

fix regression caused by rebase to master.
Also add github, zip as supported project types.

* Address review comments (#3267)

* Address review comments part 2

fix log levels to v4
fix error formatting
add case no's in test cases
update some comments

* Address review comments part 2

Remove validation for group

Co-authored-by: Mrinal Das <mrinald7@gmail.com>
Co-authored-by: Jonathan West <jgwest@users.noreply.github.com>
2020-06-03 00:16:39 +02:00
Tomas Kral
a82f3e0256 Update openshift to 4.4. and k8s to 1.17 (#3081)
* update openshift libs to 4.4

* update vendor
2020-05-06 18:53:51 +02:00
Aditi Sharma
77a605db0d Add support for command attribute restart (#3043)
* Add Support of attribute restart

If command attribute restart is false in devfile, then the
devRun command would not be restarted.

* Add Intregration test for attribute restart

* Added Support of restart attribute for docker type component

Signed-off-by: adisky <adsharma@redhat.com>
2020-05-04 17:24:13 +02:00
Maysun J Faisal
10826cc3f4 Docker Devfile Component Sync and Execution (#2922)
* Docker Exec API draft

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Sync logic for docker components

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* docker supervisord init container and vol draft

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* docker devfile exec draft

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* docker exec first pass

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* do not devfile push, if no file changes - fix regression

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Fix existing devfile tests for docker exec

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Docker exec feedback 1 and cleanup

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Further docker exec cleanup, addressing feedback 2

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* rebase, fix url hostconfig & push log info

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Fix devfile docker container restart bug

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Fix current tests for devfile docker exec sync

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Docker integration tests - push exec, sync, GET url

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* docker exec unit tests 1 & cleanup

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* docker exec unit tests 2

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* temp commit: sync unit tests 1

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* devfile exec,sync feedback 3, cleanup, tests

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>
2020-04-27 15:03:02 -04:00
Maysun J Faisal
fd8416cc92 Devfile command execution (#2735)
* First pass of devfile exec

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Second pass of devfile exec

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Devfile exec - PR Feedback 1

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* First pass of devfile exec

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Second pass of devfile exec

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Devfile exec - PR Feedback 1

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Devfile exec unit tests 1

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Devfile exec unit tests 1

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Address review comments from pull/2735#pullrequestreview-383109487

* Fix up command validation error messages

Signed-off-by: Rajiv Senthilnathan <rajivsen@ca.ibm.com>

* Devfile exec - PR Feedback 2, Unit Tests, etc.

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Rebase cleanup for devfile exec

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Fix error format and validate command bug

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Update devfile integration tests for mandatory devrun

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Temporarily switch odo init image until prod image is updated

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

Co-authored-by: Rajiv Senthilnathan <rajivsen@ca.ibm.com>
2020-04-04 01:45:56 +02:00