|
1 | 1 | # Image Manager |
2 | 2 |
|
3 | | -Converts OCI container images into bootable ext4 disk images for Cloud Hypervisor VMs. |
| 3 | +Converts OCI images to bootable ext4 disks for Cloud Hypervisor VMs. |
4 | 4 |
|
5 | 5 | ## Architecture |
6 | 6 |
|
@@ -46,23 +46,35 @@ OCI Registry → containers/image → OCI Layout → umoci → rootfs/ → mkfs. |
46 | 46 | - `-O ^has_journal` - No journal (disks mounted read-only in VMs, saves ~32MB) |
47 | 47 | - Minimum 10MB size covers ext4 metadata (~5MB for superblock, inodes, bitmaps) |
48 | 48 |
|
49 | | -**Alternative tried:** go-diskfs pure Go ext4 - has bugs |
| 49 | +**Alternative tried:** go-diskfs pure Go ext4, got too complicated. Could revisit this. |
50 | 50 |
|
51 | | -**Tradeoff:** Shell command vs pure Go, but mkfs.ext4 is universally available and robust |
| 51 | +**Tradeoff:** Shell command vs pure Go, but mkfs.ext4 is widely available and robust |
| 52 | + |
| 53 | +## Filesystem Layout (storage.go) |
52 | 54 |
|
53 | | -## Filesystem Persistence (storage.go) |
54 | 55 |
|
55 | | -**Metadata:** JSON files with atomic writes (tmp + rename) |
56 | 56 | ``` |
57 | | -/var/lib/hypeman/images/{id}/ |
58 | | - rootfs.ext4 |
59 | | - metadata.json |
| 57 | +/var/lib/hypeman/ |
| 58 | + images/ |
| 59 | + docker.io/library/alpine/ |
| 60 | + latest/ |
| 61 | + metadata.json # Status, entrypoint, cmd, env |
| 62 | + rootfs.ext4 # Bootable disk |
| 63 | + 3.18/ # Different version |
| 64 | + system/oci-cache/ |
| 65 | + docker.io/library/alpine/latest/ |
| 66 | + blobs/sha256/... # Shared layers, persistent |
60 | 67 | ``` |
61 | 68 |
|
62 | | -**Why filesystem vs database?** |
63 | | -- Disk images must be on filesystem anyway |
64 | | -- No sync issues between DB and actual artifacts |
65 | | -- Simple recovery (scan directory to rebuild state) |
| 69 | +**Benefits:** |
| 70 | +- Natural hierarchy (versions grouped) |
| 71 | +- Layer caching (alpine:latest and alpine:3.18 share base layers) |
| 72 | + |
| 73 | +## Input Validation |
| 74 | + |
| 75 | +Uses `github.com/distribution/reference` to validate and normalize names: |
| 76 | +- `alpine` → `docker.io/library/alpine:latest` |
| 77 | +- Rejects invalid formats (returns 400) |
66 | 78 |
|
67 | 79 | ## Build Tags |
68 | 80 |
|
|
0 commit comments