(workers int, stopCh <-chan struct{})
| 217 | } |
| 218 | |
| 219 | func (c *Controller) Run(workers int, stopCh <-chan struct{}) { |
| 220 | defer utilruntime.HandleCrash() |
| 221 | defer c.queue.ShutDown() |
| 222 | |
| 223 | klog.InfoS("Start CloudShell Controller") |
| 224 | defer klog.InfoS("Shutting down CloudShell Controller") |
| 225 | |
| 226 | if !cache.WaitForCacheSync(stopCh, c.cloudshellInformer.HasSynced) { |
| 227 | klog.Errorf("cloudshell manager: wait for cloushell informer factory failed") |
| 228 | } |
| 229 | if !cache.WaitForCacheSync(stopCh, c.podInformer.HasSynced) { |
| 230 | klog.Errorf("cloudshell manager: wait for pod informer factory failed") |
| 231 | } |
| 232 | currentNS := util.GetCurrentNSOrDefault() |
| 233 | configs, err := c.kubeClient.CoreV1().ConfigMaps(currentNS).List(context.TODO(), metav1.ListOptions{LabelSelector: CloudshellConfigMapLabel}) |
| 234 | if err != nil { |
| 235 | klog.ErrorS(err, "failed to list CloudShell ConfigMap") |
| 236 | } else { |
| 237 | if len(configs.Items) > 0 { |
| 238 | c.ttydServiceBufferSize = configs.Items[0].Data["TTYD_SERVER_BUFFER_SIZE"] |
| 239 | c.ttydPingInterval = configs.Items[0].Data["TTYD_PING_INTERVAL"] |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | var wg sync.WaitGroup |
| 244 | for i := 0; i < workers; i++ { |
| 245 | wg.Add(1) |
| 246 | go func() { |
| 247 | defer wg.Done() |
| 248 | c.worker(stopCh) |
| 249 | }() |
| 250 | } |
| 251 | <-stopCh |
| 252 | |
| 253 | c.queue.ShutDown() |
| 254 | wg.Wait() |
| 255 | } |
| 256 | |
| 257 | func (c *Controller) syncHandler(ctx context.Context, key string) (*time.Duration, error) { |
| 258 | klog.V(4).Infof("Reconciling cloudshell %s", key) |
no test coverage detected