MCPcopy Create free account
hub / github.com/cloudtty/cloudtty / removeCloudshell

Method removeCloudshell

pkg/controllers/cloudshell_controller.go:901–926  ·  view source on GitHub ↗
(ctx context.Context, cloudshell *cloudshellv1alpha1.CloudShell)

Source from the content-addressed store, hash-verified

899}
900
901func (c *Controller) removeCloudshell(ctx context.Context, cloudshell *cloudshellv1alpha1.CloudShell) error {
902 worker, err := c.GetBindingWorkerFor(cloudshell)
903 if err != nil {
904 return err
905 }
906
907 if worker != nil {
908 if err = c.ResetWorker(ctx, cloudshell); err != nil {
909 klog.ErrorS(err, "Failed to reset worker", "cloudshell", cloudshell.Name)
910 }
911 if err := c.workerPool.Back(worker); err != nil {
912 klog.ErrorS(err, "Failed to back worker", "cloudshell", cloudshell.Name)
913 return err
914 }
915
916 // delete the label to unbind the worker.
917 delete(cloudshell.Labels, constants.CloudshellPodLabelKey)
918 }
919
920 klog.V(4).InfoS("Delete cloudshell", "cloudshell", klog.KObj(cloudshell))
921 if err := c.removeCloudshellRoute(ctx, cloudshell); err != nil {
922 return err
923 }
924
925 return c.removeFinalizer(cloudshell)
926}
927
928// ResetWorker cleanup the kubeConfig and kill ttyd
929func (c *Controller) ResetWorker(_ context.Context, cloudshell *cloudshellv1alpha1.CloudShell) error {

Callers 2

syncHandlerMethod · 0.95
syncCloudShellMethod · 0.95

Calls 5

GetBindingWorkerForMethod · 0.95
ResetWorkerMethod · 0.95
removeCloudshellRouteMethod · 0.95
removeFinalizerMethod · 0.95
BackMethod · 0.80

Tested by

no test coverage detected