Skip to content

Commit

Permalink
Add Image Sizes
Browse files Browse the repository at this point in the history
When selecting an image based on metadata we need to raise an error, or
select a version that will actual fit on the selected flavor, or limit
flavor selection to those that will work with the image.  Or vice versa!
  • Loading branch information
spjmurray committed Dec 5, 2024
1 parent 5d6055e commit 1289b66
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 142 deletions.
4 changes: 2 additions & 2 deletions charts/region/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ description: A Helm chart for deploying Unikorn's Region Controller

type: application

version: v0.1.47-rc3
appVersion: v0.1.47-rc3
version: v0.1.47-rc4
appVersion: v0.1.47-rc4

icon: https://raw.githubusercontent.com/unikorn-cloud/assets/main/images/logos/dark-on-light/icon.png

Expand Down
1 change: 1 addition & 0 deletions pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ func convertImage(in providers.Image) openapi.Image {
CreationTime: in.Created,
},
Spec: openapi.ImageSpec{
SizeGiB: in.SizeGiB,
Virtualization: convertImageVirtualization(in.Virtualization),
Os: openapi.ImageOS{
Kernel: convertOsKernel(in.OS.Kernel),
Expand Down
281 changes: 141 additions & 140 deletions pkg/openapi/schema.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions pkg/openapi/server.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -775,9 +775,13 @@ components:
description: An image.
type: object
required:
- sizeGiB
- virtualization
- os
properties:
sizeGiB:
description: Minimum disk size required to use the image in GiB.
type: integer
virtualization:
$ref: '#/components/schemas/imageVirtualization'
os:
Expand Down Expand Up @@ -1480,6 +1484,7 @@ components:
name: ubu2204-v1.25.6-gpu-525.85.05-7ced4154
creationTime: 2023-02-22T12:04:13Z
spec:
sizeGiB: 10
virtualization: virtualized
os:
kernel: linux
Expand Down
3 changes: 3 additions & 0 deletions pkg/openapi/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions pkg/providers/openstack/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,19 @@ func (p *Provider) Images(ctx context.Context) (providers.ImageList, error) {

virtualization, _ := image.Properties["unikorn:virtualization"].(string)

size := image.MinDiskGigabytes

if size == 0 {
// Round up to the nearest GiB.
size = int((image.VirtualSize + (1 << 30) - 1) >> 30)
}

providerImage := providers.Image{
ID: image.ID,
Name: image.Name,
Created: image.CreatedAt,
Modified: image.UpdatedAt,
SizeGiB: size,
Virtualization: providers.ImageVirtualization(virtualization),
OS: p.imageOS(image),
Packages: p.imagePackages(image),
Expand Down
2 changes: 2 additions & 0 deletions pkg/providers/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ type Image struct {
Created time.Time
// Modified is when the image was modified.
Modified time.Time
// SizeGiB is the minumum disk size for the image in GiB.
SizeGiB int
// ImageVirtualization defines how the image can be used.
Virtualization ImageVirtualization
// GPU is any GPU specific configuration for scheduling on a specific flavor type.
Expand Down

0 comments on commit 1289b66

Please sign in to comment.