(ctx context.Context, cloudshell *cloudshellv1alpha1.CloudShell)
| 899 | } |
| 900 | |
| 901 | func (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 |
| 929 | func (c *Controller) ResetWorker(_ context.Context, cloudshell *cloudshellv1alpha1.CloudShell) error { |
no test coverage detected