1190 Commits

Author SHA1 Message Date
Armel Soro
147542db69 Do not necessarily error out if odo dev is stopped via Ctrl+C (#6917)
* Add test highlighting the expectations

* Propagate errors and call os.Exit only in 'main' functions

See ExitInMain[1] and ExitInMain_ExitOnce[2] coding convention guidelines.

[1] https://github.com/redhat-developer/odo/wiki/Dev:-Coding-Conventions#exit-in-main
[2] https://github.com/redhat-developer/odo/wiki/Dev:-Coding-Conventions#exit-once

* Handle errors returned by Cleanuper#Cleanup

This makes sure the exit code of the command
is mapped onto any error returned by Cleanup

* Do not return an error when the watch loop in 'odo dev' is interrupted

* Test that the exit code of 'odo dev' matches the error returned by the cleanup logic
2023-06-22 13:14:07 +02:00
Philippe Martin
a29253521c Replace odo delete component integration with unit tests (#6904) 2023-06-21 17:43:03 +02:00
Philippe Martin
50ba3868a6 Add --sync-git-dir flag to odo dev (#6910)
* Indexer does not ignore .git

* add --sync-git-dir flag to odo dev

* Integration tests

* Add doc

* Force sync of complete .git content
2023-06-20 10:26:14 -04:00
Parthvi Vala
0b012f30e5 Implement HTTP Server based on OpenAPI spec (#6835)
* Implement HTTP Server based on OpenAPI spec

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>
Co-authored-by: Philippe Martin <phmartin@redhat.com>

* Starter server when odo dev starts

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add --api-server and --api-server-port flags to start API Server; write the port to stat file; TODO: make this feature experimental

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>
Co-authored-by: Philippe Martin <phmartin@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>

Make the flag experimental

Signed-off-by: Parthvi Vala <pvala@redhat.com>

Make apiserver and apiserverport flag local

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Use container image to run openapi-generator-tool instead of a local CLI

Co-authored-by: Armel Soro <asoro@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add integration test

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Use label podman

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Regenerate the api files with openapitool v6.6.0 and changes from review

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>
Co-authored-by: Philippe Martin <phmartin@redhat.com>
2023-06-19 10:29:36 -04:00
Parthvi Vala
a9e6cdc340 Refactor StartDevMode to return a single object instead of multiple args (#6886)
* Refactor StartDevMode to return an object instead of multiple variables

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Fix test

Signed-off-by: Parthvi Vala <pvala@redhat.com>

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
2023-06-16 10:01:27 -04:00
Philippe Martin
24db6079dd Stop test as soon as expectations are ok (#6891) 2023-06-15 03:58:00 -04:00
Armel Soro
63c8e27e2a Implement odo dev --no-commands (#6855)
* Document the '--no-commands' flag

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

* Add integration tests highlighting the expectations

* Add '--no-commands' flag to the 'dev' sub-command

* Implement '--no-command' on Podman

* Implement '--no-command' on cluster

* Validate the '--no-commands' flag in the CLI

For example, it should not be possible to call it alongside '--build-command' or '--run-command',
because we won't be able to know what to do.

* Fix 'odo dev' tests when the run/debug does not exist

For consistency with how e.g., the build command works,
instead of erroring out, `odo dev` will
now simply log the error message and wait for new input.

* Check for command existence when we want to run them

As suggested in review, this makes it more adaptable.
As a consequence, if the default (or single) build/run command does not exist,
"odo dev" will not error out immediately; instead, it will behave a bit like
"odo dev --no-commands" (by starting, but printing a warning about the
missing command).
The difference here is that if a run command is added later on
during the dev session, "odo dev" will pick it up and run it,
but "odo dev --no-commands" will continue to purposely ignore it.

The existence of the optional default Build is already checked
by the 'libdevfile.Build' command. It does not error out if there is
no default (or single) Build command. It errors out only if the specified
'--build-command' does not exist in the Devfile.

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

* Check for application ports only if the Devfile has run or debug command and if there are ports to forward

This prevents:
i) displaying the "Waiting for the application to be ready" spinner for nothing,
  if there are no ports to forward
ii) waiting until the timeout of 1m has expired if there was no run/debug command executed,
  in which case, it is less unlikely that the application ports defined in the Devfile
  will ever be reachable.

* Test "odo run" command against a Dev Session started with and without "--no-commands"

---------

Co-authored-by: Philippe Martin <phmartin@redhat.com>
2023-06-14 09:28:06 -04:00
Philippe Martin
aabbded7e1 Unit tests/inject test clientset (#6874)
* Inject testClientset

* Test analyze CLI as unit test

* Replace odo analyze integration tests with unit tests
2023-06-13 13:16:31 -04: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
b6c9c88245 Make sure the "Syncing files into the container" spinner is displayed on Podman (#6863)
* Check that the "Syncing files into the container" spinner is correctly displayed on both Podman and cluster

* Add missing "Syncing files into the container" spinner when running 'odo dev' on Podman

This indicates to the user that we are sync'ing the files,
which might be a potentially long operation.
This is to be consistent with the output when using 'odo dev' on cluster.
2023-06-02 05:13:13 -04:00
Armel Soro
a79c953e7a Track preference options usage (#6843)
* Add integration test highlighting the expectations

* Record parameter (and value) set or unset using the 'odo preference set/unset' commands

By default, values are anonymized.
Only parameters explicitly declared list will be recorded verbatim.
This list is currently empty, but that might change later on.

* Mark all current preference parameters except ImageRegistry as clear-text

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

---------

Co-authored-by: Philippe Martin <phmartin@redhat.com>
2023-05-30 05:02:02 -04:00
Armel Soro
85b4ff92e8 Make sure event is recorded whenever telemetry preference is changed (#6842)
* Add integration test highlighting the expectations

* Use the cancellable context derived from 'cmd.Context' where needed

* Introduce new 'wasTelemetryEnabled' telemetry property

This is recorded before any command is run.
And it will help determine if telemetry was
changed (e.g., from enabled to disabled),
so that we can record the event in this case.

* Send telemetry if it was enabled previously or if it is currently enabled

This is done by reading the actual telemetry setting
(either from env vars or the preferences file)
at the moment we want to record the telemetry event.
This covers cases where a command ('odo preference set ConsentTelemetry')
or an environment variable ('ODO_TRACKING_CONSENT')
updated the telemetry consent for example.
2023-05-26 11:25:24 -04:00
Philippe Martin
9a239c4e77 Use a single handler for executing all commands (#6826)
* Document current implementations of command handlers

* Add unit tests for execHAndler

* Refactor pkg/devfile/image to inject Backend as dependency

* Use same handler for kubedev/podmandev

* Fail after SelectBackend==nil only if backend is needed

* Move runHandler to dev/common

* Unit tests for runHandler

* Create a component.ExecuteTerminatingCommand

* ExecuteTerminatingCommand/ExecuteNonTerminatingCommand for Handler

* Fix calling other command types

* Consider parent group to determine if a command is terminating

* Replace component.execHandler by common.runHandler

* Remove execHandler

* Make runHandler and most of fields private and pass containersRunning to handler

* Pass containersRunning value

* deploy using common Handler

* Fix tests

* Use specific Dev/Deploy mode for Apply

* Fix cmdline for job

* Fix unit tests

* Pass appName and componentName with ctx to handler

* Move handler to pkg/component package

* Update doc

* Unit tests Deploy

* Unit tests Build

* Unit tests Run

* Unit tests PostStart

* Unit tests PreStop

* Update doc

* Fix Podman tests

* Fix hotReload on podman

* Change podman version timeout to 30s for tests

* Cleanup + fix doc
2023-05-26 11:01:21 -04:00
Armel Soro
511aaa22ad Fix should print warning about default namespace when running odo dev test when Dev Session does not start correctly (#6848)
The goal of this test is to ensure that the warning message is displayed,
so it does not matter if the Dev Session does not start correctly.
2023-05-26 10:09:08 -04:00
Parthvi Vala
e9077be4d6 Fix issues with describe/list binding tests (#6839)
* Fix issues with describe/list binding tests

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>

* Attempt at fixing human readable failure

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Fix bug with odo list --namespace while fetching binding information

Signed-off-by: Parthvi Vala <pvala@redhat.com>

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>
2023-05-26 07:51:47 -04:00
Armel Soro
b60fc5bc47 Fix flaky odo dev test on Podman by randomizing component names (#6833)
* Fix 'odo dev' tests by randomizing some missing component names

* Force setting a component name when copying example Devfiles

This way, we won't forget about this in the future.
2023-05-26 04:46:51 -04:00
Armel Soro
ec747b4ab3 Allow using imageName as a selector (#6768)
* Add integration tests highlighting our expectations

* Bump Devfile library to latest commit

f041d79870

* Expose preference that allows users to globally configure an image registry

* Return the effective Devfile view by default from the initial context

This is supposed to be read-only, so that tools can rely on it
and to the operations they need to perform right away.

Raw Devfile objects can still be obtained upon request
if there is need to update them (for example via 'odo add/remove
binding' commands.

* Pass the image registry preference to the Devfile parser to build the effective view

* Fix 'odo init' integration tests

- The test spec was actually not doing what it was supposed to do
- Now 'odo init' returns a complete Devfile, where the parent is flattened,
  because the goal of 'odo init' is to bootstrap a Devfile.
  Previously, 'odo init' would not download the parent referenced,
  making it hard to understand the resulting Devfile.

* Document how odo now handles relative image names as selectors

* fixup! Document how odo now handles relative image names as selectors

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

* Revert "Fix 'odo init' integration tests"

This reverts commit 78868b03fd.

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

* Do not make `odo init` return an effective Devfile as a result

This would change the behavior of `odo init`.

Furthermore, due to an issue [1] in the Devfile library,
it is not possible to parse some Devfiles with parents linked as GitHub URLs (like GitHub release artifacts).

[1] https://github.com/devfile/api/issues/1119

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

* fixup! Document how odo now handles relative image names as selectors

---------

Co-authored-by: Philippe Martin <phmartin@redhat.com>
2023-05-22 10:45:27 -04:00
dependabot[bot]
50cb5c9b3b Go: Bump github.com/securego/gosec/v2 from 2.14.0 to 2.15.0 (#6686)
* Go: Bump github.com/securego/gosec/v2 from 2.14.0 to 2.15.0

Bumps [github.com/securego/gosec/v2](https://github.com/securego/gosec) from 2.14.0 to 2.15.0.
- [Release notes](https://github.com/securego/gosec/releases)
- [Changelog](https://github.com/securego/gosec/blob/master/.goreleaser.yml)
- [Commits](https://github.com/securego/gosec/compare/v2.14.0...v2.15.0)

---
updated-dependencies:
- dependency-name: github.com/securego/gosec/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Make sure to handle error returned by io.Closer.Close() in 'defer' statements

This is considered unsafe by gosec otherwise.

[1] https://github.com/securego/gosec/issues/512
[2] https://github.com/securego/gosec/issues/714
[3] https://www.joeshaw.org/dont-defer-close-on-writable-files/

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Armel Soro <asoro@redhat.com>
2023-05-16 09:51:30 -04:00
Philippe Martin
d23789afd3 Wait after killing odo during integration test (#6816)
* Wait after killing odo during integration test

* Make podman replacement terminate sooner
2023-05-15 08:46:17 -04:00
Philippe Martin
2e0a882dea fix 6812 (#6814)
* todo

* Log Devfile Registry

* remove end space

* Clean comment
2023-05-15 04:54:25 -04:00
Parthvi Vala
0cdc2e5542 Fix: odo init overwrites personalized configuration when downloading starter project (#6800)
* Fix personalized configuration overwritten by starter project

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Update pkg/registry/registry_test.go

Co-authored-by: Armel Soro <armel@rm3l.org>
Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Adding intergration tests for personalizing configurations with odo init

Signed-off-by: Ritu Deshmukh <rideshmu@redhat.com>

Modified changes

Signed-off-by: Ritu Deshmukh <rideshmu@redhat.com>

Update tests/integration/interactive_init_test.go

Co-authored-by: Parthvi Vala <pvala@redhat.com>

Update tests/integration/interactive_init_test.go

Co-authored-by: Parthvi Vala <pvala@redhat.com>

Update interactive_init_test.go

Update interactive_init_test.go

Update interactive_init_test.go

Update tests/integration/interactive_init_test.go

Co-authored-by: Parthvi Vala <pvala@redhat.com>

Update interactive_init_test.go

* Updated changes

Signed-off-by: Ritu Deshmukh <rideshmu@redhat.com>

* Attempt at fixing interactive tests

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add multiple devfile version check

Co-authored-by: Armel Soro <asoro@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Signed-off-by: Ritu Deshmukh <rideshmu@redhat.com>
Co-authored-by: Armel Soro <armel@rm3l.org>
Co-authored-by: Ritu Deshmukh <rideshmu@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>
2023-05-11 16:06:49 -04:00
Armel Soro
c217741cc7 Add a timeout when initializing the Podman client (broken Podman should not affect odo dev on cluster) (#6808)
* Add test highlighting the issue and setting the expectations

* Add a timeout of 1s to the 'podman version' command

This command is called at dependency injection time to initialize a (nil-able) Podman client,
even if users won't use Podman at all.
As discussed, this command is supposed to be
quite fast to return, hence this timeout of 1 second.

Initially, we were using cmd.Output to get the command output,
but as reported in [1], cmd.Output does not respect the context timeout.
This explains the workaround of reading from both stdout and stderr pipes,
*and* relying on cmd.Wait() to close those pipes properly when the program exits
(either as expected or when the timeout is reached).

[1] https://github.com/golang/go/issues/57129

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

* Log the errors returned at dependency injection time when the optional Kubernetes/Podman clients could not be initialized

This helps debug such potential issues instead of swallowing the errors.

* Make the timeout configurable via the 'PODMAN_CMD_INIT_TIMEOUT' env var

This will allow setting a different value for environments like
in GitHub where the Podman client would take slightly more time to return
(I guess because of we are running a lot of Podman commands in parallel?).

* Increase the timeout for Podman tests to an arbitrary value of 10s

Some tests did not pass because the Podman client did not
initialize in 1s; I guess because we are running a lot of Podman commands in parallel?
This should hopefully improve this situation.

* fixup! Add a timeout of 1s to the 'podman version' command

---------

Co-authored-by: Philippe Martin <phmartin@redhat.com>
2023-05-11 15:34:34 -04:00
Philippe Martin
da28e7d286 Delete previous pod and creates new ond when modifying devfile on podman (#6802)
* Delete previous pod and creates new ond when modifying devfile on podman

* Add integration tests
2023-05-10 06:45:19 -04:00
Philippe Martin
32e2df0f43 Check latest version from index instead of using hardcoded value (#6789)
* Check latest version from index instead of using harcoded value

* Use checkVersion

* Fix when DEVFILE_REGISTRY ends with /
2023-05-05 01:19:42 -04:00
Philippe Martin
56d0b6f95e Fix HotReloadCapable Build command (#6696)
* On cluster, run Build command again only if Build command itself is not hotReloadCapable

* On Podman, execute Build command only if itself is not hotReloadcapable

* Handle hotReloadCapable in handler

* Add integration tests

* Update doc

* review
2023-05-04 10:20:21 -04:00
Armel Soro
6241a66129 Allow passing extra flags to Podman/Docker (#6785)
* Allow passing extra build flags to Podman/Docker

This is supported via 2 new env vars:
- ODO_IMAGE_BUILD_ARGS: passed when building images via Podman/Docker
- ODO_CONTAINER_RUN_ARGS: passed when running odo dev on Podman

Those are comma-separated list of options
that can be passed to either Podman or Docker
(depending on the PODMAN_CMD env var).

* Refactor 'build-images' tests to make it easier to add additional tests

* Add integration tests for passing build extra args

* Add integration tests for passing global extra args to Podman

* Distinguish between global options passed to Podman and specific options for 'podman play kube'

Previously, we were handling 'ODO_CONTAINER_RUN_ARGS' as global options for Podman,
but this turns our not being that useful if we want to pass dedicated options to 'podman play kube'.
This commit introduces a new 'ODO_CONTAINER_BACKEND_GLOBAL_ARGS' env var,
which will be used as global options passed to every Podman command we execute.

This paves the way to isolating our Podman-related tests further
using the '--root' and '--runroot' global options.

* Use `ODO_IMAGE_BUILD_ARGS` in the Advanced Guides

* Use a semicolon as delimiter for extra flags

Doing so because some of the options of Podman/Docker can actually be either repeated or comma-separated.
2023-05-04 04:59:18 -04:00
Parthvi Vala
010e9634d3 Use custom address for port forwarding (#6766)
* Custom address for port forwarding

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add integration tests

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Use private variables for custom address and ports

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Update pkg/util/util.go

Co-authored-by: Armel Soro <armel@rm3l.org>

* Assign custom address to HostIP for podman

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add validation for free port when --port-forward is provided in the Validate() method, add integration test for running parallel dev sessions on same platform, same port and different addresses

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Fix unit test failure

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Attempt at fixing windows failure

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add documentation

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Use default value for --address flag

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Changes from review

Co-authored-by: Armel Soro <asoro@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <armel@rm3l.org>
Co-authored-by: Armel Soro <asoro@redhat.com>
2023-05-02 07:34:19 -04:00
Philippe Martin
191ee6f45f Wait when Build command fails (#6771)
* Same signature for reconcile in kubedev/podmandev

* Do not call initial reconcile

* Do not retry + filter deployment events

* Integration tests

* Move logs back to level 4

* Remove unnecessary files

* Log state + Set state to ready when build fails
2023-05-02 04:39:58 -04:00
Armel Soro
00918c3d16 Support variable substitution with --var and --var-file in odo build-images (#6776)
* Add integration tests

* Add support for --var and --var-file to the 'build-images' command

* Update 'build-images' command reference
2023-04-27 11:13:16 -04:00
Philippe Martin
ef9206a86f PODMAN_USE_NAMESPACES to disable using namespaces on podman integration tests for podman v4.5 (#6774)
* PODMAN_USE_NAMESPACES to disable using namespaces on podman integration tests for podman v4.5

* Parse bool value

* Update tests/helper/helper_podman.go

Co-authored-by: Parthvi Vala <pvala@redhat.com>

---------

Co-authored-by: Parthvi Vala <pvala@redhat.com>
2023-04-27 06:19:22 -04:00
ritudes
591309747f Doc automation:Command reference: odo delete,list and set namespace (#6756)
* Adding files for odo delete,list and set namespace

Signed-off-by: Ritu Deshmukh <rideshmu@redhat.com>

* Changes to be added

Signed-off-by: Ritu Deshmukh <rideshmu@redhat.com>

* Modified changes

Signed-off-by: Ritu Deshmukh <rideshmu@redhat.com>

* Adding changes based on review

Signed-off-by: Ritu Deshmukh <rideshmu@redhat.com>

---------

Signed-off-by: Ritu Deshmukh <rideshmu@redhat.com>
2023-04-27 03:04:28 -04:00
Parthvi Vala
b57d3e2f17 Attempt at fixing (#6769)
Move test skip before waitgroup is initiated

Signed-off-by: Parthvi Vala <pvala@redhat.com>
2023-04-26 03:39:24 -04:00
Armel Soro
6aacbe242b Fix flaky tests using custom port mapping when running specs in parallel (#6763)
* Fix flaky test using custom port mapping when running specs in parallel

Using a global counter currently does not work
because Ginkgo runs parallel specs by isolating them in
completely different processes [1].
This relies on the parallel process index returned by Ginkgo
to get a value that can be used as starting port.
Callers can then safely increment this value if needed in the
specs to get a different custom value.

[1] https://onsi.github.io/ginkgo/#mental-model-how-ginkgo-runs-parallel-specs

* Apply suggestions from code review

Co-authored-by: Parthvi Vala <pvala@redhat.com>

* fixup! Apply suggestions from code review

---------

Co-authored-by: Parthvi Vala <pvala@redhat.com>
2023-04-25 07:00:02 +00:00
Philippe Martin
4d1e402542 Check files to sync with gitignore library (#6760) 2023-04-24 16:29:41 +00:00
Armel Soro
f62a4337d3 Set 'mountSources' to 'true' in some example SpringBoot multi-container Devfiles (#6761)
In those examples, the build and run commands are running in
different container components.
Without mounting sources in the container used for the 'run' command,
this command will not start because Maven would not be able
to resolve the 'spring-boot' plugin:

```
 ✓  Building your application in container (command: defaultbuild) [39s]
 •  Executing the application (command: defaultrun)  ...
 ✗  Finished executing the application (command: defaultrun) [151ms]
 ⚠  Devfile command "defaultrun" exited with an error status in 20 second(s)
 ⚠  Last 100 lines of log:
 ✗  Waiting for the application to be ready [1m]
 ⚠  Port forwarding might not work correctly: timeout while checking for ports; ports not listening: (8080 in container "runtime"): context deadline exceeded
 ⚠  Running `odo logs --follow` might help in identifying the problem.

 -  Forwarding from 127.0.0.1:20001 -> 8080
```

This was not caught in the tests because failing to run the
'run' command current does not prevent the Dev session from starting.

This change might actually make the test faster as we would not have to wait 1 minute
to find out that the application port is not reachable.
2023-04-24 14:11:55 +00:00
Philippe Martin
61c38c4205 Add annotation for setting access mode on automounted configmap/secret files (#6750)
* Support accessmode annotation

* Support accessmode annotation

* Add ddoc

* Add test for decimal value + more doc
2023-04-22 16:31:27 +00:00
Philippe Martin
32f92d1ec8 Update image for springboot devfiles (#6753) 2023-04-20 17:32:19 +00:00
Parthvi Vala
a10229dd54 Cleanup e2e tests (#6738)
* Cleanup e2e tests

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Revert "Cleanup e2e tests"

This reverts commit fa61002d86a1994a26bc766b29b458ebdbaf2059.

* Use java devfile for odo dev testing and nodejs for debugging

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Use a specific container name

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Increase timeout for odo dev now that we are waiting for the application to be ready

Signed-off-by: Parthvi Vala <pvala@redhat.com>

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
2023-04-20 17:32:12 +00: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
b843ce845e Set vcs-uri annotation on podman (#6746)
* Set vcs-uri annotation on podman

* Integration test

* Disable test with Podman v3

* Make test run with podman v4

* Fix displaying error
2023-04-19 11:35:18 -04:00
Philippe Martin
bd5098eb53 Use devstats.PID.json as devstate (#6713)
* Use devstate.PID.json

* odo describe component gets forwarded ports from devstate.json

* Pass pid in context

* Add platform to state

* Overwrite devstate.json if PId not exists

* odo describe component displays forwarded ports from podman/cluster

* Start only one session on platform

* Fix integration test

* Review

* Fix

* Update pkg/state/errors.go

Co-authored-by: Armel Soro <armel@rm3l.org>

* Integration tests

* Fix integration test

---------

Co-authored-by: Armel Soro <armel@rm3l.org>
2023-04-19 04:16:08 -04:00
Parthvi Vala
28ba3df556 Podman custom port mapping (#6729)
* Temp Change

* Custom port mapping works with podman

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add unit tests

* Move custom port forward formation to the general getPortMapping function

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Integration test

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Fix unit tests

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Refactor integration test

Signed-off-by: Parthvi Vala <pvala@redhat.com>

Add dev --debug integration test for podman

Signed-off-by: Parthvi Vala <pvala@redhat.com>

Add dev --debug integration test for podman

Signed-off-by: Parthvi Vala <pvala@redhat.com>

Fix ci failures

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Use order to iterate over ceMapping and fix a check with debug integration test

Signed-off-by: Parthvi Vala <pvala@redhat.com>

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
2023-04-18 10:01:49 -04:00
Philippe Martin
7a721348b3 Automount volumes (#6698)
* Simplify AddOdoProjectVolume and AddOdoMandatoryVolume

* Rename / Clarify HandleEphemeralStorage function

* Regroup volume-specific code

* Move volume specific code to a separated function

* Add a new module configAutomount

* Automount PVC (without options)

* Add unit tests

* Separate functions

* Mount secrets

* Mount configmaps

* Specific mount path

* MountAs annotation

* Mounting cm/secret as env

* Refacto: use inAllContainers + replace result with volume

* Mounting cm/secret as subpath

* Read-only

* Integration tests

* Rename label

* Automount during odo deploy Exec command

* Add documentation

* Fix TODO

* Review

* Fix indentation

* Rename labels/annotations
2023-04-18 07:58:45 -04:00
Armel Soro
72ea3cd9e5 Wait until expected ports are opened in the container before starting port-forwarding (#6701)
* Add function in 'port' package allowing to check whether given ports are actually opened and in LISTEN state in specified containers

* Wait on Kubernetes until the application is ready by checking the ports to forward to are actually opened (or a timeout expires)

This allows to display port-forwarding messages when the application is ready to accept requests.
Otherwise, if the application takes time to listen on the port,
and we try to reach the local forwarded port, port forwarding will
be restarted.
If we are using --random-ports, new random ports will be generated.

Known issue: with the backo-go exponential backoff implementation,
it seems hitting Ctrl-C does not stop waiting =>
we need to wait until the timeout is reached or the backoff is done.

* Wait on Podman until the application is ready by checking the ports to forward to are actually opened (or a timeout expires)

This allows to display port-forwarding messages when the application is ready to accept requests.
Otherwise, if the application takes time to listen on the port,
and we try to reach the local forwarded port, port forwarding will
be restarted.
If we are using --random-ports, new random ports will be generated.

Known issue: with the backo-go exponential backoff implementation,
it seems hitting Ctrl-C does not stop waiting =>
we need to wait until the timeout is reached or the backoff is done.

* Display warnings instead if the ports are not opened

While iterating on the application, it might feel
weird to stop the Dev Session immediately.
Plus, a lot of integration tests are not passing because
of source code not strictly matching the ports declared in the
(too many) Devfiles.

* Fix integration test checking the behavior when simulating an app taking long to start

* Fix output expected for documentation tests

* Add hint to run 'odo logs --follow [--platform]' to help understand why app is not listening on the expected ports

Co-authored-by: Parthvi Vala <pvala@redhat.com>

* Collect all unreachable ports along with the containers and return the list to the users

Co-authored-by: Parthvi Vala <pvala@redhat.com>

* Apply suggestions from code review

Co-authored-by: Parthvi Vala <pvala@redhat.com>

* fixup! Add hint to run 'odo logs --follow [--platform]' to help understand why app is not listening on the expected ports

* fixup! Add hint to run 'odo logs --follow [--platform]' to help understand why app is not listening on the expected ports

---------

Co-authored-by: Parthvi Vala <pvala@redhat.com>
2023-04-13 11:56:22 -04:00
Parthvi Vala
c57364f8b1 Fix e2e test failures and doc test failures due to updated devfile registry (#6735)
Signed-off-by: Parthvi Vala <pvala@redhat.com>
2023-04-13 07:24:40 -04:00
ritudes
5ec9907fc2 Doc automation:Command Reference: odo create namespace (#6703)
* doc automation files for create namespace command

* test file for of create namespace cmd

* Update docs/website/docs/command-reference/docs-mdx/create-namespace/create_namespace.mdx

Co-authored-by: Parthvi Vala <pvala@redhat.com>

* Update docs/website/docs/command-reference/docs-mdx/create-namespace/create_project.mdx

Co-authored-by: Parthvi Vala <pvala@redhat.com>

* Update tests/documentation/command-reference/doc_command_reference_createnamespace_test.go

Co-authored-by: Parthvi Vala <pvala@redhat.com>

* Update doc_command_reference_createnamespace_test.go

* Adding changes to test file

Signed-off-by: Ritu Deshmukh <rideshmu@redhat.com>

---------

Signed-off-by: Ritu Deshmukh <rideshmu@redhat.com>
Co-authored-by: Parthvi Vala <pvala@redhat.com>
2023-04-10 02:48:48 -04:00
Armel Soro
c2d850fa41 Follow-up to comments on #6654 (support for autoBuild and deployByDefault) (#6720)
* Remove additional non-nil checks on component fields since they are already filtered by type

We are confident that the fields we expect
(comp.{Image,Kubernetes,OpenShift}) are non-nil.

* Rename 'libdevfile.GetImageComponentsToPush' into 'libdevfile.GetImageComponentsToPushAutomatically'

* Document with examples cases where 'deployByDefault' and 'autoBuild' are `false` and the component is not referenced

* Rename 'image-autobuild-true-and-referenced' command into 'image-autobuild-true' in test Devfile

* Simplify parsing the output on Podman in the tests when looking for K8s/OpenShift components

* Use 'source/nodejs' instead of 'source/devfiles/nodejs/project' in the tests

* Revert "Rename 'image-autobuild-true-and-referenced' command into 'image-autobuild-true' in test Devfile"

This reverts commit 65812b857c.
2023-04-07 03:07:43 -04:00
Parthvi Vala
c82583bdc3 Allow users to define custom port-mappings for port forwarding [Kubernetes] (#6704)
* Allow users to define custom port-mappings for port forwarding: add methods to parse and validate  the flag

* Add methods to kube port-forwarding to obtain custom port pairs

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

* Pass custom port-mappings from CLI to Business layer

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

* Add integration test

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add integration test for debug

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add check for using --random-ports and --port-forward together

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Return all validation errors for --port-forward flag at once

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Use random local ports for integration testing

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Fix ci failures

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Print invalids of --port-forward to stderr so that they are printed when debugging

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Attempt at fixing the test failure on windows

Signed-off-by: Parthvi Vala <pvala@redhat.com>

Remove the use of seed for randomzing

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Use global counters for generate port number

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Apply changes from code review

Co-authored-by: Armel Soro <asoro@redhat.com>

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>
Co-authored-by: Philippe Martin <phmartin@redhat.com>
2023-04-06 15:37:36 -04:00
Philippe Martin
7aa336926f Fix problem when odo deploy processes do not terminate (#6716) 2023-04-05 03:14:22 -04:00