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

Fix editor update flow #1310

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Fix editor update flow #1310

wants to merge 2 commits into from

Conversation

olexii4
Copy link
Contributor

@olexii4 olexii4 commented Feb 4, 2025

What does this PR do?

This PR fixes the editor update flow and changes the approach of how to store editorYamlUrl variable in the devworkspace.metadata.annotations[REGISTRY_URL].
The existing implementation allows using editorId instead of URL.
With these changes, a correct API request http://127.0.0.1:8080/dashboard/api/editors/devfile?che-editor=${editorId} will be stored instead of an editorID.

What issues does this PR fix or reference?

fixes https://issues.redhat.com/browse/CRW-7936

Is it tested? How?

  1. Deploy Eclipse-Che with the image from this PR.
  2. Create a new workspace from the source:
https://github.com/eclipse-che/che-dashboard.git
  1. Stop the workspace. Open Swagger: {che-server}/dashboard/api/swagger.
    Use Devworkspace Template API and find the templateName.
  2. Modify(remove field /spec/commands) the target template with the next patch:
[
  {
    "op": "replace",
    "path": "/spec/commands",
    "value": []
  }
]
  1. Check the target template. The field /spec/commands should be empty.
  2. Start the target workspace. Check the additional request with the template/spec data:
    Знімок екрана 2025-02-04 о 01 47 16
  3. Check the target template. The field /spec/commands should be restored.

Signed-off-by: Oleksii Orel <[email protected]>
Copy link

openshift-ci bot commented Feb 4, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: olexii4

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@che-bot
Copy link
Contributor

che-bot commented Feb 4, 2025

Click here to review and test in web IDE: Contribute

@olexii4 olexii4 requested a review from svor February 4, 2025 00:14
Copy link

github-actions bot commented Feb 4, 2025

Docker image build succeeded: quay.io/eclipse/che-dashboard:pr-1310

kubectl patch command
kubectl patch -n eclipse-che "checluster/eclipse-che" --type=json -p="[{"op": "replace", "path": "/spec/components/dashboard/deployment", "value": {containers: [{image: "quay.io/eclipse/che-dashboard:pr-1310", name: che-dashboard}]}}]"

Copy link

codecov bot commented Feb 4, 2025

Codecov Report

Attention: Patch coverage is 81.96721% with 11 lines in your changes missing coverage. Please review.

Project coverage is 91.67%. Comparing base (1635623) to head (53628ab).

Files with missing lines Patch % Lines
...orkspace-client/devworkspace/devWorkspaceClient.ts 79.24% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1310      +/-   ##
==========================================
- Coverage   91.68%   91.67%   -0.01%     
==========================================
  Files         500      500              
  Lines       45482    45512      +30     
  Branches     3164     3178      +14     
==========================================
+ Hits        41700    41724      +24     
- Misses       3754     3756       +2     
- Partials       28       32       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

return Object.assign({ content: dump(editor), editorYamlUrl: editorIdOrPath });
return {
content: dump(editor),
editorYamlUrl: `http://127.0.0.1:8080/dashboard/api/editors/devfile?che-editor=${editorId}`,
Copy link
Member

Choose a reason for hiding this comment

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

@olexii4 could you clarify this change please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ibuziuk The previous implementation allowed assigning editorId to a field named "editorYamlUrl". Based on the variable name 'editorYamlUrl', it is unexpected to have the value editorId there.

This misunderstanding led to an error. That is why I changed the implementation to use URLs instead of IDs.

This URL http://127.0.0.1:8080/dashboard/api/editors/devfile?che-editor=${editorId} is a part of dashboard API, which returns the editor devfile by ID. You can test it with dashboard swagger:

For example, an HTTP POST request {che-server}/dashboard/api/data/resolver with JSON data

{
  "url": "http://127.0.0.1:8080/dashboard/api/editors/devfile?che-editor=che-incubator/che-code/latest"
}

Знімок екрана 2025-02-04 о 15 27 15

PS
This request will be sent if we don't have the proper editor in the redux store.

@ibuziuk ibuziuk requested a review from dmytro-ndp February 4, 2025 15:14
Copy link
Contributor

@svor svor left a comment

Choose a reason for hiding this comment

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

@olexii4
I've tested the PR according to the description, and it works as expected.
Could you clarify the root cause of why the template wasn't patched with editorId?

Based on the variable name 'editorYamlUrl', it is unexpected to have the value editorId there.

I’d prefer to avoid hardcoding the API URL here. Would it make sense to rename the variable while still using editorId?

}

if (plugin === undefined) {
console.warn('Failed to get plugin');
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe editor not plugin

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 have fixed it.

const annotations = {
[COMPONENT_UPDATE_POLICY]: 'managed',
[REGISTRY_URL]: editorReference,
[REGISTRY_URL]: `http://127.0.0.1:8080/dashboard/api/editors/devfile?che-editor=${match[1]}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd move http://127.0.0.1:8080/dashboard/api/editors/devfile?che-editor= into a const, maybe EDITOR_DEVFILE_API_QUERY

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 have fixed it.

Copy link

github-actions bot commented Feb 5, 2025

Docker image build succeeded: quay.io/eclipse/che-dashboard:pr-1310

kubectl patch command
kubectl patch -n eclipse-che "checluster/eclipse-che" --type=json -p="[{"op": "replace", "path": "/spec/components/dashboard/deployment", "value": {containers: [{image: "quay.io/eclipse/che-dashboard:pr-1310", name: che-dashboard}]}}]"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants