Implement API endpoints#6915
Conversation
✅ Deploy Preview for odo-docusaurus-preview ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
valaparthvi
left a comment
There was a problem hiding this comment.
The normal workflow works well for me, but I am unable to run parallel sessions on mac:
$ ODO_EXPERIMENTAL_MODE=t odo dev --api-server
============================================================================
⚠ Experimental mode enabled. Use at your own risk.
More details on https://odo.dev/docs/user-guides/advanced/experimental-mode
============================================================================
__
/ \__ Developing using the "my-go-app" Devfile
\__/ \ Namespace: default
/ \__/ odo version: v3.11.0
\__/
⚠ You are using "default" namespace, odo may not work as expected in the default namespace.
⚠ You may set a new namespace by running `odo create namespace <name>`, or set an existing one by running `odo set namespace <name>`
↪ Running on the cluster in Dev mode
I0621 16:41:04.909656 22390 starterserver.go:58] API Server started at localhost:20000/api/v1
I0621 16:41:04.909831 22390 starterserver.go:78] Stopping the API server; encountered error: listen tcp :20000: bind: address already in use
Cleaning resources, please wait
✗ error watching deployment: context canceled
$ ODO_EXPERIMENTAL_MODE=t odo dev --api-server --platform podman
============================================================================
⚠ Experimental mode enabled. Use at your own risk.
More details on https://odo.dev/docs/user-guides/advanced/experimental-mode
============================================================================
__
/ \__ Developing using the "my-go-app" Devfile
\__/ \ Platform: podman
/ \__/ odo version: v3.11.0
\__/
↪ Running on podman in Dev mode
I0621 16:44:09.646006 22887 starterserver.go:58] API Server started at localhost:20000/api/v1
I0621 16:44:09.646188 22887 starterserver.go:78] Stopping the API server; encountered error: listen tcp :20000: bind: address already in use
✓ Deploying pod [8s]
✗ Syncing files into the container [4ms]
Error occurred on Push - failed to sync to component with name my-go-app: unable to exec command [rm -rf /projects/*]: context canceled
↪ Dev mode
Status:
Watching for changes in the current directory /tmp/nodejs-debug
Keyboard Commands:
[Ctrl+c] - Exit and delete resources from podman
[p] - Manually apply local changes to the application on podman
Cleaning up resources
✗ Dev mode interrupted by userI think it again has to do with the fact that mac believes a port is free even if it is in use.
Perhaps we can add an --api-address flag in the future iterations.
Also, cluster was very quick in terminating the session, but podman took a while to terminate the session when context was cancelled.
cc6c329 to
42b55b4
Compare
| s.pushWatcher <- struct{}{} | ||
| return openapi.Response(http.StatusOK, nil), nil | ||
| default: | ||
| return openapi.Response(http.StatusBadRequest, nil), fmt.Errorf("command name %q not supported. Supported values are: %q", componentCommandPostRequest.Name, "push") |
There was a problem hiding this comment.
Wondering if the response body in case of error should not be serialized as a real JSON string too. Currently, I get a simple string, which does not respect the response content type returned in the response headers:
$ http POST http://127.0.0.1:20002/api/v1/component/command name=fake-cmd
HTTP/1.1 400 Bad Request
Content-Length: 74
Content-Type: application/json; charset=UTF-8
Date: Thu, 22 Jun 2023 15:45:12 GMT
"command name \"fake-cmd\" not supported. Supported values are: \"push\""
I'd expect something like below. What do you think?
{
"message": "command name \"fake-cmd\" not supported. Supported values are: \"push\""
}There was a problem hiding this comment.
I think we will need to complete the openapi spec, to define a return code in case of error, a,d to point to the correct GeneralError instead of using the default. WDYT?
| return openapi.Response(http.StatusNotImplemented, nil), errors.New("ComponentCommandPost method not implemented") | ||
| switch componentCommandPostRequest.Name { | ||
| case "push": | ||
| s.pushWatcher <- struct{}{} |
There was a problem hiding this comment.
Also, one thing I just noticed with this: when there is already a 'push' operation in progress (for example, I sent a first POST /component/command request, immediately followed by the same request again), the second request would be blocked waiting for the in-progress push operation to finish (which in my case took a lot of seconds).
Wouldn't it make more sense to return immediately if there is already a 'push' operation?
There was a problem hiding this comment.
Yes, that makes sense. In this case, which status code do we want to return? StatusServiceUnavailable?
There was a problem hiding this comment.
Maybe a 429 Too Many Requests would be relevant, as the user can retry later when there is no other push in progress?
There was a problem hiding this comment.
@feloy Not sure if you saw my previous comment.. What do you think?
There was a problem hiding this comment.
I changed from StatusServiceUnavailable to StatusTooManyRequests.
I think we will need to update the openapi spec for the non 2xx responses, but I would prefer we discuss it before to write it. That could be part of another PR?
There was a problem hiding this comment.
Yes, sure, that can be a separate PR indeed.
c2ca26c to
21d656c
Compare
Co-authored-by: Armel Soro <[email protected]>
554d20b to
a8bd866
Compare
|
Kudos, SonarCloud Quality Gate passed!
|
|
/override Kubernetes-Integration-Tests/Kubernetes-Integration-Tests |
|
@feloy: Overrode contexts on behalf of feloy: Kubernetes-Integration-Tests/Kubernetes-Integration-Tests DetailsIn 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. |








What type of PR is this:
/kind feature
What does this PR do / why we need it:
Which issue(s) this PR fixes:
Fixes #6302
PR acceptance criteria:
Unit test
Integration test
Documentation
How to test changes / Special notes to the reviewer: