pkg/cri/server: experimental NRI integration for CRI.
Implement the adaptation interface required by the NRI service plugin to handle CRI sandboxes and containers. Hook the NRI service plugin into CRI request processing. Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
This commit is contained in:
		| @@ -160,6 +160,24 @@ func (c *criService) StartContainer(ctx context.Context, r *runtime.StartContain | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	defer func() { | ||||
| 		if retErr != nil { | ||||
| 			deferCtx, deferCancel := ctrdutil.DeferContext() | ||||
| 			defer deferCancel() | ||||
| 			err = c.nri.stopContainer(deferCtx, &sandbox, &cntr) | ||||
| 			if err != nil { | ||||
| 				log.G(ctx).WithError(err).Errorf("NRI stop failed for failed container %q", id) | ||||
| 			} | ||||
| 		} | ||||
| 	}() | ||||
| 	if c.nri.isEnabled() { | ||||
| 		err = c.nri.startContainer(ctx, &sandbox, &cntr) | ||||
| 		if err != nil { | ||||
| 			log.G(ctx).WithError(err).Errorf("NRI container start failed") | ||||
| 			return nil, fmt.Errorf("NRI container start failed: %w", err) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// Start containerd task. | ||||
| 	if err := task.Start(ctx); err != nil { | ||||
| 		return nil, fmt.Errorf("failed to start containerd task %q: %w", id, err) | ||||
| @@ -177,6 +195,13 @@ func (c *criService) StartContainer(ctx context.Context, r *runtime.StartContain | ||||
| 	// It handles the TaskExit event and update container state after this. | ||||
| 	c.eventMonitor.startContainerExitMonitor(context.Background(), id, task.Pid(), exitCh) | ||||
|  | ||||
| 	if c.nri.isEnabled() { | ||||
| 		err = c.nri.postStartContainer(ctx, &sandbox, &cntr) | ||||
| 		if err != nil { | ||||
| 			log.G(ctx).WithError(err).Errorf("NRI post-start notification failed") | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	containerStartTimer.WithValues(info.Runtime.Name).UpdateSince(start) | ||||
|  | ||||
| 	return &runtime.StartContainerResponse{}, nil | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Krisztian Litkey
					Krisztian Litkey