-
Notifications
You must be signed in to change notification settings - Fork 228
Support external volumes (block devices) in Ignite VMs #275
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; this will need to wait for #280, on top of that you can rebase successfully to minimize the changes in this PR
cmd/ignite/cmd/cmdutil/volumeflag.go
Outdated
switch len(paths) { | ||
case 0: | ||
// No paths given | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this error? --volume=
seem invalid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking an input like /path:/path,,/path:/path
, but maybe it should error in that case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, please error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in ca75db1.
cmd/ignite/cmd/cmdutil/volumeflag.go
Outdated
case 2: // We were given | ||
// Set the VM path and verify it's absolute | ||
if vmPath = paths[1]; !path.IsAbs(vmPath) { | ||
return absPathsErr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you like, this can be done here too, but this validation should exist in pkg/apis/ignite/validation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will move/add it to validation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in ca75db1.
cmd/ignite/cmd/cmdutil/volumeflag.go
Outdated
} | ||
|
||
fallthrough | ||
case 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why support --volume /my-block-device
? I don't think docker does. I like being explicit in from where to where
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You suggested that we would support single paths, with the same path being applied for both the host and the VM. It's a bit illogical though as on the host that path points to a block device, but in the VM the path is a mounted directory. I'll remove that support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in ca75db1.
cmd/ignite/cmd/cmdutil/volumeflag.go
Outdated
} | ||
|
||
// Verify that the host path points to a device file | ||
if err := util.DeviceFile(hostPath); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: IsDeviceFile
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed in ca75db1.
cmd/ignite/cmd/cmdutil/volumeflag.go
Outdated
} | ||
|
||
// If the VM path is not set, use the host path | ||
if len(vmPath) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove; IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in ca75db1.
|
||
// Volume defines named storage volume | ||
type Volume struct { | ||
Name string `json:"name"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add validation that this must be set, and must match something in volumemounts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in the validation added in ca75db1.
// VolumeMount defines the mount point for a named volume inside a VM | ||
type VolumeMount struct { | ||
Name string `json:"name"` | ||
MountPath string `json:"mountPath"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add validation that this field must be set, and must be absolute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in the validation added in ca75db1.
|
||
// VolumeMount defines the mount point for a named volume inside a VM | ||
type VolumeMount struct { | ||
Name string `json:"name"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add validation that this must be set, and must match something in volumes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in the validation added in ca75db1.
pkg/container/firecracker.go
Outdated
|
||
cfg.Drives = append(cfg.Drives, models.Drive{ | ||
DriveID: firecracker.String(strconv.Itoa(i + 2)), | ||
IsReadOnly: firecracker.Bool(false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a TODO to support readonly volumes eventually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in ca75db1.
} | ||
|
||
for _, entry := range entries { | ||
if entry.isValid() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at least put a warning if it's not valid? log.Errorf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It now returns an error in ca75db1, this should never happen thanks to validation.
I just rebased and ran autogen/tidy on this PR so that it's well in shape tomorrow when you continue on it. I think it would make sense to squash your commits in a logical order before removing the wip label |
The CI test appears to fail on |
Also add them to `v1alpha2` and add conversions for `v1alpha1`.
Commit history rebased to exclude CI/build/meta changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks for the fixes, and the rebase.
This LGTM 👍
This PR adds support for exposing host block devices inside Ignite VMs. It also sports internal automounting support via
/etc/fstab
. The volumes are now declared in the API as.spec.storage.volumes
and.spec.storage.volumeMounts
k8s style, so this changesv1alpha2
.Fixes #76.
cc @luxas