MCPcopy Index your code
hub / github.com/cloudtty/cloudtty / syncHandler

Method syncHandler

pkg/controllers/cloudshell_controller.go:257–290  ·  view source on GitHub ↗
(ctx context.Context, key string)

Source from the content-addressed store, hash-verified

255}
256
257func (c *Controller) syncHandler(ctx context.Context, key string) (*time.Duration, error) {
258 klog.V(4).Infof("Reconciling cloudshell %s", key)
259 startTime := time.Now()
260 defer func() {
261 klog.V(4).Infof("Finished syncing %q (%v)", key, time.Since(startTime))
262 }()
263
264 ns, name, err := cache.SplitMetaNamespaceKey(key)
265 if err != nil {
266 return nil, err
267 }
268
269 cloudShell, err := c.lister.CloudShells(ns).Get(name)
270 if err != nil {
271 if apierrors.IsNotFound(err) {
272 klog.V(2).InfoS("Skip syncing, cloudshell not found", "cloudshell", key)
273 return nil, nil
274 }
275
276 return nil, err
277 }
278
279 if !cloudShell.DeletionTimestamp.IsZero() {
280 return nil, c.removeCloudshell(ctx, cloudShell)
281 }
282
283 // as we not have webhook to init some necessary feild to cloudshell.
284 // fill this default values to cloudshell after calling "syncCloudShell".
285 if err := c.ensureCloudShell(ctx, cloudShell); err != nil {
286 return nil, err
287 }
288
289 return c.syncCloudShell(ctx, cloudShell)
290}
291
292func (c *Controller) syncCloudShell(ctx context.Context, cloudshell *cloudshellv1alpha1.CloudShell) (*time.Duration, error) {
293 t := nextRequeueTimeDuration(cloudshell)

Callers 1

processNextItemMethod · 0.95

Calls 5

removeCloudshellMethod · 0.95
ensureCloudShellMethod · 0.95
syncCloudShellMethod · 0.95
GetMethod · 0.65
CloudShellsMethod · 0.65

Tested by

no test coverage detected