Skip to content

[Bug]: Race conditions in ContainersService #692

@dkovba

Description

@dkovba

I have done the following

  • I have searched the existing issues
  • If possible, I've reproduced the issue using the 'main' branch of this project

Steps to reproduce

For example:

  1. Create two containers with the same name simultaneously:
#!/bin/bash
bin/container system start &
sleep 2
bin/container delete test-race
bin/container create --name test-race ubuntu &
bin/container create --name test-race ubuntu &
wait

Current behavior

Error: internalError: "failed to create container" (cause: "unknown: "Error Domain=NSCocoaErrorDomain Code=516 ""vmlinux-6.12.28-153" couldn't be copied to "test-race" because an item with the same name already exists." UserInfo={NSSourceFilePathErrorKey=/Users/Dmitry/Library/Application Support/com.apple.container/kernels/vmlinux-6.12.28-153, NSUserStringVariant=(
Copy
), NSDestinationFilePath=/Users/Dmitry/Library/Application Support/com.apple.container/containers/test-race/kernel.bin, NSFilePath=/Users/Dmitry/Library/Application Support/com.apple.container/kernels/vmlinux-6.12.28-153, NSURL=file:///Users/Dmitry/Library/Application%20Support/com.apple.container/kernels/vmlinux-6.12.28-153, NSUnderlyingError=0xc790ec420 {Error Domain=NSPOSIXErrorDomain Code=17 "File exists"}}"")
test-race

Expected behavior

Error: internalError: "failed to create container" (cause: "exists: "container already exists: test-race"")

The likely races that need to be fixed occur in methods:

  • create()
  • createProcess()
  • stop()
  • delete()
  • _cleanup()

The following methods are likely safe:

  • list()
  • kill()
  • dial()
  • wait()
  • resize()
  • cleanup()

Environment

N/A

Relevant log output

N/A

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

nextItems in scope for the next few milestones

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions