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

Method Run

pkg/controllers/cloudshell_controller.go:219–255  ·  view source on GitHub ↗
(workers int, stopCh <-chan struct{})

Source from the content-addressed store, hash-verified

217}
218
219func (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
257func (c *Controller) syncHandler(ctx context.Context, key string) (*time.Duration, error) {
258 klog.V(4).Infof("Reconciling cloudshell %s", key)

Callers 1

execCommandFunction · 0.45

Calls 4

workerMethod · 0.95
WaitForCacheSyncMethod · 0.65
ListMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected