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

feat: add workspace:delete command #586

Merged
merged 7 commits into from
Mar 19, 2020
Merged

feat: add workspace:delete command #586

merged 7 commits into from
Mar 19, 2020

Conversation

tolusha
Copy link
Collaborator

@tolusha tolusha commented Mar 18, 2020

What does this PR do?

Allows to delete user's workspace and namespace.
Use should have cluster admin rights to delete namespaces

$ ./run workspace:list -n abazkoche --access-token=$CHE_ACCESS_TOKEN
  ✔ Verify Kubernetes API...OK (it's OpenShift)
  ✔ Verify if namespace 'abazkoche' exists
  ✔ Retrieving Eclipse Che server URL... http://che-abazkoche.apps.ocp43.codereadyqe.com
  ✔ Eclipse Che status check
  ✔ Get workspaces... done
Id                        Name                          Namespace Status  Created                  Updated                  
workspace0kxaqsiwpe2h77g2 apache-camel-springboot-m83c3 admin-che STOPPED 2020-03-18T14:56:51.675Z                          
workspace8d7pzoq23h9iffiw golang-g2rp3                  admin-che STOPPED 2020-03-18T14:57:03.415Z 2020-03-18T14:57:05.404Z 
 $ ./run workspace:delete -n abazkoche --access-token=$CHE_ACCESS_TOKEN -w workspace0kxaqsiwpe2h77g2
  ✔ Verify Kubernetes API...OK (it's OpenShift)
  ✔ Verify if namespace 'abazkoche' exists
  ✔ Retrieving Eclipse Che server URL... http://che-abazkoche.apps.ocp43.codereadyqe.com
  ✔ Eclipse Che status check
  ✔ Get workspace with id 'workspace0kxaqsiwpe2h77g2'... done
  ✔ Delete workspace with id 'workspace0kxaqsiwpe2h77g2'... done
  ✔ Verify if namespace exists 'admin-che'... found
  ✔ Delete namespace 'admin-che'... done
$ ./run workspace:delete -n abazkoche --access-token=$CHE_ACCESS_TOKEN -w workspace8d7pzoq23h9iffiw
  ✔ Verify Kubernetes API...OK (it's OpenShift)
  ✔ Verify if namespace 'abazkoche' exists
  ✔ Retrieving Eclipse Che server URL... http://che-abazkoche.apps.ocp43.codereadyqe.com
  ✔ Eclipse Che status check
  ✔ Get workspace with id 'workspace8d7pzoq23h9iffiw'... done
  ✔ Delete workspace with id 'workspace8d7pzoq23h9iffiw'... done
  ✔ Verify if namespace exists 'admin-che'... not found
  ↓ Delete namespace [skipped]

What issues does this PR fix or reference?

eclipse-che/che#16236

tolusha added 3 commits March 17, 2020 16:18
Signed-off-by: Anatoliy Bazko <[email protected]>
Signed-off-by: Anatoliy Bazko <[email protected]>
Signed-off-by: Anatoliy Bazko <[email protected]>
@tolusha tolusha changed the title Ab/delete feat: add workspace:delete command Mar 18, 2020
}
})
tasks.add({
title: 'Delete namespace',
Copy link
Contributor

Choose a reason for hiding this comment

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

Hello. @tolusha workspace can be configured to start workspace with the same namespace with Che...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes. that's why I check

skip: ctx => ctx.infrastructureNamespace === flags.chenamespace,

if it is the same namespace then I won't delete it

@sleshchenko
Copy link
Contributor

@tolusha Are we able to avoid having parameter to the main argument - identifier?
Like kubectl/oc does with everything: oc get pod my-pod-name...
I wonder if we could do the same: chectl workspace:delete workspace123923 -n myche or even chectl workspace:delete username/java-mysql -n myche 🚀

@sleshchenko
Copy link
Contributor

>  $ ./run workspace:delete -n abazkoche --access-token=$CHE_ACCESS_TOKEN -w workspace0kxaqsiwpe2h77g2
  ✔ Verify Kubernetes API...OK (it's OpenShift)
  ✔ Verify if namespace 'abazkoche' exists
  ✔ Retrieving Eclipse Che server URL... http://che-abazkoche.apps.ocp43.codereadyqe.com
  ✔ Eclipse Che status check
  ✔ Get workspace with id 'workspace0kxaqsiwpe2h77g2'... done
  ✔ Delete workspace with id 'workspace0kxaqsiwpe2h77g2'... done
  ✔ Verify if namespace exists 'admin-che'... found
  ✔ Delete namespace 'admin-che'... done

Is admin-che namespace read from workspace configuration?
⚠️ I'm not sure if we need even try to delete namespace, maybe only when user specify additional parameter... Like admin-che namespace is reused for every admin's namespace. So, it mean that every namespace lose their PVC

@tolusha
Copy link
Collaborator Author

tolusha commented Mar 19, 2020

@sleshchenko

Are we able to avoid having parameter to the main argument - identifier?

That's not possible due to underlying cli tool

@sleshchenko
Copy link
Contributor

That's not possible due to underlying cli tool

@tolusha Are you sure? Seems we just haven't used it before but it's possible. It's called argument while we use only flags https://oclif.io/docs/args

@tolusha
Copy link
Collaborator Author

tolusha commented Mar 19, 2020

That's much better

$ ./run workspace:list
Id                        Name      Namespace Status  Created                  Updated                  
workspaceisyay7xhi8euo94t wksp-r1ua che-che   STOPPED 2020-03-19T08:55:23.414Z 2020-03-19T08:55:24.392Z 
$ ./run workspace:delete -w workspaceisyay7xhi8euo94t --delete-namespace
Workspace with id 'workspaceisyay7xhi8euo94t' deleted.
Namespace 'che-che' deleted.

tolusha added 2 commits March 19, 2020 10:59
Signed-off-by: Anatoliy Bazko <[email protected]>
Signed-off-by: Anatoliy Bazko <[email protected]>
@tolusha
Copy link
Collaborator Author

tolusha commented Mar 19, 2020

@sleshchenko

It's called argument

agree, it is possible. Not sure if it is good practice to use arguments for one command and flags for another. We should be consistent.

Copy link
Contributor

@sleshchenko sleshchenko left a comment

Choose a reason for hiding this comment

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

I still believe argument it's a good thing to consider to be implemented in a perspective of workspace:delete command, but I'm OK with the current state as well.

tolusha added 2 commits March 19, 2020 16:05
Signed-off-by: Anatoliy Bazko <[email protected]>
Signed-off-by: Anatoliy Bazko <[email protected]>
@tolusha
Copy link
Collaborator Author

tolusha commented Mar 19, 2020

[test]

@tolusha
Copy link
Collaborator Author

tolusha commented Mar 19, 2020

@sleshchenko
agreed

@tolusha tolusha merged commit a3c72dc into master Mar 19, 2020
@tolusha tolusha deleted the ab/delete branch March 19, 2020 15:41
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