[sandbox] Specify sandbox ID when using sandboxed shims
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
		| @@ -252,6 +252,11 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta | |||||||
| 		containerd.WithContainerExtension(containerMetadataExtension, &meta), | 		containerd.WithContainerExtension(containerMetadataExtension, &meta), | ||||||
| 	) | 	) | ||||||
|  |  | ||||||
|  | 	// When using sandboxed shims, containerd's runtime needs to know which sandbox shim instance to use. | ||||||
|  | 	if ociRuntime.SandboxMode == string(criconfig.ModeShim) { | ||||||
|  | 		opts = append(opts, containerd.WithSandbox(sandboxID)) | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	var cntr containerd.Container | 	var cntr containerd.Container | ||||||
| 	if cntr, err = c.client.NewContainer(ctx, id, opts...); err != nil { | 	if cntr, err = c.client.NewContainer(ctx, id, opts...); err != nil { | ||||||
| 		return nil, fmt.Errorf("failed to create containerd container: %w", err) | 		return nil, fmt.Errorf("failed to create containerd container: %w", err) | ||||||
|   | |||||||
| @@ -257,12 +257,15 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox | |||||||
| 		} | 		} | ||||||
| 		return nil, fmt.Errorf("failed to start sandbox %q: %w", id, err) | 		return nil, fmt.Errorf("failed to start sandbox %q: %w", id, err) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// TODO: get rid of this. sandbox object should no longer have Container field. | 	// TODO: get rid of this. sandbox object should no longer have Container field. | ||||||
| 	container, err := c.client.LoadContainer(ctx, id) | 	if ociRuntime.SandboxMode == string(criconfig.ModePodSandbox) { | ||||||
| 	if err != nil { | 		container, err := c.client.LoadContainer(ctx, id) | ||||||
| 		return nil, fmt.Errorf("failed to load container %q for sandbox: %w", id, err) | 		if err != nil { | ||||||
|  | 			return nil, fmt.Errorf("failed to load container %q for sandbox: %w", id, err) | ||||||
|  | 		} | ||||||
|  | 		sandbox.Container = container | ||||||
| 	} | 	} | ||||||
| 	sandbox.Container = container |  | ||||||
|  |  | ||||||
| 	labels := resp.GetLabels() | 	labels := resp.GetLabels() | ||||||
| 	if labels == nil { | 	if labels == nil { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Maksym Pavlenko
					Maksym Pavlenko