Skip to content

add support for shm_size - #567

Open
madejackson wants to merge 3 commits into
azukaar:unstablefrom
aseracorp:shm_size
Open

add support for shm_size#567
madejackson wants to merge 3 commits into
azukaar:unstablefrom
aseracorp:shm_size

Conversation

@madejackson

Copy link
Copy Markdown
Contributor

This PR enables support for shm_size in servapps.

I tested it on my system and also tested if it works for imports and backups, and it does.

shm_size was an integer byte count (int64), but docker-compose specifies
it as a {amount}{unit} byte-size string (e.g. "64mb", "1gb"). Align
Cosmos with the upstream docker behavior:

- src/docker/api_blueprint.go: ContainerCreateRequestContainer.ShmSize is now
  a string; parse to raw bytes via units.RAMInBytes at create time (mirroring
  mem_limit/mem_reservation).
- src/docker/export.go: format the daemon's raw byte count back to a compact
  byte-size string on export so round-trips behave the same.
- client docker-compose.jsx: stop coercing shm_size to a number; keep the
  byte-size string (bare numbers normalized to raw-byte string for compat).
- go-sdk: DockerContainerCreateRequestContainer.ShmSize is now *string.

Co-authored-by: Plurality by Beyond Cloud
@madejackson

Copy link
Copy Markdown
Contributor Author

What commit 17e69eb does

Aligns Cosmos's shm_size handling with Docker Compose's upstream behavior.

The problem: Docker Compose specifies shm_size as a byte-value string — e.g. "64mb", "1gb", "512kb" — but Cosmos stored and transmitted it as a raw integer byte count (int64). The compose importer even actively destroyed the unit by parsing the string to a number before sending it, so shm_size: 64mb would silently become raw bytes.

The fix:

  • src/docker/api_blueprint.goContainerCreateRequestContainer.ShmSize is now a string; parsed to raw bytes at container-create time via units.RAMInBytes(), mirroring the existing mem_limit/mem_reservation handling.
  • src/docker/export.go — formats the daemon's raw byte count back into a compact {amount}{unit} string on export, so round-tripped services/exports behave identically to the original compose file.
  • client/.../docker-compose.jsx — stops coercing shm_size to a number; keeps the byte-size string (bare numbers still normalized to a raw-byte string for backward compat).
  • go-sdk/client.gen.goDockerContainerCreateRequestContainer.ShmSize updated to *string to match.

Result: shm_size behaves the same as docker-compose — "64mb", "1gb", "512kb" etc. are accepted and preserved, and existing compose files / exports round-trip correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant