(ctx context.Context, key string)
| 255 | } |
| 256 | |
| 257 | func (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 | |
| 292 | func (c *Controller) syncCloudShell(ctx context.Context, cloudshell *cloudshellv1alpha1.CloudShell) (*time.Duration, error) { |
| 293 | t := nextRequeueTimeDuration(cloudshell) |
no test coverage detected