(r *createContainerRequest)
| 232 | } |
| 233 | |
| 234 | func (c *criService) createContainer(r *createContainerRequest) (_ string, retErr error) { |
| 235 | span := tracing.SpanFromContext(r.ctx) |
| 236 | // Create container root directory. |
| 237 | containerRootDir := c.getContainerRootDir(r.containerID) |
| 238 | if err := c.os.MkdirAll(containerRootDir, 0755); err != nil { |
| 239 | return "", fmt.Errorf( |
| 240 | "failed to create container root directory %q: %w", |
| 241 | containerRootDir, |
| 242 | err, |
| 243 | ) |
| 244 | } |
| 245 | defer func() { |
| 246 | if retErr != nil { |
| 247 | // Cleanup the container root directory. |
| 248 | if err := c.os.RemoveAll(containerRootDir); err != nil { |
| 249 | log.G(r.ctx).WithError(err).Errorf( |
| 250 | "Failed to remove container root directory %q", |
| 251 | containerRootDir, |
| 252 | ) |
| 253 | } |
| 254 | } |
| 255 | }() |
| 256 | volatileContainerRootDir := c.getVolatileContainerRootDir(r.containerID) |
| 257 | if err := c.os.MkdirAll(volatileContainerRootDir, 0755); err != nil { |
| 258 | return "", fmt.Errorf( |
| 259 | "failed to create volatile container root directory %q: %w", |
| 260 | volatileContainerRootDir, |
| 261 | err, |
| 262 | ) |
| 263 | } |
| 264 | defer func() { |
| 265 | if retErr != nil { |
| 266 | // Cleanup the volatile container root directory. |
| 267 | if err := c.os.RemoveAll(volatileContainerRootDir); err != nil { |
| 268 | log.G(r.ctx).WithError(err).Errorf( |
| 269 | "Failed to remove volatile container root directory %q", |
| 270 | volatileContainerRootDir, |
| 271 | ) |
| 272 | } |
| 273 | } |
| 274 | }() |
| 275 | |
| 276 | platform, err := c.sandboxService.SandboxPlatform(r.ctx, r.sandbox.Sandboxer, r.sandboxID) |
| 277 | if err != nil { |
| 278 | return "", fmt.Errorf("failed to query sandbox platform: %w", err) |
| 279 | } |
| 280 | ociRuntime, err := c.getPodSandboxRuntime(r.sandboxID) |
| 281 | if err != nil { |
| 282 | return "", fmt.Errorf("failed to get sandbox runtime: %w", err) |
| 283 | } |
| 284 | |
| 285 | // mutate the extra CRI volume mounts from the runtime spec to properly specify the OCI image volume mount requests as bind mounts for this container |
| 286 | err = c.mutateMounts(r.ctx, r.containerConfig.GetMounts(), c.RuntimeSnapshotter(r.ctx, ociRuntime), r.sandboxID, platform) |
| 287 | if err != nil { |
| 288 | return "", fmt.Errorf("failed to mount image volume: %w", err) |
| 289 | } |
| 290 | |
| 291 | var volumeMounts []*runtime.Mount |
no test coverage detected