Skip to content
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

Implement API endpoints #6915

Conversation

feloy
Copy link
Contributor

@feloy feloy commented Jun 19, 2023

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:

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Jun 19, 2023
@netlify
Copy link

netlify bot commented Jun 19, 2023

Deploy Preview for odo-docusaurus-preview ready!

Name Link
🔨 Latest commit cbb362d
🔍 Latest deploy log https://app.netlify.com/sites/odo-docusaurus-preview/deploys/64998832a822160008ff33e3
😎 Deploy Preview https://deploy-preview-6915--odo-docusaurus-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@openshift-ci openshift-ci bot added the kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation label Jun 19, 2023
@openshift-ci openshift-ci bot requested review from anandrkskd and valaparthvi June 19, 2023 14:58
@odo-robot
Copy link

odo-robot bot commented Jun 19, 2023

OpenShift Unauthenticated Tests on commit e30e203 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Jun 19, 2023

NoCluster Tests on commit e30e203 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Jun 19, 2023

Unit Tests on commit e30e203 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Jun 19, 2023

Validate Tests on commit e30e203 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Jun 19, 2023

Windows Tests (OCP) on commit e30e203 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Jun 19, 2023

Kubernetes Tests on commit e30e203 finished with errors.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Jun 19, 2023

OpenShift Tests on commit e30e203 finished successfully.
View logs: TXT HTML

@feloy feloy closed this Jun 20, 2023
@feloy feloy reopened this Jun 20, 2023
@odo-robot
Copy link

odo-robot bot commented Jun 20, 2023

Kubernetes Docs Tests on commit 4b9c89e finished with errors.
View logs: TXT HTML

@feloy feloy changed the title [wip] Implement API endpoints Implement API endpoints Jun 20, 2023
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Jun 20, 2023
Copy link
Contributor

@valaparthvi valaparthvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 user

I 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.

pkg/apiserver-impl/api_default_service.go Show resolved Hide resolved
pkg/dev/interface.go Show resolved Hide resolved
tests/integration/cmd_dev_api_server_test.go Show resolved Hide resolved
tests/integration/cmd_dev_api_server_test.go Show resolved Hide resolved
tests/integration/cmd_dev_api_server_test.go Show resolved Hide resolved
tests/integration/cmd_dev_api_server_test.go Show resolved Hide resolved
@feloy feloy force-pushed the feature-6302/api-endpoints-impl-main branch from cc6c329 to 42b55b4 Compare June 21, 2023 15:45
@feloy feloy closed this Jun 22, 2023
@feloy feloy reopened this Jun 22, 2023
@feloy feloy closed this Jun 22, 2023
@feloy feloy reopened this Jun 22, 2023
pkg/component/describe/describe.go Outdated Show resolved Hide resolved
pkg/component/describe/describe.go Outdated Show resolved Hide resolved
pkg/apiserver-impl/api_default_service.go Outdated Show resolved Hide resolved
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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\""
}

Copy link
Contributor Author

@feloy feloy Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that makes sense.

@rm3l rm3l added the area/dev Issues or PRs related to `odo dev` label Jun 22, 2023
return openapi.Response(http.StatusNotImplemented, nil), errors.New("ComponentCommandPost method not implemented")
switch componentCommandPostRequest.Name {
case "push":
s.pushWatcher <- struct{}{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

@feloy feloy Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that makes sense. In this case, which status code do we want to return? StatusServiceUnavailable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a 429 Too Many Requests would be relevant, as the user can retry later when there is no other push in progress?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@feloy Not sure if you saw my previous comment.. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sure, that can be a separate PR indeed.

@feloy feloy force-pushed the feature-6302/api-endpoints-impl-main branch 2 times, most recently from c2ca26c to 21d656c Compare June 23, 2023 14:33
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jun 23, 2023
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jun 23, 2023
@feloy feloy force-pushed the feature-6302/api-endpoints-impl-main branch from 554d20b to a8bd866 Compare June 25, 2023 18:31
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jun 25, 2023
@feloy feloy closed this Jun 26, 2023
@feloy feloy reopened this Jun 26, 2023
@feloy feloy closed this Jun 26, 2023
@feloy feloy reopened this Jun 26, 2023
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@feloy
Copy link
Contributor Author

feloy commented Jun 26, 2023

/override Kubernetes-Integration-Tests/Kubernetes-Integration-Tests

 [FAILED] [10.576 seconds]
odo devfile deploy command tests deploying devfile with exec when using devfile where the exec command is bound to fail [It] should print the last 100 lines of the log to the output
/go/odo_1/tests/integration/cmd_devfile_deploy_test.go:648

@openshift-ci
Copy link

openshift-ci bot commented Jun 26, 2023

@feloy: Overrode contexts on behalf of feloy: Kubernetes-Integration-Tests/Kubernetes-Integration-Tests

In response to this:

/override Kubernetes-Integration-Tests/Kubernetes-Integration-Tests

[FAILED] [10.576 seconds]
odo devfile deploy command tests deploying devfile with exec when using devfile where the exec command is bound to fail [It] should print the last 100 lines of the log to the output
/go/odo_1/tests/integration/cmd_devfile_deploy_test.go:648

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.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jun 26, 2023
@openshift-merge-robot openshift-merge-robot merged commit 94e3230 into redhat-developer:main Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dev Issues or PRs related to `odo dev` kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement API Endpoints
4 participants