Skip to content
This repository was archived by the owner on Feb 5, 2020. It is now read-only.

installer: validate libvirt#3265

Merged
squat merged 1 commit intocoreos:masterfrom
squat:validate_libvirt
Jun 8, 2018
Merged

installer: validate libvirt#3265
squat merged 1 commit intocoreos:masterfrom
squat:validate_libvirt

Conversation

@squat
Copy link
Contributor

@squat squat commented Jun 6, 2018

This commit adds validation for all libvirt fields. Additionally, it
moves the default values for these validated fields from Terraform to
Golang so that the defaults are handled consistently and we do not
accidentally omit configuration values by forgetting to plumb values
through Terraform.

Addresses: INST-1089

CC @enxebre @squeed

We need to set up our libvirt smoke tests so we can properly test future changes like this.

@squat squat requested review from enxebre and squeed June 6, 2018 12:39
// DefaultDNSServer is the default DNS server for libvirt.
DefaultDNSServer = "8.8.8.8"
// DefaultIfName is the default interface name for libvirt.
DefaultIfName = "tt0"
Copy link

Choose a reason for hiding this comment

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

Let's get "tectonic" out of this - how about osbr0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good. I should have confirmed with you earlier, I just grabbed what was in defaulted in the Terraform config.

Copy link

@squeed squeed Jun 6, 2018

Choose a reason for hiding this comment

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

at this point, it's completely arbitrary. oh, did you know that Linux interface names have no restrictions on characters? Let's just call it 🌉

if c.Platform != PlatformLibvirt {
return errs
}
if err := validate.PrefixError("libvirt network ipRange", validate.SubnetCIDR(c.Libvirt.Network.IPRange)); err != nil {
Copy link

Choose a reason for hiding this comment

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

It's not 100% necessary, but if you want to validate that this doesn't overlap with the cluster and service cidrs, that would be awesome!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

if err := validate.PrefixError("libvirt uri", validate.NonEmpty(c.Libvirt.URI)); err != nil {
errs = append(errs, err)
}
if err := validate.PrefixError("libvirt imagePath", validate.NonEmpty(c.Libvirt.QOWImagePath)); err != nil {
Copy link

Choose a reason for hiding this comment

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

Is it possible to validate that this is a valid path on disk? Even more amazing would be validating that the first four bytes match QFI\xFB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool idea!

@squeed
Copy link

squeed commented Jun 6, 2018

A few suggestions, but looks great!

@squat squat force-pushed the validate_libvirt branch from cc1c726 to 5fb34a3 Compare June 6, 2018 16:06
@squat
Copy link
Contributor Author

squat commented Jun 6, 2018

Thanks @squeed! I made the requested additions. It meant some refactoring of the CIDR comparison code so the PR grew a little bit. Please take another look when you can.

@squat
Copy link
Contributor Author

squat commented Jun 6, 2018

I also replaced all occurrences of qow with qcow

@squat squat force-pushed the validate_libvirt branch from 5fb34a3 to 9afbdbf Compare June 7, 2018 09:30
squeed
squeed previously approved these changes Jun 7, 2018
@squat
Copy link
Contributor Author

squat commented Jun 7, 2018

rebased again hehe

This commit adds validation for all libvirt fields. Additionally, it
moves the default values for these validated fields from Terraform to
Golang so that the defaults are handled consistently and we do not
accidentally omit configuration values by forgetting to plumb values
through Terraform.
Copy link
Contributor

@alexsomesan alexsomesan left a comment

Choose a reason for hiding this comment

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

LGTM

@squat squat merged commit 72b2a9a into coreos:master Jun 8, 2018
@squat squat deleted the validate_libvirt branch June 8, 2018 09:32
wking added a commit to wking/openshift-installer that referenced this pull request Nov 29, 2018
DefaultIfName was added in f245ca6 (installer: validate libvirt,
2018-06-06, coreos/tectonic-installer#3265), but the last consumer was
removed by 619db92 (pkg/types/config: Break into pkg/validate and
pkg/tfvars, 2018-10-03, openshift#412).  We currently feed the default bridge
name in via pkg/asset/installconfig/libvirt's defaultNetworkIfName.

The AWS and OpenStack default variables I'm also removing here have a
similar history and current default location.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants