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

chectl commands in the devworkspace land #20671

Closed
Tracked by #20830
tolusha opened this issue Oct 20, 2021 · 17 comments
Closed
Tracked by #20830

chectl commands in the devworkspace land #20671

tolusha opened this issue Oct 20, 2021 · 17 comments
Labels
area/chectl Issues related to chectl, the CLI of Che kind/task Internal things, technical debt, and to-do tasks to be performed. severity/P1 Has a major impact to usage or development of the system.
Milestone

Comments

@tolusha
Copy link
Contributor

tolusha commented Oct 20, 2021

Is your task related to a problem? Please describe

When devworkspace is enabled by default then some workspace commands won't work.
We have to decided what to do with them

command(s) status plan
auth broken drop
cacert work keep
dashboard work keep
devfile broken dropped
server:backup broken fixed
server:restore broken to fix
server:update work keep
server:debug work keep
server:delete work keep
server:deploy work keep
server:logs not complete to fix
server:start work keep
server:status work keep
server:stop work keep
server:update work keep
all workspace commands broken drop

Describe the solution you'd like

Make a plan for every not working command with devworkspace engine either to remove or fix.

Describe alternatives you've considered

No response

Additional context

#20010

@tolusha tolusha added kind/task Internal things, technical debt, and to-do tasks to be performed. sprint/next severity/P1 Has a major impact to usage or development of the system. area/chectl Issues related to chectl, the CLI of Che team/deploy labels Oct 20, 2021
@tolusha
Copy link
Contributor Author

tolusha commented Nov 29, 2021

Issue to close: #13785

@dmytro-ndp
Copy link
Contributor

@tolusha: our Happy path tests and CRW E2E tests are widely using next workspace commands [1]:

  • workspace:start
  • workspace:stop
  • workspace:delete
  • workspace:list

So, could you continue supporting those commands from chectl?

[1] https://gitlab.cee.redhat.com/codeready-workspaces/crw-jenkins/-/blob/master/vars/crwctlUtil.groovy

@tolusha
Copy link
Contributor Author

tolusha commented Dec 1, 2021

auth and workspace commands doesn't work with devworkspace.
We can keep them for a while (for testing purpose) and then remove anyway.
Deploy and QE team will have to adjust their tests not to use those commands

@tolusha
Copy link
Contributor Author

tolusha commented Dec 6, 2021

Droping chectl commands will be done here [1]

[1] #20866

@kpiwko
Copy link

kpiwko commented Dec 7, 2021

@tolusha based on #20010 exploration, do you happen to know what is the feature parity in between chectl and k8 APIs?

@tolusha
Copy link
Contributor Author

tolusha commented Dec 8, 2021

Hello
@kpiwko

chectl is different tool than kubectl.
It is uses to deploy Eclipse Che but kubectl is used to interact with k8s cluster.

@kpiwko
Copy link

kpiwko commented Dec 8, 2021

I get that @tolusha, thanks. My point was whether to-be-removed functionality of chectl can be replace with kubectl. It is essential that any changes won't cause some functionality to be available only through UI, as this causes significant overhead during testing.

An ask to replace used chectl functionality in in the test suites because of removing functionality there is valid and just needs to be accounted in efforts to deliver these changes in chectl. However if such changes would require using UI to test Che, it is a no-go and this task should be updated to cover that gap.

cc @dmytro-ndp @rhopp

@rhopp
Copy link
Contributor

rhopp commented Dec 8, 2021

What I think would help us greatly is to have an instructions on how to create/start/list workspaces using "any" API.
I have rough idea how to do that, but I'm still missing some pieces of the puzzle. And please correct me if I'm wrong on anything
For listing workspaces & their state we can use k8s api and query for DevWorkspace CR's.
For creation & operatrions on workspaces (start,stop, ...), we could use k8s api to create/edit DevWorkspace CRs to create/edit workspace, but we need to create the workspace from Devfile.
So what I'm missing right now is some clear instructions on how to convert Devfile(v2) to DevWorkspace. Florent already pointed me to code, which is doing such conversion. But even though it's not very complicated - it's also not trivial. Maybe we could have this functionality exposed as a API on dashboard? (or... maybe it already is, I just don't know about it?)
@dmytro-ndp Do we need anything else?

@tolusha
Copy link
Contributor Author

tolusha commented Dec 9, 2021

@akurinnoy
Could you help us with k8s API requests to create/start/stop/list devfile 2.0 workspaces?

@benoitf
Copy link
Contributor

benoitf commented Dec 9, 2021

@nickboldt
Copy link
Contributor

For the simplest case of create the workspace from Devfile -- could we not curl the factory URL and have that flow create the workspace? That way we're testing an actually recommended customer user story and might discover problems w/ passing parameters or page refresh bugs...

For the other commands like stop, delete and list I would expect there are simple oc or even odo commands we use.

@l0rd
Copy link
Contributor

l0rd commented Dec 14, 2021

An alternative to @nickboldt proposal to use an HTTP request to start the workspace (that can be complicated if devfile->devworkspace conversion is still done client side cc @benoitf @olexii4) is to use the DW CRs included in Che devfile registry.

Create the workspaces namespace (optional)

This step is required if the Che user hasn't logged in yet. The first time a user open the User Dashboard, a namespace with some particular annotations/labels is created. So if this namespace doesn't exist it should be created:

CHE_USER_NAME="kube:admin"
CHE_USER_NAMESPACE="che-workspaces"
kubectl apply - <<EOF
apiVersion: v1
kind: Namespace
metadata:
  annotations:
    che.eclipse.org/username: "${CHE_USER_NAME}"
  labels:
    app.kubernetes.io/component: workspaces-namespace"
    app.kubernetes.io/part-of: che.eclipse.org
  name: ${CHE_USER_NAMESPACE}"
EOF

Start a workspace

⚠️ UPDATE2: the following command doesn't work out of the box, the devworkspacerouting needs to be patched. I need to find an easy way to do that or open a specific issue to make this scenario easier to run for QE. I updated the instructions to start the workspace via command line. Note that today the dashboard injects a user kubeconfig in the workspace containers too (PR) and the following commands don't do that (although it should be easy to do that via command line too.)

REGISTRY_URL="https://eclipse-che.github.io/che-devfile-registry/main"
CHE_SAMPLE="nodejs"
CHE_EDITOR="che-theia-next"
DW="nodejs-web-app"
DWT="theia-ide-${DW}"

# Set the namespace to be CHE_USER_NAMESPACE
CHE_USER_NAMESPACE="che-workspaces"
kubens "${CHE_USER_NAMESPACE}"

# Create the editor DevWorkspaceTemplate
curl -sSL ${REGISTRY_URL}/devfiles/${CHE_SAMPLE}/devworkspace-${CHE_EDITOR}.yaml | yq --arg DWT ${DWT} 'select(.metadata.name == $DWT)' | kubectl apply -f -

# Create the DevWorkspace itself
curl -sSL ${REGISTRY_URL}/devfiles/${CHE_SAMPLE}/devworkspace-${CHE_EDITOR}.yaml | yq --arg DW ${DW} 'select(.metadata.name == $DW)' | jq '. * {spec: {routingClass: "che"}}' | kubectl apply -f -

# Wait until it's started
k wait --for=jsonpath='{.status.phase}'=Running dw/${DW} --timeout=-1s

List workspaces

k get dw 

Stop an existing workspace

k patch dw ${DW} -p '{"spec":{"started":false}}' --type=merge
k wait --for=jsonpath='{.status.phase}'=Stopped dw/${DW}

Restart an existing workspace

k patch dw ${DW} -p '{"spec":{"started":true}}' --type=merge
k wait --for=jsonpath='{.status.phase}'=Running dw/${DW}

@kpiwko
Copy link

kpiwko commented Dec 15, 2021

Thank you @benoitf @l0rd @nickboldt . @dmytro-ndp would it meet team needs once devworkspacerouting is patched?

@dmytro-ndp
Copy link
Contributor

dmytro-ndp commented Dec 19, 2021

@kpiwko: thanks for heads up.
Hope, @l0rd will find an easy way or open a specific issue to make suggested scenarios easier to run in E2E tests.

@l0rd, @benoitf , @nickboldt: thank you for help!

@benoitf
Copy link
Contributor

benoitf commented Dec 20, 2021

I think that if you're adding .spec.routingClass: che on the prebuilt devWorkspace yaml it should work

...
spec:
  ....
  routingClass: che
...  

@benoitf
Copy link
Contributor

benoitf commented Dec 21, 2021

moving issue to 7.42 milestone as this issue is part of the endgame

@l0rd
Copy link
Contributor

l0rd commented Jan 10, 2022

@dmytro-ndp I have update the instructions to start a workspace

max-cx added a commit to max-cx/chectl that referenced this issue Feb 10, 2022
Removing `$ crwctl workspace:start --devfile` from the *Usage* section because according to eclipse-che/che#20671:
command(s)                            status 	plan
------------------------------------------------------------
all `workspace` commands 	broken 	drop
max-cx added a commit to max-cx/codeready-workspaces-chectl that referenced this issue Feb 10, 2022
Removing `$ crwctl workspace:start --devfile` from the *# Usage* section because according to eclipse-che/che#20671 `all workspace commands | broken | drop`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/chectl Issues related to chectl, the CLI of Che kind/task Internal things, technical debt, and to-do tasks to be performed. severity/P1 Has a major impact to usage or development of the system.
Projects
None yet
Development

No branches or pull requests

7 participants