New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug 1836337: Azure: Add functionality to change Azure Machine Disk Types #3520
Bug 1836337: Azure: Add functionality to change Azure Machine Disk Types #3520
Conversation
/test e2e-azure |
This PR should update docs as well. |
d571086
to
ee4ab7f
Compare
/test e2e-azure |
/test images |
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.
Validation pieces needs to be moved to install config validation.
docs/user/azure/customization.md
Outdated
@@ -18,6 +18,7 @@ The following options are available when using Azure: | |||
|
|||
* `osDisk` (optional object): | |||
* `diskSizeGB` (optional integer): The size of the disk in gigabytes (GB). | |||
* `diskType` (optional string): The type of the disk. (Values allowed are Premium_LRS, Standard_LRS, StandardSSD_LRS) |
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.
* `diskType` (optional string): The type of the disk. (Values allowed are Premium_LRS, Standard_LRS, StandardSSD_LRS) | |
* `diskType` (optional string): The type of disk (allowed values are: `Premium_LRS`, `Standard_LRS`, and `StandardSSD_LRS`). |
pkg/asset/machines/master.go
Outdated
@@ -263,6 +263,11 @@ func (m *Master) Generate(dependencies asset.Parents) error { | |||
} | |||
pool.Platform.Azure = &mpool | |||
|
|||
if mpool.OSDisk.DiskType == "Standard_LRS" { |
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.
This doesn't seem like the right place for validation. Shouldn't this be validated in the install config?
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.
This validation is only for the master. The worker will still take up the value. Since the value for the master alone cannot be HDD but it can be for the workers and since there is only one diskType for both master and worker, I thought placing it here would minimize code.
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.
See #3520 (comment)
The code in this file is for creating machine assets. The code in the link above is where we validate install configs
pkg/asset/machines/master.go
Outdated
@@ -263,6 +263,11 @@ func (m *Master) Generate(dependencies asset.Parents) error { | |||
} | |||
pool.Platform.Azure = &mpool | |||
|
|||
if mpool.OSDisk.DiskType == "Standard_LRS" { | |||
logrus.Warnf("%s disktype not recommended for master, switching to Premium_LRS", mpool.OSDisk.DiskType) | |||
mpool.OSDisk.DiskType = "Premium_LRS" |
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 think it's better to error out and let users determine course of action.
pkg/types/azure/machinepool.go
Outdated
@@ -38,4 +44,18 @@ func (a *MachinePool) Set(required *MachinePool) { | |||
if required.OSDisk.DiskSizeGB != 0 { | |||
a.OSDisk.DiskSizeGB = required.OSDisk.DiskSizeGB | |||
} | |||
|
|||
a.OSDisk.DiskType = validateDiskType(required.OSDisk.DiskType) |
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.
validation should not be performed here. Check out https://github.com/openshift/installer/blob/master/pkg/types/validation/installconfig.go#L302-L331 but I think some modification may be necessary.
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 we were to error out if invalid value is given then I think this code should be in here since it's azure specific.
installer/pkg/types/azure/validation/machinepool.go
Lines 9 to 16 in 6f9a0b8
func ValidateMachinePool(p *azure.MachinePool, fldPath *field.Path) field.ErrorList { | |
allErrs := field.ErrorList{} | |
if p.OSDisk.DiskSizeGB < 0 { | |
allErrs = append(allErrs, field.Invalid(fldPath.Child("diskSizeGB"), p.OSDisk.DiskSizeGB, "Storage DiskSizeGB must be positive")) | |
} | |
return allErrs | |
} |
Making the changes.
pkg/types/azure/machinepool.go
Outdated
|
||
a.OSDisk.DiskType = validateDiskType(required.OSDisk.DiskType) | ||
} | ||
func validateDiskType(diskType string) string { |
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.
validating and setting defaults are two different functions
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.
Couldn't find an appropriate function name for this. It validates the value and sets the default when there is empty or invalid value.
pkg/types/azure/machinepool.go
Outdated
if diskType == "" { | ||
return "Premium_LRS" | ||
} | ||
_, found := map[string]string{"Standard_LRS": "", "StandardSSD_LRS": "", "Premium_LRS": ""}[ //"UltraSSD_LRS": "", |
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.
This is hard to read. UltraSSD_LRS
even if commented out should not be within the indexing operator.
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.
gofmt formatted it that way when I tried to create a new line and comment it. I think I'll move it to the top of this line.
ee4ab7f
to
f59a394
Compare
With the new commit, I have kind of fixed the top level Machine Pool validation that the master workers in Azure must not use the Standard HDD disks but the top level Platform where the defaultMachinePlatform value is not fixed specifically for the master machines. |
f59a394
to
f5f2b3b
Compare
//"UltraSSD_LRS": "", | ||
_, found := map[string]string{"Standard_LRS": "", "StandardSSD_LRS": "", "Premium_LRS": ""}[p.OSDisk.DiskType] |
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:
keep a list of known valid values and then run sets.NewString(knownDiskTypes...).Has(p.OSDisk.DiskType)
that helps with readability as a constant list is easy to track and maintain outside the function.
//"UltraSSD_LRS": "", | ||
_, found := map[string]string{"Standard_LRS": "", "StandardSSD_LRS": "", "Premium_LRS": ""}[p.OSDisk.DiskType] | ||
if !found { | ||
allErrs = append(allErrs, field.Invalid(fldPath.Child("diskType"), p.OSDisk.DiskType, "Storage DiskType value 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.
include the list of supported values in the message.
Also i think there is https://www.godoc.org/k8s.io/apimachinery/pkg/util/validation/field#NotSupported
if pool.Platform.Azure != nil && pool.Name == masterPoolName && pool.Platform.Azure.OSDisk.DiskType == "Standard_LRS" { | ||
allErrs = append(allErrs, field.Invalid(fldPath.Child("diskType"), pool.Platform.Azure.OSDisk.DiskType, "DiskType not compatible with master machines.")) | ||
} |
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 think this is redundant, as you already have https://github.com/openshift/installer/pull/3520/files#diff-e8044151bf8d8c8e84c04c49911da440R64-R66
@@ -355,6 +358,9 @@ func validatePlatform(platform *types.Platform, fldPath *field.Path, openStackVa | |||
validate(azure.Name, platform.Azure, func(f *field.Path) field.ErrorList { | |||
return azurevalidation.ValidatePlatform(platform.Azure, c.Publish, f) | |||
}) | |||
if platform.Azure.DefaultMachinePlatform != nil && platform.Azure.DefaultMachinePlatform.OSDisk.DiskType == "Standard_LRS" { | |||
allErrs = append(allErrs, field.Invalid(fldPath.Child(azure.Name), platform.Azure.DefaultMachinePlatform.OSDisk.DiskType, "Disk type \"Standard_LRS\" not recommended as default disk for machines.")) |
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, don't use .
also try not to use \"
, you can use `string with "quotes" here`
pkg/types/validation/machinepools.go
Outdated
@@ -61,6 +61,9 @@ func ValidateMachinePool(platform *types.Platform, p *types.MachinePool, fldPath | |||
if !validArchitectures[p.Architecture] { | |||
allErrs = append(allErrs, field.NotSupported(fldPath.Child("architecture"), p.Architecture, validArchitectureValues)) | |||
} | |||
if p.Platform.Azure != nil && p.Name == masterPoolName && p.Platform.Azure.OSDisk.DiskType == "Standard_LRS" { | |||
allErrs = append(allErrs, field.Invalid(fldPath.Child("diskType"), p.Platform.Azure.OSDisk.DiskType, "DiskType not compatible with master machines.")) |
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 : don;'t have the fieldName in the error message too, it's already part of fldPath.Child("diskType")
something like Standard_LRS is not compatible with control plane machines
docs/user/azure/customization.md
Outdated
@@ -65,6 +66,7 @@ controlPlane: | |||
type: Standard_DS4_v2 | |||
osDisk: | |||
diskSizeGB: 512 | |||
diskType: Standard_LRS |
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.
this is not a valid setting with your validations :P
since it's still in WIP.
That would be very helpful 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.
I requested some changes. I think the biggest issue is we don't know how to handle defaultMachinePool
. Master machines cannot have Standard_LRS
. So would the ideal way to handle validating the defaultMachinePool
be to not allow Standard_LRS
for the default pool unless a control plane machine pool was provided?
There are certainly some challenges to achieving this. For one, defaultMachinePool
s do not seem to have a predictable name. We might be able to check based on name is not worker
or master
... This might also require some not insignificant replumbing of machinepool validation.
//"UltraSSD_LRS": "", | ||
_, found := map[string]string{"Standard_LRS": "", "StandardSSD_LRS": "", "Premium_LRS": ""}[p.OSDisk.DiskType] | ||
if !found { | ||
allErrs = append(allErrs, field.Invalid(fldPath.Child("diskType"), p.OSDisk.DiskType, "Storage DiskType value 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.
What about something like:
diskTypes := map[string]string{
"Standard_LRS": "",
"StandardSSD_LRS": "",
"Premium_LRS": "",
//"UltraSSD_LRS": "", // currently in preview
}
if _, found := diskTypes[p.OSDISK.DiskType]; !found {
allErrs = append(allErrs, field.Invalid(fldPath.Child("diskType"), p.OSDisk.DiskType, "Storage DiskType value invalid"))
}
@@ -307,6 +307,9 @@ func validateControlPlane(platform *types.Platform, pool *types.MachinePool, fld | |||
if pool.Replicas != nil && *pool.Replicas == 0 { | |||
allErrs = append(allErrs, field.Invalid(fldPath.Child("replicas"), pool.Replicas, "number of control plane replicas must be positive")) | |||
} | |||
if pool.Platform.Azure != nil && pool.Name == masterPoolName && pool.Platform.Azure.OSDisk.DiskType == "Standard_LRS" { |
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.
All Azure-specific validation should happen in https://github.com/openshift/installer/blob/master/pkg/types/azure/validation/machinepool.go
If you need variables that are not available, you should plumb them.
pkg/types/validation/machinepools.go
Outdated
@@ -61,6 +61,9 @@ func ValidateMachinePool(platform *types.Platform, p *types.MachinePool, fldPath | |||
if !validArchitectures[p.Architecture] { | |||
allErrs = append(allErrs, field.NotSupported(fldPath.Child("architecture"), p.Architecture, validArchitectureValues)) | |||
} | |||
if p.Platform.Azure != nil && p.Name == masterPoolName && p.Platform.Azure.OSDisk.DiskType == "Standard_LRS" { |
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.
Isn't this the same check as https://github.com/openshift/installer/pull/3520/files#diff-02200a3eac2ac223b4117e690cf2d0c7R310?
As with the comment for that line, this should be consolidated into Azure-specific validation.
@@ -355,6 +358,9 @@ func validatePlatform(platform *types.Platform, fldPath *field.Path, openStackVa | |||
validate(azure.Name, platform.Azure, func(f *field.Path) field.ErrorList { | |||
return azurevalidation.ValidatePlatform(platform.Azure, c.Publish, f) | |||
}) | |||
if platform.Azure.DefaultMachinePlatform != nil && platform.Azure.DefaultMachinePlatform.OSDisk.DiskType == "Standard_LRS" { |
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.
All Azure-specific validation should be the in the azure validation package.
i think it is okay to validate where the information is available completely, if the definition of check is platform specific we can start with keeping it in general function, and later move it to platform specific location when there is more need. for now, we could also just move all the check for control-plane disk to asset/machines/master.go to keep this simpler. |
pkg/types/validation/machinepools.go
Outdated
@@ -61,6 +61,9 @@ func ValidateMachinePool(platform *types.Platform, p *types.MachinePool, fldPath | |||
if !validArchitectures[p.Architecture] { | |||
allErrs = append(allErrs, field.NotSupported(fldPath.Child("architecture"), p.Architecture, validArchitectureValues)) | |||
} | |||
if p.Platform.Azure != nil && p.Name == masterPoolName && p.Platform.Azure.OSDisk.DiskType == "Standard_LRS" { | |||
allErrs = append(allErrs, field.Invalid(fldPath.Child("diskType"), p.Platform.Azure.OSDisk.DiskType, "DiskType not compatible with master machines.")) |
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.
master machines
-> control plane
Since this is validating the default machine pool perhaps the error message could point the user that this is a valid selection for the control plane machine pool
f5f2b3b
to
5b86cb3
Compare
Fixed most of it (I think). Added validation checks for UltraSSD support but could not create a disk with it because the support for it in Azure terraform is available in version 2.0. There are some deprecation issues that need to be solved if terraform is to be updated. An example of deprecation is
|
64f6653
to
01affa6
Compare
Will wait for #3526 to complete and then work on the changes for the Ultra SSD in a separate pull request. Pushing code with inclusion of other disk type support. |
this is missing https://github.com/openshift/installer/pull/3595/files#diff-c2be8487621063db19a181fa83200aa3 like updates to customization.md @rna-afk |
4cc16bd
to
4072b43
Compare
4072b43
to
22db280
Compare
/test e2e-azure |
/retest |
/lgtm /retest |
/retest Please review the full test history for this PR and help us cut down flakes. |
14 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
@rna-afk: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/retest Please review the full test history for this PR and help us cut down flakes. |
@rna-afk: All pull requests linked via external trackers have merged: openshift/installer#3520. Bugzilla bug 1836337 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Azure disk types for the master and worker nodes is by default
set to Premium SSD(Premium_LRS) setting. Made the changes to add
the disktype of the master and worker nodes in the install config
by adding an extra field in MachinePool DiskType to the OSDisk struct
which is part of the DefaultMachinePlatform attribute in the Azure
Platform type. To change the disk type, the install config must be
changed by adding the diskType under platform->Azure property by adding
the defaultMachinePlatform->osDisk->diskType and setting the value to
one of the following, Premium_LRS, Standard_LRS and StandardSSD_LRS.
Setting Standard_LRS is not recommended for the master nodes and hence,
if the disktype is set to it then the Master node is defaulted to Premium_LRS
and the worker nodes will take up the Standard_LRS.
Also, DefaultMachinePlatform can only have both Premium_LRS or
StandardSSD_LRS for the above reason.
Currently, the UltraSSD_LRS is under construction as the terraform version
needs to be updated.