Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Support external volumes (block devices) in Ignite VMs #275

Merged
merged 14 commits into from
Aug 7, 2019

Conversation

twelho
Copy link
Contributor

@twelho twelho commented Aug 5, 2019

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 changes v1alpha2.
Fixes #76.

cc @luxas

@twelho twelho added kind/feature Categorizes issue or PR as related to a new feature. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/design Categorizes issue or PR as related to the design of the project. do-not-merge/wip The PR is still work in progress labels Aug 5, 2019
@twelho twelho added this to the v0.5.0 milestone Aug 5, 2019
@twelho twelho removed the do-not-merge/wip The PR is still work in progress label Aug 5, 2019
Copy link
Contributor

@luxas luxas left a 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

switch len(paths) {
case 0:
// No paths given
continue
Copy link
Contributor

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

Copy link
Contributor Author

@twelho twelho Aug 6, 2019

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, please error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in ca75db1.

case 2: // We were given
// Set the VM path and verify it's absolute
if vmPath = paths[1]; !path.IsAbs(vmPath) {
return absPathsErr
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in ca75db1.

}

fallthrough
case 1:
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in ca75db1.

}

// Verify that the host path points to a device file
if err := util.DeviceFile(hostPath); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: IsDeviceFile instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed in ca75db1.

}

// If the VM path is not set, use the host path
if len(vmPath) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove; IMO

Copy link
Contributor Author

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"`
Copy link
Contributor

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

Copy link
Contributor Author

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"`
Copy link
Contributor

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

Copy link
Contributor Author

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"`
Copy link
Contributor

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

Copy link
Contributor Author

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.


cfg.Drives = append(cfg.Drives, models.Drive{
DriveID: firecracker.String(strconv.Itoa(i + 2)),
IsReadOnly: firecracker.Bool(false),
Copy link
Contributor

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?

Copy link
Contributor Author

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() {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@twelho twelho added the do-not-merge/wip The PR is still work in progress label Aug 6, 2019
@luxas
Copy link
Contributor

luxas commented Aug 6, 2019

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

@twelho twelho requested a review from luxas August 7, 2019 11:53
@twelho twelho removed the do-not-merge/wip The PR is still work in progress label Aug 7, 2019
@twelho
Copy link
Contributor Author

twelho commented Aug 7, 2019

The CI test appears to fail on openapi/violations.txt changes, for this branch openapi-gen removed a bunch of lines there.

@twelho
Copy link
Contributor Author

twelho commented Aug 7, 2019

Commit history rebased to exclude CI/build/meta changes.

Copy link
Contributor

@luxas luxas left a 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 👍

@luxas luxas merged commit 3f5fe66 into weaveworks:master Aug 7, 2019
@twelho twelho deleted the volume-support branch August 7, 2019 14:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/design Categorizes issue or PR as related to the design of the project. kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for adding volumes to ignite run
2 participants